Animating a character in a game
Author |
Message |
strike_hawk89
|
Posted: Wed May 25, 2005 10:20 am Post subject: Animating a character in a game |
|
|
i need to make a character for a game animate properly while walking. i know i posted something like this b4 but no one gave me a clear answer on how to solve the problem. here is the code i am using now. right now, i does not work properly. i want it so that when u press and hold the arrow key to move the character, the character moves his right leg, and then his left leg, so he looks like he is walking. code: | var x, y : int
x := 100
y := 100
var pic : array 1..2 of int
pic (1) := Pic.FileNew ("ninja1.bmp")
pic (2) := Pic.FileNew ("ninja2.bmp")
var chars : array char of boolean
loop
Input.KeyDown (chars)
if chars (KEY_RIGHT_ARROW) then
x := x + 2
Pic.Draw (pic(1), x, y, picMerge)
View.Update
Pic.Draw (pic(2), x, y, picMerge)
View.Update
end if
delay (10)
cls
end loop |
thx
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
jamonathin
|
Posted: Wed May 25, 2005 1:34 pm Post subject: Re: Animating a character in a game |
|
|
strike_hawk89 wrote: i need to make a character for a game animate properly while walking. i know i posted something like this b4 but no one gave me a clear answer on how to solve the problem. here is the code i am using now. right now, i does not work properly. i want it so that when u press and hold the arrow key to move the character, the character moves his right leg, and then his left leg, so he looks like he is walking. code: | var x, y : int
x := 100
y := 100
var pic : array 1..2 of int
pic (1) := Pic.FileNew ("ninja1.bmp")
pic (2) := Pic.FileNew ("ninja2.bmp")
var chars : array char of boolean
loop
Input.KeyDown (chars)
if chars (KEY_RIGHT_ARROW) then
x := x + 2
Pic.Draw (pic(1), x, y, picMerge)
View.Update
delay(10) %HERE <-----------------
Pic.Draw (pic(2), x, y, picMerge)
View.Update
end if
delay (10)
cls
end loop |
thx
Try putting a delay inbetween the pictures.
|
|
|
|
|
|
strike_hawk89
|
Posted: Wed May 25, 2005 5:48 pm Post subject: (No subject) |
|
|
i tried doing that many times but with no success. when i put that in it slows down the character completely and the animation of the character walking stays the same
|
|
|
|
|
|
Token
|
Posted: Wed May 25, 2005 8:49 pm Post subject: (No subject) |
|
|
code: | var x, y, rl : int := 1
x := 100
y := 100
var pic : array 1 .. 2 of int
pic (1) := Pic.FileNew ("ninja1.bmp")
pic (2) := Pic.FileNew ("ninja2.bmp")
var chars : array char of boolean
loop
Input.KeyDown (chars)
if chars (KEY_RIGHT_ARROW) then
x := x + 2
if rl = 1 then
Pic.Draw (pic (1), x, y, picMerge)
rl := 2
elsif rl = 2 then
Pic.Draw (pic (2), x, y, picMerge)
rl := 1
end if
View.Update
end if
delay (10)
cls
end loop
|
here you go, what you needed to do is alternate between the drawings. hope it works, and if it dosent, on ur next post include the drawings
|
|
|
|
|
|
McKenzie
|
Posted: Wed May 25, 2005 8:51 pm Post subject: (No subject) |
|
|
code: | var x, y : int
x := 100
y := 100
var pic : array 1..2 of int
pic (1) := Pic.FileNew ("ninja1.bmp")
pic (2) := Pic.FileNew ("ninja2.bmp")
var chars : array char of boolean
var frame:int :=1
loop
Input.KeyDown (chars)
if chars (KEY_RIGHT_ARROW) then
x := x + 2
end if
frame := frame mod 2 + 1
Pic.Draw (pic(frame), x, y, picMerge)
View.Update
cls
end loop |
keep track of what frame you are in in a seperate variable.
|
|
|
|
|
|
strike_hawk89
|
Posted: Thu May 26, 2005 9:26 am Post subject: (No subject) |
|
|
Quote: here you go, what you needed to do is alternate between the drawings. hope it works, and if it dosent, on ur next post include the drawings
doesnt quite work. u cannot see the character walking like i wanted it to. the last poster's frame thing worked to keep the character in the last position, but still the pictures didnt work. here are the pictures.
Description: |
|
Filesize: |
9.33 KB |
Viewed: |
1514 Time(s) |
|
Description: |
|
Filesize: |
9.33 KB |
Viewed: |
1511 Time(s) |
|
|
|
|
|
|
|
Token
|
Posted: Thu May 26, 2005 2:06 pm Post subject: (No subject) |
|
|
code: | var x, y, rl : int := 1
x := 100
y := 100
var pic : array 1 .. 2 of int
pic (1) := Pic.FileNew ("ninja1.bmp")
pic (2) := Pic.FileNew ("ninja2.bmp")
var chars : array char of boolean
loop
Input.KeyDown (chars)
if chars (KEY_RIGHT_ARROW) then
x := x - 2
cls
if rl = 1 then
Pic.Draw (pic (1), x, y, picMerge)
rl := 2
elsif rl = 2 then
Pic.Draw (pic (2), x, y, picMerge)
rl := 1
end if
View.Update
delay (300)
end if
end loop
|
Tadum:D
|
|
|
|
|
|
strike_hawk89
|
Posted: Thu May 26, 2005 5:25 pm Post subject: (No subject) |
|
|
thank you thank you thank you thank you....... ur a life saver man!
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
|
|