PDA

View Full Version : Pause a lua script?



Anonymous D
July 11th, 2007, 19:47
is it possible to make a lua script pause for a certain amount of time e.g :

(hitest player with enemy)
if hitest (true) then
draw image 1
pause
draw image 2
pause
draw image 3
end

(with proper syntax of course) . just im trying to show a ship exploding but just blitting all the images in a row only takes a few milleseconds so you dont actually see anything.

dangee
July 11th, 2007, 21:14
screen:flip();
repeat until Controls.read()circle();
repeat until not Controls.read()circle();
screen:flip()

-Xandu-
July 11th, 2007, 21:22
You can do like:

while true do

if not paused then
GAME CODE
elseif paused then
DISPLAY PAUSE SCREEN (unpause here)
end

Anonymous D
July 11th, 2007, 21:42
thanks in a way..i dontt hink i explained very well. basically what i want is to display a sprite sequence but with a pause in between each image (otherwise you dont see them). and i want it to be sort off automatic rather than awating input from the player.

dangee
July 11th, 2007, 21:46
k, replace the Controls lines with
System.sleep(5000) --(5 sec pause)

Anonymous D
July 11th, 2007, 21:48
will do thanks dangee...trying now....

edit: that seems to just stop the script for ever, its what i want but its to permenant lol

sos i misunderstood you ig et what you mean now

edit could you show me how youd use it with an image draw..
basically write it out with a blank blit in the right position

jak66
July 11th, 2007, 22:29
try
screen.waitVblankStart(X)
replace X with amount of time you want pause for

Anonymous D
July 11th, 2007, 22:40
that has got me closets to my goal thanks very much.
thanks people, ive got it working now, apart from some strange bug which makes evertrything but the animation sprites move back and forward....but ill try and disguise it with an explosion sound and call it an effect lol i am making a shump after all

edit: also how wud i have 2 sounds play at once.. e.g sound effects along with sound music, ive tried it before with the normal sound things and one always seems to stop the other eventually if not immediatley

dangee
July 12th, 2007, 07:19
dont give up on this one.the small details in the
GFX can make a big diff.(re:wunmorgo).
The sprites r dancing to & fro coz after the pause ur
flipping back to the previous screen.I thought the pause was
just for debug reasons. What you can do for each frame of the
animation is:

for i = 1 to numberOfAframes do
-- draw frame(i) to screen 1
-- flip
-- draw frame(i) to screen 2
-- flip
-- pause
end

*EDIT*..or just
-- draw frame(i)
-- flip
-- pause
should do it..

Anonymous D
July 12th, 2007, 13:08
well basically ive got:

(hitest with enemy and other stuff in if loop) then
(reset enemy position back to original (off screeen))
screen:blit(Player[1].x,Player[1].y, player2)
screen:flip();
screen.waitVblankStart(1)

and so on till frame 7 of the explosion anim. player 1 is already drawn because that is the default image for the player ( a ship in this case)

dangee
July 12th, 2007, 19:32
looks like progress..
..only thng is, not sure that a pause for the
explosions a good idea coz its slowing all else on
screen including player1.
Suggest U blit each frame of the explosion multiple
times.
The PSP Vblanks at about 70hz, so for a 5 frame explosion
lasting 1 sec, blit each frame for 14 screen
flips using the standard:
waitVblankStart() ; screen:flip()
Update all other sprites at normal rate
U'll need a Vblank counter and an explosion frame counter
hope this makes some kinda sense..

Anonymous D
July 13th, 2007, 14:51
so i blit each one 14 times? or flip the screen 14 times?

dangee
July 13th, 2007, 16:17
this is getting tricky coz I still cant d/l
ur code from mediafire for some reason, but NEway
assuming a main loop like:

while true do
--read controls
--for i=1,numberOfSprites do
-- newSpritePosition(i)
-- if hitest(i) then drawExplosion(i) else drawSprite(i) end
--end
--waitVblankStart() screen:flip()
end

you get about 70 flips per sec.
in drawExplosion(), advance the explosion image
by one frame every 14 flips (using flip/frame counters)
to slow the explosion animation down by a
factor of 14

Anonymous D
July 14th, 2007, 12:22
im lost....im sure your perfectley right and all im just lost...ill upload my code that im using this for to somet other than mediafire for you..
http://files-upload.com/369991/sidescrollingshooterWIP.zip.html
plz just edit and reupload for me im totally lost and this bug is soo anoying me.

dangee
July 14th, 2007, 20:58
its probbly just my sloppy pseudo-code.
cant promise NEthng b4 I see ur script,but I'd like to have
a try at an edit..that link in ur post looks weird.Like
mediafire, it didnt d/l for me. Maybe my server-its been
up n' down like a yoyo on pcp recently. Can SUM1 post
the .zip as an attachment here plz..?

Anonymous D
July 14th, 2007, 21:53
ill try attaching it myself....

worked..woot now i cant post releases properly to musta been somet up with my conection b4, anyways there it is dangee

Safari Al
July 15th, 2007, 02:10
I think there was a gamestate thing on evilmana

dangee
July 15th, 2007, 04:26
k,got it..think i can help out (those are weerd
bullets..) First off, am adding a quit control and life
counter -1 for +1 after a hit..

*EDIT*now know Y my pseudo-code didnt make sense - thought it was NMEs Xploding , not player1!
(ignore that thng about the life counter,it was only to stop game over at 0)
should have a working first edit posted soonish..
*EDIT*..here it is, had to change the structures a bit.the pause logics near the top of the main loop.

Anonymous D
July 15th, 2007, 12:52
thanks a lot dangee, i will credit you if i ever get this thing into as full game. i may re interprit if you dont mind. but i see what you mean with it thanks a lot.

edit: Ive added the same sort of thing you wer doing into my original code, so as i can understand it better. thanks for showing me how to do it though.

dangee
July 15th, 2007, 14:44
well,thanx for persevering despite all the Gremlinz.
feels good, happy to have helped, & looking forward to playing version 1.0.

on the SFX : np354 used these WAV settings for SMM -
8 bit PCM Mono..