cube movement... smooth movements..

BlitzPlus Forums/BlitzPlus Beginners Area/cube movement... smooth movements..

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

The delay method is bad indeed. Here's a freshly hacked solution.. dunno if it could be improved, I don't care to bother actually .. it just works :P

Graphics 640,480

timer=CreateTimer(25)
repeatwalks=-1


Repeat
	WaitEvent()
	If KeyHit(200)
		repeatwalks=0
		direction=0 ; up
	EndIf
	If KeyHit(208)
		repeatwalks=0
		direction=1 ; down
	EndIf
	If KeyHit(203)
		repeatwalks=0
		direction=2 ; left
	EndIf
	If KeyHit(205)
		repeatwalks=0
		direction=3 ; right
	EndIf
	
	If EventID()=$4001
	
		If repeatwalks>=0
			repeatwalks=repeatwalks+1
			
			If repeatwalks<=5
				Select direction
					Case 0 y=y-1
					Case 1 y=y+1
					Case 2 x=x-1
					Case 3 x=x+1
				End Select
			Else
				repeatwalks=-1
			EndIf
		EndIf
		
		Cls
		
		For px=-8 To 8
			For py=-8 To 8
				Plot (x+px)*8,(y+py)*8
			Next
		Next
		Rect x*8,y*8,8,8,1
		

		f=f+1
		fx=Sin(f*3.0)*32
		fy=Cos(f*2.0)*32
		Rect 320+fx*8,240+fy*8,4,4,1
		
		Flip
	EndIf

Until KeyHit(1)
End