B3D code to BlitzMax
BlitzMax Forums/BlitzMax Beginners Area/B3D code to BlitzMax
| ||
Hi!Im new at BlitzMax,and i dont understand how to port this simple B3D code to BlitzMax.Please help me to port it. --------------------------------------------------------------------- Graphics 640,480,16,2 SetBuffer BackBuffer() Global gfx_image = LoadImage("media\player.png") Type player Field x#,y# Field image End Type Function create_player(x#,y#) p.player = New player p\x# = x# p\y# = y# p\image = gfx_image End Function Function update_player() For p.player = Each player DrawImage p\image,p\x#,p\y# Next End Function create_player(x#,y#) Repeat update_player() Flip Cls Forever |
| ||
Graphics 640,480,16 Global gfx_image:TImage = LoadImage("media\player.png") Type player Field x#,y# Field image:TImage Global playerList:TList Function Create(x#,y#) If playerList=Null Then playerList=CreateList() p:player = New player ListAddLast playerList,p p.x# = x# p.y# = y# p.image = gfx_image End Function Function Update() If playerList Then For p:player = EachIn playerList DrawImage p.image,p.x#,p.y# Next EndIf End Function End Type player.Create(x#,y#) Repeat player.Update Flip Cls Until KeyHit(KEY_ESCAPE) Or AppTerminate() I'll let you look up the differences and the new commands I've introduced in the docs yourself. Basically, note the changes from '\' to '.' and '.' to ':', the introduction of TLists (as you now have to manage your own Type lists) and the moving of all player related Functions into the Type definition itself. You may also want to look up Methods for future use. I've changed the Forever to a conditional test, as it's not good having an infinite loop with no way of breaking out of it (the close button doesn't work in BlitzMax unless you program it into your code - AppTerminate). There's also no scaled window mode, so the above will run fullscreen. For windowed, change the bitdepth to 0. Hope the above helps. |
| ||
Thanks a lot |
| ||
its a rather tricky learning curve remembering what goes where but when ya been doing it a while it becomes second nature :) |