Creating The Ship

Click here to load the completed tutorial directly into the editor SWARM-07.DBA. If you want to step through and make the modifications, click here to load SWARM-06.DBA.

The stage is set, and ready to admit the hero of our game. To defend the Earth from those alien nasties, we shall create a ship. You will notice a new line has been added to the top of the program that reads GOSUB _create_player. If you go to the end of the program, you will find the subroutine responsible for creating the object that will become our ship.

Replace the line REM * HERE B * to read:
rem Load ship model
load object "obj\ship.x",50

This command will load the model file called SHIP.X located in the OBJ folder of your project. The second parameter of this command specifies that the model should be loaded into object number 50. If you now press F5, you will see our model.

Replace the line REM * HERE A * to read:
rem Setup camera
position camera 0,-40,-200
point camera 0,0,0

These two commands will place and point the camera further away from the ship. It is important our game has a good field of view to contain the action.

Replace the line REM * HERE C * to read:
rem Scale and position ship
scale object 50,75,50,75
position object 50,0.0,-90,-10

The first command scales object 50 by shrinking the X dimension to 75 percent, the Y dimension to 50 percent and the Z dimension to 75 percent. The second command places our ship at the base of the screen.

Replace the line REM * HERE D * to read:
rem Colour ship
color object 50,rgb(64,128,255)

Finally, we will colour our ship a lovely shade of blue. Colours are specified using the RGB command that accepts three parameters, namely red, green and blue. By specifying a value between 0 and 255, we can mix a degree of each colour to produce a final colour. To create light blue, we use 64 units of red, 128 units of green and 255 units of blue.

Click Here For The Next Tutorial Controlling The Ship.