hi folks,
i am writing a 2d top down game and am having trouble rotation my main sprite. i know most people make, say 36 frames with the sprite rotaed by 10 degreees each time, then they just play the frame closest to the sprites orientation, but, the sprite i have made is a man, and has 20 frames for walking. So the only way i could do this is to make a frame for each walk step at each rotation, and this would give me 36 * 20 frames!
Whenever i the rotateImage functon, it kills the framerate. Is there a fast, clean way to do this? I have posted the code below for clarity:
Global player
Global rootx
Global rooty
Global frame
Global rotate
Graphics 600,800,0
rootx = 400
rooty = 300
rotate = 0
While KeyDown(1) = False
If KeyDown(17) = True
frame = frame + 1
rooty = rooty + 7
If frame > 19 Then
frame = 0
EndIf
Else If KeyDown(31) = True Then
frame = frame - 1
rooty = rooty - 7
If frame < 0 Then
frame = 19
EndIf
Else
frame = 0
EndIf
SetBuffer BackBuffer()
Cls
draw_player()
Flip
Wend
End
Function draw_player()
player = LoadAnimImage("basicWalk.bmp",100,80,0,20)
MaskImage player,0,255,0
RotateImage player,rotate
DrawImage player,rootx,rooty,frame
End Function
i know there is no code in there for incrementing 'rotate' in accordance with the key's pressed, but the rest should work.
Also, in VB, there is a max() function. IE: you put in
max(a,b)
and it will retur the larger value. What is the equivelent code in blitz as i cant seem to find one. I know it would be easy to write a function to do it, but i was wondering if there is a built-in command. Thanks for any help folks.
~V~
i am writing a 2d top down game and am having trouble rotation my main sprite. i know most people make, say 36 frames with the sprite rotaed by 10 degreees each time, then they just play the frame closest to the sprites orientation, but, the sprite i have made is a man, and has 20 frames for walking. So the only way i could do this is to make a frame for each walk step at each rotation, and this would give me 36 * 20 frames!
Whenever i the rotateImage functon, it kills the framerate. Is there a fast, clean way to do this? I have posted the code below for clarity:
Global player
Global rootx
Global rooty
Global frame
Global rotate
Graphics 600,800,0
rootx = 400
rooty = 300
rotate = 0
While KeyDown(1) = False
If KeyDown(17) = True
frame = frame + 1
rooty = rooty + 7
If frame > 19 Then
frame = 0
EndIf
Else If KeyDown(31) = True Then
frame = frame - 1
rooty = rooty - 7
If frame < 0 Then
frame = 19
EndIf
Else
frame = 0
EndIf
SetBuffer BackBuffer()
Cls
draw_player()
Flip
Wend
End
Function draw_player()
player = LoadAnimImage("basicWalk.bmp",100,80,0,20)
MaskImage player,0,255,0
RotateImage player,rotate
DrawImage player,rootx,rooty,frame
End Function
i know there is no code in there for incrementing 'rotate' in accordance with the key's pressed, but the rest should work.
Also, in VB, there is a max() function. IE: you put in
max(a,b)
and it will retur the larger value. What is the equivelent code in blitz as i cant seem to find one. I know it would be easy to write a function to do it, but i was wondering if there is a built-in command. Thanks for any help folks.
~V~