Assignment3 Development Progress
As part of our group work for Assignment 3, I developed the logic for enemy car generation in the game. To improve gameplay clarity and user experience, apart from the original enemy car logic, I deployed to ensured that only one enemy car appears on the screen at a time. This avoids visual clutter and gives players enough time to react and avoid incoming traffic.
The system is controlled by a timer called TrafficTimer. A new enemy car is spawned only when the timer exceeds 0.35 seconds and there are no other enemy cars currently on the screen. This check ensures the game waits until the previous car has either exited the screen or been destroyed before creating the next one.
Each enemy car appears in a random lane. I used a variable called CarLane, which randomly picks a value from 1 to 4. Depending on the value, a corresponding car (Blue, Grey, Green, or Pink) is spawned in a predefined lane using stored X and Y positions. All enemy cars are added to a group called Traffic Group for easy management.
When the player’s car collides with an enemy car, an explosion is triggered at the collision point, and both cars are removed. The timer is then restarted to allow the next car to appear. Additionally, if the enemy car moves off-screen (Y-position ≥ 700), it is deleted automatically.
This system makes the game more structured, fair, and easier to play, as players only need to focus on avoiding one car at a time, enhancing both gameplay and performance.

















