Midterm Progress 1 – Street Crash

Concept and User Interaction

Concept: The inspiration for my current project stems from a previous experience in an “Introduction to Computer Science” course, where I was tasked with creating a game using the Processing library in Python. This immersive experience not only kindled my passion for game development but also became the driving force behind my current endeavor. Inspired by this journey, I set out to create an entertaining 2D car racing game called “Street Crash”. The core idea is quite straightforward: players take the wheel of a virtual car and must deftly navigate it along a bustling road while skillfully avoiding collisions with other cars. The final goal is to achieve the greatest possible score while retaining control and avoiding accidents.

User Interaction: I’ve given considerable thought to the user experience in my game. I created an intuitive interaction approach to ensure that players find the game accessible and entertaining. This is how it works:

  • Player Control: Players can easily steer their car using the arrow keys. The left arrow key initiates a left turn, while the right arrow key guides the car to the right.
  • Game Start: A simple and universally recognized action ‘pressing the spacebar’ kickstarts the game. This design choice makes it easy for players to begin their adventure.
  • Game Restart: After a game over, players can swiftly get back into the action by pressing the spacebar again.

Classes and Functions

  • Player Class (player): This class takes care of everything related to the player’s car, including its position and movement. Here’s a snippet of the code:
function player() {
  // Define properties and methods for the player's car
  this.pos = createVector(width / 2, height - 100);
  this.r = createVector(40, 60);

  // Render the player's car
  this.render = function () {
    // Drawing code for the player's car
    // ...
  };

  // Update the player's car position
  this.update = function () {
    // Logic for updating player's car position
    // ...
  };
}
  • Street Class (street): This class represents the road that the player’s car travels on, including its movement.
  • Cars Class (cars): This class manages the spawning, movement, and collision detection of other cars on the road.
  • Keys Function: The keys function responds to arrow key input for controlling the player’s car.

Embedded Sketch

Tackling Complexity: Collision Detection

The collision detection system is without a doubt one of the most complex aspects of this project. It is critical to the game’s fairness and enjoyment that collisions are detected and handled reliably. To reduce the risk associated with this complexity, I’ve carefully implemented the collision detection algorithm. This method determines if the player’s car and other cars cross on both the X and Y axes, taking into account the cars’ size. In the event of a collision, the game ends, and the player is given the option to restart.

Edit Link

 

Leave a Reply