Hi there! I’m currently working on an asteroids game for my Graphics and animation class. In this class we use openGL to draw and animate shapes around the screen.
The game will have the following:
- A spaceship that wraps around the screen. For example: if half of the ship goes beyond the right border of the screen, the not visible half should appear on the left side instead.
- Multiple asteroids that move at different velocities and rotate at a different speed. These will also wrap around the screen.
- The spaceship will move using the Up and Down arrow keys, and it will rotate by using the Right and Left arrow keys.
- The spaceship will shoot a laser when pressing Spacebar, which will have its origin at the tip of the spaceship. The laser will also wrap around the screen and have a pre-set lifetime.
Drawing the elements on screen
I will be using vectors to store the position and color for each vertices that will define the elements I will use (spaceship, asteroid, laser). I have set the origin to be at the center of the elements so that it will be easier to move and rotate them on the screen when applying the corresponding transformations.
Classes and Game Logic
I believe the best way to approach this project is to create a class for every element. Each one of them will contain the parameters needed to animate while the game is running. In total there will be 4 classes, including the Game class, which will bring together the other three.
I will create methods in each of the classes that will provide access to their components, and let the game class take care of drawing and moving the elements. At the same time, the Game class will contain methods that will take care of the “wrapping” effect for each one of the elements!
In the next posts, I will be laying down how each of the elements were added into the game’s “world” and the methods used to apply the correct displacement of them on the screen! 🙂
One thought on “Simple Asteroids game in OpenGL: Scheme”
God help me, I put aside a whole afotenron to figure this out.