Wegen you hit the flag, set a flag (heh) in the code, and stop updating the have world in update, and render the face out fadeout in draw
Should have said in my post but I'm not a good coder, I know it's something to do through those functions but I don't know the code to use/where to start
Ah, sorry.
The game state (like movement, etc) should only be updated in update.
This allows you to make a giant if around then.
Another option, that might be more easy might be to use a different _update and _draw function.
Replacing update will make sure that nothing gets updated, and changing draw will allow you to simply draw the black areas on the last state, until it's black.
I'm currently not at my computer, will give you an example later.
So, here's an example.
It starts in the "game state' which draws a lot of circles.
As soon as you press x, t switches to the fade out.
When the fadeout is doe, it switches to the exit screen.
function _init() stuff={} local a for a=1,32 do add(stuff,{ rnd(128),rnd(128), --x,y rnd(8), --r rnd(2), --dr flr(rnd(5))+8 }) end end function _update() local item for item in all(stuff) do item[3]+=item[4] if (item[3]>32) then item[1] = rnd(128) item[2] = rnd(128) item[3] = rnd(2) end end if btn(❎) then freeze_init() end end function _draw() cls() local a for item in all(stuff) do local x,y,r,dr,col=unpack(item) circfill(x,y,r,col) end printb("press ❎ to freeze", 10,120, 9,0) end function printb(txt,_x,_y,c1,c2) local x,y c2= c2 or 0 for y=-1,1 do for x=-1,1 do print(txt,x+_x,y+_y,c2) end end print(txt,_x,_y,c1) end function freeze_init() freeze_frame=0 _update=freeze_update _draw =freeze_draw end function freeze_update() freeze_frame+=2 if freeze_frame > 63 then exit_init() end end function freeze_draw() rectfill(0,0,128,freeze_frame,0) rectfill(0,127-freeze_frame,128,128) end function exit_init() _update=exit_update _draw =exit_draw end function exit_update() end function exit_draw() rectfill(0,0,128,128,10) circfill(100,110,80,9) circfill(30,110,50,9) printb("the end",55,50,8) end |
@jmsnsh - it would be nice if you could give some feedback.
hey! thank you for this, i ended up going something slightly different using circfill instead of rectfill, but i wouldn't have got there without this code, very thankful for your help!
I know you used circfill (see my reply in the other thread), but there wasn't any feedback in the other thread, either, so I was wondering.
Glad it helped.
[Please log in to post a comment]