heres a little something i whipped up quickly ( key word quickly ).
graphics = very cheesy
code = not perfect and could be better but its a start and shows a basic example
source and resources at : http://www.mediafire.com/download.php?dhnnd3xyimi
like i said not the best and could be better but it was done very quickly and atleast its a start.
i'm sure someone will be along and have a much better and cleaner example, but until then i hope this helps.
graphics = very cheesy
code = not perfect and could be better but its a start and shows a basic example
source and resources at : http://www.mediafire.com/download.php?dhnnd3xyimi
Strict Graphics 800,600 AutoMidHandle(1) 'gfx Global map:TImage = LoadImage("map.png") Global colmap:TImage = LoadImage("colmap.png") Global player:TImage = LoadAnimImage("player.png",64,64,0,3) 'var Global px=400,py=300,pf ,pr 'player x, player y, player frame, player rotation Global pmoveon=0 'check if player is moving Global pmovecount 'add a pause to the walk speed Global pspeed = 5 'how fast the player walks Global xoffset=400,yoffset=250 'offsets for drawing the map relative to player position Global LMapList:TList = New TList TLevelMap.CreateLevelMap(map,colmap) While Not KeyDown(key_Escape) Cls Keys() TLevelMap.Update() If pmoveon = 1 pmovecount:+1 If pmovecount = 20 Then pmovecount = 0 If pmovecount = 0 MoveAnim() EndIf Else pf = 0 EndIf SetRotation pr DrawImage player,px,py,pf SetRotation 0 Flip Wend End Function Keys() Local walkcheck = 0 If pmovecount = 0 pmoveon = 0 If KeyDown(key_Left) pr = 270 pmoveon = 1 walkcheck = TLevelMap.CheckCollision((px-pspeed)-2,0) If walkcheck = 1 px:-pspeed xoffset:+pspeed Else px:+(pspeed+4) xoffset:-(pspeed+4) EndIf EndIf If KeyDown(key_Right) pr = 90 pmoveon = 1 walkcheck = TLevelMap.CheckCollision((px+pspeed)+2,0) If walkcheck = 1 px:+pspeed xoffset:-pspeed Else px:-(pspeed+4) xoffset:+(pspeed+4) EndIf EndIf If KeyDown(key_Up) pr = 0 pmoveon = 1 walkcheck = TLevelMap.CheckCollision(0,(py-pspeed)-2) If walkcheck = 1 py:-pspeed yoffset:+pspeed Else py:+(pspeed+4) yoffset:-(pspeed+4) EndIf EndIf If KeyDown(key_down) pr = 180 pmoveon = 1 walkcheck = TLevelMap.CheckCollision(0,(py+pspeed)+2) If walkcheck = 1 py:+pspeed yoffset:-pspeed Else py:-(pspeed+4) yoffset:+(pspeed+4) EndIf EndIf EndIf EndFunction Function MoveAnim() pf:+1 If pf>2 Then pf = 1 EndFunction Type TLevelMap Field lmap:TImage Field cmap:TImage Function CreateLevelMap:TLevelMap(map:Timage,col:Timage) Local m:TLevelMap = New TlevelMap m.lmap = map m.cmap = col LMapList.AddLast m EndFunction Function CheckCollision(xin,yin) For Local m:TLevelMap = EachIn LMapList If ImagesCollide2(player,px+xin,py+yin,pf,pr,1,1, m.cmap,xoffset+xin,yoffset+yin,0,0,1,1) Return 0 Else Return 1 EndIf Next EndFunction Method Draw() DrawImage Self.lmap,0+xoffset,0+yoffset EndMethod Function Update() For Local m:TLevelMap = EachIn LMapList m.Draw() Next EndFunction EndType
like i said not the best and could be better but it was done very quickly and atleast its a start.
i'm sure someone will be along and have a much better and cleaner example, but until then i hope this helps.