Mars Explorer Ported From GLBasic To Monkey X

Monkey Archive Forums/Monkey Projects/Mars Explorer Ported From GLBasic To Monkey X

GarBenjamin(Posted 2015) [#1]
Hey folks, just wanted to let you know I completed another piece of my experiment in testing different 2D game development frameworks.

Tonight I finished porting my little test game from GLBasic to Monkey X.



For the game itself I chose Moon Patrol as the inspiration. The name of the game is Mars Explorer. The game only has two stages because that is all I needed for the test to cover the various systems needed in 2d game dev.

The Mars Explorer Dev Log is available on my website and upon release the HTML5 version of the game will be available for play at the bottom of that page.

This project took 23 hours and I will probably spend one more hour just to clean up the code a bit here and there before I release the source this weekend.


therevills(Posted 2015) [#2]
Cool! Just wondering how you did your collisions with the ground and the vehicle, as it looks pretty well done.


Playniax(Posted 2015) [#3]
Nice!


GarBenjamin(Posted 2015) [#4]
Thanks!

The stages are tile maps (doesn't really matter but in this case the maps were created in Tiled and loaded in via the bit.tiled module).
There are 4 terrain tiles the vehicle can drive across.

To make it so the wheels traced the terrain I just created a simple data structure to define the y offsets from the top of the tile rectangles to the top of the actual terrain image contained within the tiles.

Actually, the source code is fairly well commented, so let me just paste that into here:

' This is just a simple data structure that allows the wheels to trace the terrain.
' There are several ways to achieve this result from throwing out ray casts and so forth
' and I always go with the simple method because... well... simpler is better.
' The data structure defines the offset from the top of tile rectangle to the top of the terrain image.
' Tiles are 32 pixels wide.
' LeftHalf defines the offset of the left side.
' RightHalf defines the offset of the right side.
' To make the player vehicle trace the terrain as it moves, I simply call a method (GetTileTopOffset below)
' passing in the pixel x position of each wheel (one at a time).
' The GetTileTopOffset method takes the current scrolling x offset into account, looks up
' the top (offset) of the tile at this position and returns it.
' That bit of information is all that is needed to position the wheel correctly on the ground.
' The average of the wheel offsets is taken to provide the amount of lift to the vehicle frame.
' This produces a nice effect where the wheels trace the ground and the frame adjusts accordingly simulating
' the suspension system of the vehicle reacting to the uneven terrain.
Class TileTopClass
	Public
	Field LeftHalf:Int
	Field RightHalf:Int
End Class


I will be releasing the full Monkey X source code as soon as I get my website updated.


GarBenjamin(Posted 2015) [#5]
Just wanted to update this to say last night I released the Mars Explorer Source Code. Hopefully it will be useful to someone.