add gameplay

Signed-off-by: Better nya <nya@nya.com>
This commit is contained in:
Better nya 2026-02-18 08:54:31 +11:00
parent fe2ccf5edf
commit 9b1dc0c48e

22
main.py
View file

@ -1,7 +1,8 @@
import sys
import pygame
import sys
pygame.init()
pygame.font.init()
#SETUP
WIDTH, HEIGHT = 800, 600
screen = pygame.display.set_mode((WIDTH, HEIGHT))
@ -41,12 +42,27 @@ while running:
pygame.quit()
sys.exit()
#score/timer
font = pygame.font.SysFont(None, 48)
start_time = 0
current_time = pygame.time.get_ticks()
elapsed_time = (current_time - start_time) // 1000
timer_text = font.render(f"Time: {elapsed_time}s", True, (255, 255, 255)) # Render the text
screen.blit(timer_text, (100, 100))
#INPUT
keys = pygame.key.get_pressed()
if keys[pygame.K_LEFT]:
if keys[pygame.K_LEFT] or keys[pygame.K_a]:
car_x -= car_speed
if keys[pygame.K_RIGHT]:
if keys[pygame.K_RIGHT] or keys[pygame.K_d]:
car_x += car_speed
if keys[pygame.K_UP] or keys[pygame.K_w]:
car_y -= car_speed
if keys[pygame.K_DOWN] or keys[pygame.K_s]:
car_y += car_speed
#LANE SPEED
lane_y += lane_speed