|
Show Index |
|---|
This page demonstrates the code necessary to create an Asteroids clone. Some of it's features include:
Start with setting up graphics:
Graphics 800,600, 0, 1 ;2D graphics at a resolution of 800x600 Text 400, 300, "Loading...", 1 ;Write a temp message (could display an image here too)
Define Types:
;Define Types ;Use Types to store ship, asteroid, bullet, and particle information Type ShipTYPE ;Set up the Ship type Field ID ;Type of ship (1=Player, 2=Slow UFO, 3=Fast UFO) Field X# ;X position Field Y# ;Y position Field rotation ;Current rotation of ship Field XVelocity# ;Ships X velocity Field YVelocity# ;Ships Y velocity End Type Type BulletTYPE ;Set up the Bullet type Field ID ;Type of bullet (1=player's, 2=UFO's) Field X# ;X position Field Y# ;Y position Field XVector# ;X, Y vectors of the bullets rotation, both are used to Field YVector# ; reduce the math required when updating the bullets position Field life ;Counter to keep track of bullets existence End Type Type AsteroidTYPE ;Set up the Asteroid type Field ID ;Type of asteroid (1=Big, 2=Medium, 3=Small) Field X# ;X position Field Y# ;Y position Field rotation ;Current rotation of asteroid Field velocity# ;Asteroid velocity End Type Type ParticleTYPE ;Set up the Particle type Field X# ;X position Field Y# ;Y position Field XVector# ;X, Y vectors of the particles rotation, both are used to Field YVector# ; reduce the math required when updating the particles position Field life ;Counter to keep track of the particles existence End Type
Unfinished...
And here is the entire code pieced together so that you can copy&paste it
and immediately run it to see how it works.
Unfortunately, it doesn't all fit into one text box, so you'll have to add the code in the
2nd text box to the first.
|
|
| If you've reached this page and there's no index on the left, Click here to show the Index Page | |