Post by Darkjester on Nov 25, 2009 2:21:43 GMT -5
As i hardly ever use teh sprite engine, i am attempting to utilize it(i usually just use opengl which i can do this in)
i have 2 questions
1) how can i smooth the movement(im sure you will know what im trying to do once you run it
2)how to keep the sprites from going back to origin of screen(does that make sense)
its 2 20 am and im half asleep anyway -darkjester
i have 2 questions
1) how can i smooth the movement(im sure you will know what im trying to do once you run it
2)how to keep the sprites from going back to origin of screen(does that make sense)
its 2 20 am and im half asleep anyway -darkjester
struc stank
dim pos(1)
dim turret
dim tank
dim ang
dim old(2)
endstruc
dim Stank tank
tank.turret = Newsprite(LoadTex("data\turret.png"))
tank.tank = newsprite(Loadtex("data\tank.png"))
dim crosshair = newsprite(loadtex("data\crosshair.png"))
'turret setup for tank
bindsprite(tank.turret)
sprsetangle(-90)
sprsetsize(25,25)
sprsetpos(320,240)
'tankbase setup for tank
bindsprite(tank.tank)
sprsetangle(-90)
sprsetsize(50,30)
sprsetpos(320,240)
declare sub updatetank()
while true
if Scankeydown(vk_left) then
tank.old(2) = tank.ang
tank.ang = tank.ang - 1
updatetank()
endif
if Scankeydown(vk_right) then
tank.old(2) = tank.ang
tank.ang = tank.ang + 1
updatetank()
endif
If Scankeydown(vk_up) then
tank.old(0) = tank.pos(0) : tank.old(1) = tank.pos(1)
tank.pos(0) = tank.pos(0) + cosd (tank.ang) * 2
tank.pos(1) = tank.pos(1) + sind (tank.ang) * 2
updatetank()
endif
If Scankeydown(vk_down) then
tank.old(0) = tank.pos(0) : tank.old(1) = tank.pos(1)
tank.pos(0) = tank.pos(0) - cosd (tank.ang) * 2
tank.pos(1) = tank.pos(1) - sind (tank.ang) * 2
updatetank()
endif
wend
sub Updatetank()
bindsprite(tank.tank)
sprsetangle(tank.ang)
sprsetpos(tank.pos(0), tank.pos(1))
bindsprite(tank.turret)
sprsetangle(tank.ang)
sprsetpos(tank.pos(0), tank.pos(1))
endsub