walking animation
Author |
Message |
kousha41564
|
Posted: Fri Jan 02, 2009 4:02 pm Post subject: walking animation |
|
|
alright watsup guys. i am making a game for fun , and right now i am just working on the walking animations and the colisions. this is a pokemon red blue style thing. you know where you have the bird view thing going on ?
so here is my code, i made a dude, and made his shoes in relation to the position of the dude (cirlce) , now i wud like the feet to move as if he is walking. cant figure it out thogh. any help is apreciated.
code: |
View.Set ("graphics:800,600,offscreenonly")
var x1,y1,x2,y2,a,b,xx1,yy1, yy2, xx2:int:=0
var sd2,sd1,sdd1,sdd2 : int :=0 %shoe dircection
var c,csq:real:=0
var key : array char of boolean
x1:=300
y1:=300
x2:=150
y2:=150
sd1 :=15
sd2 :=15 % shoe irection
sdd1 :=10
sdd2 := 10
loop
drawoval(x1,y1,22,22,7)
drawoval(x2,y2,50,50,1)
a:=x2-x1
b:=y2-y1
csq:=a*a+b*b
c:=sqrt(csq)
if 50+22>c then
put "collide"
end if
Input.KeyDown (key)
if key (KEY_UP_ARROW) and y1 < maxy then %makes sure the character won't go past the top of the screen
xx1 := x1 +10
yy1 := y1 +23
xx2 := x1 -10
yy2 := y1 +23
y1 +=1
sd1 :=10
sd2 :=10 % all sd's change direction of shoes
sdd1 :=15
sdd2 := 15
end if
if key (KEY_DOWN_ARROW) and y1 > 0 then
xx1 := x1 + 10
yy1 := y1 - 23
xx2 := x1 - 10
yy2 := y1 -23
y1 -=1
sd1 :=10
sd2 :=10 % all sd's change direction of shoes
sdd1 :=15
sdd2 := 15
end if
if key (KEY_LEFT_ARROW) and x1 > 0 then
xx1 := x1 -22
yy1 := y1 -8
xx2 := x1 -22
yy2 := y1 +12
x1 -= 1
sd1 :=15
sd2 :=15
sdd1 :=10 % sd's change direction of shoes
sdd2 := 10
end if
if key (KEY_RIGHT_ARROW) and x1 < maxx then
xx1 := x1 + 22
xx2:= x1 + 22 % SHOE POSITION IN RELATION TO CIRCLE POSITION
yy1:= y1 + 5
yy2 := y1 - 15
x1 +=1
sd1 :=15
sd2 :=15
sdd1 :=10 % sd's change direction of shoes
sdd2 := 10
end if
drawfilloval (xx2,yy2, sd1,sdd1,2) %shoes
drawfilloval (xx1,yy1, sd2,sdd2,2) %shoes
drawfilloval(x1,y1,22,22,7) %body
delay (10)
View.Update
cls
end loop
|
|
|
|
|
|
![](images/spacer.gif) |
Sponsor Sponsor
![Sponsor Sponsor](templates/subSilver/images/ranks/stars_rank5.gif)
|
|
![](images/spacer.gif) |
Homer_simpson
![](http://compsci.ca/v3/uploads/user_avatars/18138546704b4d2a3b2e50e.gif)
|
Posted: Fri Jan 02, 2009 7:41 pm Post subject: Re: walking animation |
|
|
replace:
drawfilloval (xx2,yy2, sd1,sdd1,2) %shoes
drawfilloval (xx1,yy1, sd2,sdd2,2) %shoes
with:
drawfilloval (xx2 + round (sind (x1 * 10)) * 3, yy2 + round (sind (y1 * 10)) * 3, sd1, sdd1, 2) %shoes
drawfilloval (xx1 + round (sind ((x1 + 18) * 10)) * 3, yy1+ round (sind ((y1 + 18) * 10)) * 3, sd2, sdd2, 2) %shoes |
|
|
|
|
![](images/spacer.gif) |
kousha41564
|
Posted: Fri Jan 02, 2009 7:47 pm Post subject: RE:walking animation |
|
|
dude aweosme THANK YOU. sorrry to be a burden but could you explain ? |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
|
|
|
![](images/spacer.gif) |
kousha41564
|
Posted: Fri Jan 02, 2009 9:12 pm Post subject: RE:walking animation |
|
|
alright alright alright, sorry i am such a dumb*** but , i will require a more indepth explenation as to what exactly is happening cuz i would love to use this code in future for other things. thank you |
|
|
|
|
![](images/spacer.gif) |
Tony
![](http://wiki.compsci.ca/images/f/f4/OniTony.gif)
|
|
|
|
![](images/spacer.gif) |
kousha41564
|
Posted: Fri Jan 02, 2009 10:34 pm Post subject: RE:walking animation |
|
|
Well, i will have a fun type trying to pass this as my own genius in front of otehr people lol thank you tony, helped allot |
|
|
|
|
![](images/spacer.gif) |
|
|