Skip to content

Instantly share code, notes, and snippets.

@drakeirving
Last active November 15, 2016 11:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drakeirving/885fe82e4da206e8b4f87ba2b6cd36c7 to your computer and use it in GitHub Desktop.
Save drakeirving/885fe82e4da206e8b4f87ba2b6cd36c7 to your computer and use it in GitHub Desktop.
Bullet Trail Effect
task ManageEffectTrail(){
// CreateShotA1(ObjMove_GetX(objEnemy),ObjMove_GetY(objEnemy), 2, 80, SHOT_RING_RED, 0);
let num = 20;
let delay = 1;
let textures = [];
let tex_objs = [];
ascent(i in 0..num){
textures = textures ~ ["EffectBuffer"~itoa(i)];
CreateRenderTarget(textures[i]);
tex_objs = tex_objs ~ [ makeTextureObject(textures[i]) ];
}
function makeTextureObject(texture){
let obj = ObjPrim_Create(OBJ_SPRITE_2D);
ObjRender_SetPosition(obj, 0, 0, 0);
ObjPrim_SetTexture(obj, texture);
ObjSprite2D_SetSourceRect(obj, 32, 16, 32+384, 16+448);
ObjSprite2D_SetDestRect(obj, 0, 0, 384, 448);
Obj_SetRenderPriorityI(obj, 49);
return obj;
}
let c = 0;
loop{ // exit condition?
RenderToTextureA1(textures[c], 50, 50, true);
ascent(i in 0..num){
// Obj_SetRenderPriorityI( tex_objs[(c - i) % num], 49 - i );
ObjRender_SetAlpha( tex_objs[(c - i) % num], 255 - 255*(i+1)/(num+1) );
}
c = (c + 1) % num;
loop(delay){yield;}
}
ascent(i in 0..length(tex_objs)){ Obj_Delete(tex_objs[i]); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment