-
-
Save drakeirving/885fe82e4da206e8b4f87ba2b6cd36c7 to your computer and use it in GitHub Desktop.
Bullet Trail Effect
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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