Skip to content

JackyC415/openGL-2D-marioDash

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OpenGL-2D

Two dimensional action based game, marioDash, implemented by C++ with OpenGL libary framework.

Topic: A more detailed description of the project. This should include not only what the app does but also how certain features were implemented. Code snippets should be included, particularly to highlight Object-Oriented Programming features that make the code more readable, maintainable,and extendable.

Our 2D side scroller game, marioDash, is based on the classic game Mario. Instead reaching a goal post as in the original game, this game’s purpose is to attempt get as far as possible in the game while also killing as many enemies, Mega Men, as possible. There are features integrated into the game that make it playable and also enjoyable. The player is able to shoot laser balls at enemies. The Mega Men can also fire laser balls that can damage Mario. The player is capable of moving left and right across the map by using the “a” and “d” button. Jumping can also be done as well by manipulating the space bar key(Y is set to a certain position, so jumping has a fixed positioning). These functions were done using the keypress function. With the jump feature, the player could dodge the enemies fireball lasers. Jump has certain parameters, the if statement constraints and the jump variable, that do not allow it to be abused.

Furthermore, after eliminating enough enemies to run across the screen, the character is able to move to next map. This map switching illusion is done by resetting the player’s position to -0.9f, the leftmost part of the screen, and respawning the enemies to their original position, the map background texture is decided by the value of the variable “backgroundcheck”. This variable loops in a cycle from 0-2 allowing for a total of 3 backgrounds which switch every time the player reaches the rightmost part of the screen. This snippet will demonstrate how we implement the scrolling map functions.

Moreover, we have health bar on the top left corner of the screen. Theses health bars are created with an array that stores each heart in a index of the array. There are 4 indexes for a total of 10 lives.

When an enemy missile hits Mario, it will decrement one life variable which removes one of the 4 hearts, and when life reaches zero, the game ends by displaying “Game Over” on the interface. Both the player and the enemy's missiles have similar implementation with slight differences. They are both done using a vectors. Missile detection is done using a contains function which check if the position of the missile is within the hit range of Mario. A sample of this is shown below.

If a player’s missiles hits an enemy the enemy will be destroyed/erased and the kill count will increment by one. The kill count is used to keep track of the score. The level of the game gets increased after each map, the enemy's missile speed will be increased every time the background changes. This incrementation adds more difficulty to the game which creates a competitive atmosphere for the player. The player will have more difficulty dodging bullets as the maps cycle.

The most commonly used OOP feature implemented in this game are vectors; we used vectors to store both the enemy and the player’s missile, also the enemies object. We commented in many areas of our code for further description, therefore it should be comprehensible easily. Also, we used the concept of creating a struct/class to set different value for different object and to maintain code consistency.