Monkey2Tutorials
Some example code for the Monkey2 programming language
Spacecraft Tutorial
Part 1:
- Create a SpaceCraft class that extends Window
- Prepare some methods to draw and update the screen
- Make a GameObject Class which will be the base class for all our game objects
- Implement a simple Component class for giving game objects functionality
- Create a Player class with a control Component and get it drawing to the screen
Part 2:
- Enable the GameObject to have a Body and Space and set up an InitPhysics method
- Add a chipmunk Space in the SpaceCraft class.
- Write some maintainence functions to handle adding and removing from the Space
- Use a Chipmunk bounding box query to draw all objects on screen (in this case just the player).
Part 3:
- Build on the Controls component to define the player controls and get it moving about
- Use a chipmunk query to update objects that are on screen
Part 4 - Implement json to load in a set of map tiles
Part 5 - Create a terrain class that will manage adding and removing tiles from the game world
- Create a Tilemap class and set some initial fields that we'll need
- Create some methods for converting screen coordinates into node coordinates and vice versa
- Set the origin vec in the Spacraft Class to the centre of the screen
- Test the coordinates for the tilemap are working ok.
Part 6 - Create a tile layer class and draw tiles to the screen according to adjacent tiles.
- Create a TileLayer class and create some fields and methods that we'll need
- Add extra methods and fields to the TileMap class that we need
- Draw nodes to the screen with just a single block tile for each node to start with and test.
- Add a way to erase tiles
Part 7 - Make the tiles take into account adjacent nodes to draw the appropriate tiles in the world
- Alter the AssignTiles method to create four tiles for each node
- Create AssignTile to assign the correct tile image according to surrounding nodes
- Update the erase method to erase all tiles as necessary.
Part 8 - Use TimelineFX to shoot a laser beam
- Import TimelineFX and load in the effects library
- Add a class to create the different weapons and utilities the ship can fire/use
- Extend that class and make a laser beam class
- Add controls to the player to fire the laser on left mouse (update the map drawing controls to something else as well)
Part 9 - Use TimelineFX to shoot a laser beam
- Import TimelineFX and load in the effects library
- Add a class to create the different weapons and utilities the ship can fire/use
- Extend that class and make a laser beam class
- Add controls to the player to fire the laser on left mouse (update the map drawing controls to something else as well)
Part 10 - Use Raycasting in Chipmunk to have the laser hit the maptiles
- Start with some bug fixing with the virtual screen resolution
- Create a segment query in chipmunk to handle the raycasting
- Add a sparks particle effect at the point of impact
- Add a particle effect for the player and a thruster effect too
- Set the texture filter to linear for more crisper graphics
Part 11 - Destroy the map tiles with the laser, and use a matrix to position points on the player
- Use a matrix to calulate points on the player as it rotates to offset the laser and thrusters
- Make the maptiles destructable by giving them properties and the ability to take damage
- Add a glow effect for map tiles that are being mined
- Add an explosion effect for when a tile is destroyed
Part 12 - Add rocket objects that appear after mining a map tile
- Create a new RockObject class that extends Gameobject
- Use Chipmunk to handle the physics
- Give them an expirey so that they dissapear after a while
Part 13 - Create a tractor beam that can suck up the rocks
- Create the TractorBeam class and set up the activate/deactive methods
- Edit the player class to accomodate the tractor beam and add controls so that the it can be fired with right mouse
- Create a chipmunk segment query to handle the tractor beam hitting the map tiles
- Create a shape query to handle the rocks touching the beam and getting sucked up
Part 14 - Make the player able to absorb the rocks with an effect
-
Add a Chipmunk sensor to the player
-
Set up a collision handler for when the sensor hits a rock
-
Add an effect for when a rock is hit and use a lambda to position it as the player moves about