f1 2d
f1 2d
S.no Heading
1. ABSTRACT
2. ABOUT PYTHON
3. MODULES USED
6. OUTPUT
7. BIBLIOGRAPHY
ABSTRACT
The project titled "F1 : 2D" is an immersive racing game developed in
Python using the powerful pygame library. This game aims to create an
engaging experience that not only entertains players but also
showcases the application of fundamental programming concepts,
particularly focusing on object-oriented programming (OOP) and
graphical user interface (GUI) development skills.
Key Features
One of the standout features of the "F1 : 2D" project is its emphasis
on object-oriented programming principles This approach facilitates the
encapsulation of game-related data and behaviors,.
Players can track their progress through a clear scoring system that
displays laps completed, time taken, and remaining lives. This feature
motivates players to improve their performance with each race. The
game also includes a completion message that rewards players for their
achievements, further enhancing the sense of accomplishment.
ABOUT PYTHON
Python is a high-level, interpreted programming language known for its
simplicity, readability, and vast range of applications. Created by Guido
van Rossum and first released in 1991, Python has grown in popularity
over the years due to its clear syntax and dynamic nature, making it an
excellent choice for both beginners and seasoned developers.
2. Interpreted Language:
Sys
Random
HARDWARE :
SOFTWARE :
import sys
import random
# Initialize Pygame
pygame.init()
# Constants
FPS = 60
pygame.display.set_caption('F1 : 2D')
car_speed = 0
# Track boundaries
laps = 0
lap_start_time = 0
lap_duration = 0
# Enemy cars
enemy_cars = []
NUM_ENEMY_CARS = 5
ENEMY_SPEED = 3
def draw_road():
def display_score():
def create_enemy_cars():
for _ in range(NUM_ENEMY_CARS):
enemy_cars.append((enemy_x, enemy_y))
def move_enemy_cars():
if y > HEIGHT:
def check_collision():
return False
def main():
while True:
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
# Movement
keys = pygame.key.get_pressed()
if keys[pygame.K_UP]: # Accelerate
car_speed += acceleration
if keys[pygame.K_DOWN]: # Brake
car_speed -= braking
# Cap speed
car_speed = max_speed
if car_speed < 0:
car_speed = 0
move_enemy_cars()
if car_y < 0:
laps += 1
if check_collision():
pygame.quit()
sys.exit()
# Draw everything
draw_road()
display_score()
pygame.display.flip()
clock.tick(FPS)
if _name_ == '_main_':
main()
OUTPUT
BIBLIOGRAPHY:
Google.com
chat.openai.com
www.Formula1.com
Geeksforgeeks.com