add gameplay
Signed-off-by: Better nya <nya@nya.com>
This commit is contained in:
parent
fe2ccf5edf
commit
9b1dc0c48e
1 changed files with 19 additions and 3 deletions
22
main.py
22
main.py
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue