By the way. I'm trying some Platform Code I learned a long time ago from a guy called Alan Mcdonald. This is going back 5 years. Don't know if he is still around.
I can't find the thread where he helped me and am trying from memory to recode it for max.
Heres how far I've got so far.
As you can see I'm trying to get platform collision working.
I can't find the thread where he helped me and am trying from memory to recode it for max.
Heres how far I've got so far.
SuperStrict Graphics 800 , 600 Global Tiles:TImage = LoadAnimImage("ice_floortiles.png",32,32,0,8) Global Player:TImage = LoadImage("player.png") Const MAPWIDTH:Int = 800/32 Const MAPHEIGHT:Int = 600/32 Global Map:Int[MAPWIDTH , MAPHEIGHT] Global PlayerX:Int Global PlayerY:Int Global Direction:String = "Standing" ReadLevelData() While Not KeyHit(KEY_ESCAPE) Cls DrawMap() DrawPlayer() MovePLayer() CheckIfPlayerCollideWithTile() Flip Wend Function DrawPlayer() For Local x:Int = 0 Until MAPWIDTH For Local y:Int = 0 Until MAPHEIGHT Select Map[x,y] Case 2 'DrawImage Player , PlayerX+x*32 ,PlayerY + y*32 , 0 DrawImage Player ,x*32 ,y*32 , 0 Local TempPosX:Int = x/32 DrawText "tempPosX = " + TempPosX , 0 , 20 End Select Next Next End Function Function MovePLayer() If KeyDown(KEY_LEFT) If Not KeyDown(KEY_RIGHT) Direction = "Moving_Left" PlayerX:-2 EndIf ElseIf KeyDown(KEY_RIGHT) If Not KeyDown(KEY_LEFT) Direction = "Moving_Right" PlayerX:+2 EndIf End If End Function Function CheckIfPlayerCollideWithTile() Local TempX:Int = PlayerX/32 Local TempY:Int = PlayerY/32 If Direction = "Moving_Right" ' If TempX>0 If Map[TempX, TempY] = 1 PlayerX:-2 End If EndIf ' EndIf DrawText "TempX = "+TempX,0,0 End Function Function DrawMap() For Local x:Int = 0 Until MAPWIDTH For Local y:Int = 0 Until MAPHEIGHT Select Map[x,y] Case 1 DrawImage Tiles , x*32 , y*32 , 0 End Select Next Next End Function Function ReadLevelData() For Local y:Int = 0 Until MAPHEIGHT For Local x:Int = 0 Until MAPWIDTH Local data:Int ReadData data Map[x,y] = data Next Next End Function DefData 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 DefData 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,1,1,1,1,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1 DefData 1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1 DefData 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,1,1,1,1,1,0,0,0,0,0,0,1,1,1,1,1,0,0,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,1,1,1,1,0,0,1,1,1,1,0,0,0,0,1,1,1,1,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,1 DefData 1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 DefData 1,0,0,0,0,0,0,0,0,2,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1 DefData 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
As you can see I'm trying to get platform collision working.