Created
March 1, 2025 05:46
-
-
Save Horizon733/f0078ce28dad6a893942a8bd4899bf33 to your computer and use it in GitHub Desktop.
TCET IP lecture gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import pygame | |
| pygame.init() | |
| # Game Constants | |
| WIDTH, HEIGHT = 800, 1000 | |
| WHITE = (255, 255, 255) | |
| PLAYER_BASE_SPEED = 6 # Initial player speed | |
| ENEMY_BASE_SPEED_MIN = 4 # Initial min speed for enemies | |
| ENEMY_BASE_SPEED_MAX = 8 # Initial max speed for enemies | |
| SPAWN_INTERVAL = 60 # Frames between enemy spawns | |
| SPEED_INCREASE_RATE = 0.006 # Gradual speed increase rate | |
| # Load Images | |
| road_img = pygame.image.load("assets/road.jpg") | |
| player_car_img = pygame.image.load("assets/player_car.png") | |
| enemy_car_img = pygame.image.load("assets/enemy_car.png") | |
| # Create Game Window | |
| screen = pygame.display.set_mode((WIDTH, HEIGHT)) | |
| pygame.display.set_caption("One-Lane Vertical Racing") | |
| class Car: | |
| def __init__(self, x, y, image, speed): | |
| self.x = x | |
| self.y = y | |
| self.image = image | |
| self.speed = speed | |
| self.width = 50 | |
| self.height = 100 | |
| def draw(self, screen): | |
| screen.blit(self.image, (self.x, self.y)) | |
| class BlueCar(Car): | |
| def __init__(self, x, y, image, speed): | |
| super().__init__(x, y, image, speed) | |
| def move_left(self): | |
| pass | |
| def move_right(self): | |
| pass | |
| def move_up(self): | |
| pass | |
| def move_down(self): | |
| pass | |
| class OrangeCar(Car): | |
| pass | |
| car = Car(50, 100, player_car_img, PLAYER_BASE_SPEED) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment