test with this:
and this:
"tank.bmx"
use this images:
"grass.png"

"walltiles.png"

"tankimg.png
SuperStrict Framework BRL.D3D7Max2D Import BRL.Random Import BRL.PNGLoader Import BRL.BMPLoader Import BRL.Standardio ' modules which may be required: ' Import BRL.TGALoader ' Import BRL.JPGLoader SetGraphicsDriver D3D7Max2DDriver() Include "tank.bmx" Include "maze.bmx" Graphics 800,600,32 'use any mode. limited to graphics card SetBlend alphablend Local image:timage = LoadAnimImage("tankimg.png",32,32,0,2) Local tank:ttank = New ttank Local enemy:Ttank Local enemyList:TList = New TList MidHandleImage(image) SeedRnd MilliSecs() 'used to generate a non repetitive tile map Local map:tmap = tmap.Create(35,35) 'mapsize in tiles create(width ,height) Local x:Float,y:Float 'map.SetMapOffset(0,0) 'use this to repositon map. map default center view Local ms:Int = 0 Local start:Int Local xs:Float = 0,ys:Float = 0 map.Random(xs,ys) ' find a location in map unocupied by wall tiles tank.Create(image,xs,ys,0,2) For Local c:Int = 0 To 10 enemy = New ttank map.random(xs,ys) enemy.Create(image,xs,ys,0,2) enemyList.addlast(enemy) Next Cls DrawText("press a key to continue", 400,380) Flip() WaitKey() Global fps:Int=0 Global count:Int = 0 Global out:Int= 0 Repeat start = MilliSecs() map.windowclear() ms = MilliSecs() - start If KeyDown(key_Down ) Then tank.setspeed(-2) ElseIf KeyDown(key_UP) Then tank.setspeed(2) Else tank.setspeed(0) EndIf If KeyDown(key_left) tank.TurnLeft() If KeyDown(key_right) tank.TurnRight() If map.RectCollided(tank.x+tank.dx,Tank.y+tank.dy,tank.sw1,tank.sh1,tank.sw2,tank.sh2) tank.setspeed(0) Else tank.move() EndIf map.centerto(tank.x,tank.y,tank.dx,tank.dy,tank.speed ) map.display() For enemy = EachIn enemyList map.DrawImageToMap(tank.image,enemy.x,enemy.y,tank.angle)'purposely wrong enemy.angle Next map.DrawImageToMap(tank.image,tank.x,tank.y,tank.angle) ms = MilliSecs() - start SetColor 255,0,0 SetRotation(0) DrawText "fps = "+fps,10,10 If map.clearscreen DrawText "map clear screen with cls",10,25 Else DrawText "no screen clear",10,25 EndIf SetColor 255,255,255 Flip() fpscounter() Until KeyDown(key_escape) Function fpscounter() If out<MilliSecs() fps = count out = MilliSecs()+1000 count = 0 EndIf count:+1 End Function
and this:
"tank.bmx"
' bitmaps Const TURNSPEED :Float = 2.0 Global BITMAPWIDTH :Float = 32.0 Global BITMAPHEIGHT :Float = 32.0 Global HALFBITMAPWIDTH :Float = BITMAPWIDTH/2.0 Global HALFBITMAPHEIGHT :Float = BITMAPHEIGHT/2.0 Const TANK_BOTTOMSIDE :Float = 10.0 Const TANK_RIGHTSIDE :Float = 12.0 Type Ttank Field lta :Float,.. rta :Float,.. lba :Float,.. rba :Float Field sw1 :Float,.. sh1 :Float,.. sw2 :Float,.. sh2 :Float Field x :Float,.. y :Float Field dx :Float,.. dy :Float Field speed :Float Field angle :Float Field TSpeed :Float Field radius :Float Field image :timage Method Create(image:timage,x:Float,y:Float,angle:Float,speed:Float,AngleSpeed:Float = TURNSPEED) Self.x = x Self.y = y Self.speed = speed Self.angle = angle Self.TSpeed = AngleSpeed Self.dx = Cos(angle)*speed Self.dy = Sin(angle)*speed Self.image = image Self.rba = ATan2(TANK_BOTTOMSIDE,TANK_RIGHTSIDE) ' find angle to bottom right corner of tank from center of tank Self.lba = 180.0 - Self.rba ' find bottom left angle of tank Self.lta = 180.0 + Self.rba ' find top left angle of tank Self.rta = 360.0 - Self.rba ' find top right angle of tank Self.radius = Sqr(TANK_RIGHTSIDE*TANK_RIGHTSIDE+TANK_BOTTOMSIDE*TANK_BOTTOMSIDE) 'find radius to corner Self.FindCorners() End Method Method setspeed(sp:Float) If speed = sp Return speed = sp dx = Cos(Self.angle)*speed dy = Sin(Self.angle)*speed findcorners() End Method Method setturnspeed(sp:Float=TURNSPEED) Tspeed = sp End Method Method move() Self.x:+ Self.dx Self.y:+ Self.dy End Method Method GetNextPos(x:Float Var,y:Float Var) x = Self.x + Self.dx y = Self.y + Self.dy End Method Method FindCorners() If speed > 0 Then 'locate front 2 corners of tank sw1 = Cos(angle+rta)*radius 'x front top corner of tank sh1 = Sin(angle+rta)*radius 'y front top corner of tank sw2 = Cos(angle+rba)*radius 'x of front bottom corner of tank sh2 = Sin(angle+rba)*radius 'y of front bottom corner of tank ElseIf speed<0 Then 'locate rear 2 corners of tank sw1 = Cos(angle+lta)*radius 'x of rear top corner of tank sh1 = Sin(angle+lta)*radius 'y of rear top corner of tank sw2 = Cos(angle+lba)*radius 'x of rear bottom corner of tank sh2 = Sin(angle+lba)*radius 'y of rear bottom corner of tank EndIf End Method Method TurnRight() Self.angle = (Self.angle + Self.TSpeed) Mod 360.0 Self.dx = Cos(Self.angle)*Self.speed Self.dy = Sin(Self.angle)*Self.speed Self.FindCorners() End Method Method TurnLeft() Self.angle = (Self.angle - Self.TSpeed) Mod 360.0 Self.dx = Cos(Self.angle)*speed Self.dy = Sin(Self.angle)*speed Self.FindCorners() End Method End Type
use this images:
"grass.png"

"walltiles.png"

"tankimg.png