AIprojekt-wozek/Program.py

37 lines
975 B
Python

import pygame
from pygame.locals import *
from Truck import Truck
WINDOW_X = 1400
WINDOW_Y = 750
RECT_SIZE = 50
class Program:
def __init__(self):
pygame.init()
self.window = pygame.display.set_mode((WINDOW_X, WINDOW_Y)) # decides window's size
self.track = Truck(self.window)
self.track.draw()
def run(self):
running = True
while running:
for event in pygame.event.get(): # integrating with keyboard
if event.type == KEYDOWN:
if event.key == K_LEFT:
self.track.move_left()
if event.key == K_RIGHT:
self.track.move_right()
if event.key == K_UP:
self.track.move_up()
if event.key == K_DOWN:
self.track.move_down()
elif event.type == QUIT:
running = False