This is a 2D bike racing game developed using SDL (Simple DirectMedia Layer) in C++. The game features a bike that can jump over obstacles and navigate through a scrolling background.
The project consists of several key files:
main.cpp
: The entry point of the application.constants.h
: Defines various constants used throughout the game.coardinate.h
: Contains classes for handling coordinates and game objects.collision.h
: Implements collision detection logic.function.h
: Defines utility functions likeapply_surface
for rendering.menu.h
: Implements the game's menu system.process.h
: Contains the main game loop and mechanics.variable.h
: Declares global variables used across the game.init.h
: Contains initialization code and resource loading functions.bike race.cbp
: CodeBlocks project file.bike race.depend
: Dependency file for the project.bike race.layout
: CodeBlocks layout file.
The game relies on the following libraries:
- SDL (Simple DirectMedia Layer)
- SDL_image
- SDL_ttf
Ensure these libraries are installed on your system before attempting to build the project.
This project uses CodeBlocks as its IDE. To build the project:
- Open the
bike race.cbp
file in CodeBlocks. - Ensure all necessary libraries (SDL, SDL_image, SDL_ttf) are properly linked.
- Build the project using the CodeBlocks build command.
- The game initializes SDL and its subsystems (Video, Event Handling, File I/O, and Threading).
- The video mode is set to 800x600 pixels with 32-bit color depth.
- TTF (TrueType Font) is initialized for text rendering.
- Various image resources are loaded, including backgrounds, bike sprite, and obstacles.
- Font files are loaded for text rendering.
- The game window is titled "RISING SUN BIKE RACING GAME".
- The bike starts at x-coordinate 150 and can move up to x-coordinate 250.
- The game includes a scrolling background and two types of obstacles (walls).
- The bike can jump using the spacebar or up arrow key.
- Collision detection is implemented for obstacles.
- A timer displays the elapsed time during gameplay, with a time limit of 1:30 minutes.
- The game features a menu system with options to play, view instructions, or quit.
- Right Arrow: Increase speed
- Left Arrow: Decrease speed
- Spacebar / Up Arrow: Jump
- Escape: Exit the game
The game requires the following resource files in the image
folder:
bg1.png
,bg2.png
: Background imagesbike.PNG
: Bike spritewall.JPG
,wall1.JPG
: Obstacle imagesmenu.jpg
,menu_play.jpg
,menu_instruction.jpg
,menu_exit.jpg
: Menu images
Additionally, a times.ttf
font file is required for text rendering.
init.h
: Handles SDL initialization, window creation, and resource loading.function.h
: Defines theapply_surface
function for rendering images to the screen.menu.h
: Implements the start menu with options for play, instructions, and quit.process.h
: Contains thebike_process
class, which handles the main game loop, including bike movement, jumping mechanics, and obstacle management.variable.h
: Declares global variables for surfaces, fonts, game states, and other necessary elements.
- The bike's vertical position is controlled by a jumping mechanism.
- The game speed increases or decreases based on user input.
- The background and obstacles scroll to create the illusion of movement.
- Collisions with obstacles end the game.
- The game ends when the player reaches the time limit or collides with an obstacle.
This project is a work in progress. Ensure all necessary files are present and properly linked before attempting to build and run the game. If you encounter any issues with resource loading, check that all image and font files are in the correct locations relative to the executable.