
-----------------------------------
Blade
Thu Mar 06, 2003 9:31 pm

Movin animations quickly
-----------------------------------
I'm currently making a pacman game... and i cant get him to open/close his mouth, and be able to make him move quickly at the same time... here's the animation code i'm currently using 

loop
    drawfillarc (x, y, 30, 30, 50, 330, yellow)
    delay (100)
    cls
    drawfillarc (x, y, 30, 30, 30, 370, yellow)
    delay(100)
    cls
end loop

with the delays being 100 in there i cant get him to move quickly around the screen, is there any other way to animate pacman??

-----------------------------------
Dan
Thu Mar 06, 2003 10:09 pm

mr. pac man
-----------------------------------
i whode use pics to do this but they can be hard to figer out so i will tell you how to do it your way. basilky you animate it by having  it when the key is hit the face swichs to  the next frame and the picher moves in the diserid direction. 

here is an example.


var key:string(1)
var x:int := maxx div 2
var y:int := maxy div 2
var frame:int := 1


loop 
    getch(key)    
    
    cls
    
    if ord(key) = 205 and frame = 1 then
        x += 5
        drawfillarc (x, y, 30, 30, 50, 330, yellow) 
        frame := 0
    elsif ord(key) = 205 and frame = 0 then
        x += 5
        drawfillarc (x, y, 30, 30, 30, 370, yellow) 
        frame := 1
    elsif ord(key) = 203 and frame = 1 then
        x -= 5
        drawfillarc (x, y, 30, 30, 50, 330, yellow) 
        frame := 0
    elsif ord(key) = 203 and frame = 0 then
        x -= 5
        drawfillarc (x, y, 30, 30, 30, 370, yellow) 
        frame := 1
    end if
    
    delay (100)
    
end loop


this code  only  use left and right keys and pac man looks same way going  in both dircetions but you get the idea.

-----------------------------------
Tony
Thu Mar 06, 2003 10:33 pm


-----------------------------------
also the use for delay is general a bad idea in the games... I mean why wait :wink:

but if you need to keep pacman from running around like a road-runner, you can just decrease the movement distance per loop. Such as instead of x:=x+1 you can slow it down 2 times by using x:=x+0.5 Its more accurate too

Another good way to consider is the use of an actual timer that calls procedures when the time is right. This way the program will run at the same speed on any machine (since 3GHz P4 is about 6 times faster then my Celeron 550  :cry: )

-----------------------------------
Blade
Thu Mar 06, 2003 10:44 pm


-----------------------------------
also the use for delay is general a bad idea in the games... I mean why wait :wink: ...

the reason i had to use the delays was because he would be animating waaay to fast.. then it slowed down the movement of pacman... you see what i mean?

-----------------------------------
Asok
Thu Mar 06, 2003 10:48 pm


-----------------------------------
Highest delay in a moving game should be 50.

if he is moving too fast change the movement modifier (the number x/y is increasing/decreasing by)

-----------------------------------
Tony
Thu Mar 06, 2003 10:51 pm


-----------------------------------
ya, thats what I explained after... delay(100) might be too much...

delay(1000) is 1 second. So 100 is 0.1 of a second. Your eyes keep an image for 0.06 of a second so thats not good enough. Movie's framerate is 32 per second :wink:

It might be a nice feature to add in a game to make delay duration a variable, so that the user can set the gamespeed. Also you can't go into negatives and I was playing in my own snakegame on 0 delay :?

-----------------------------------
Blade
Thu Mar 06, 2003 11:05 pm


-----------------------------------
that's not really the problem... dan knew what i was talking about... the problem was, with the image... he was chomping way too quickly, and i couldnt make him move as fast as i wanted him to... but if i lowered the delay, it looked really crappy cuz he was chomping too quickly, but he was able to move a little better, but not what i wanted... with dans code, its good though, because he moves as he chomps, i'd never thought of that

-----------------------------------
Tony
Thu Mar 06, 2003 11:08 pm


-----------------------------------
ahh... so thats the problem :wink:

should have played original pacman   8) 

but hey, still some good things to keep in mind while setting up the speed of your game

-----------------------------------
Dan
Thu Mar 06, 2003 11:09 pm


-----------------------------------
also i think that in the real pac man game he only chops when he moves. but i could be wrong i have not played it in like 3 years, lol.

-----------------------------------
Asok
Thu Mar 06, 2003 11:11 pm


-----------------------------------
No you're right dan, that's how Pacman AND Ms.Pacman work.

Ms.Pacman is cute  :oops:

-----------------------------------
Blade
Thu Mar 06, 2003 11:26 pm


-----------------------------------
haha, yeah it is right... my mom's still obsessed with that game..  :roll: 

but yeah, i want to thank you all for your help, i will keep that other stuff in mind  :D
