v. 1.06
This commit is contained in:
parent
ba1f2d96b6
commit
c981921fbd
4
Tractor.py
Normal file
4
Tractor.py
Normal file
@ -0,0 +1,4 @@
|
||||
class Tractor:
|
||||
def __init__(self, horizontal_index, vertical_index):
|
||||
self.horizontal_index = horizontal_index
|
||||
self.vertical_index = vertical_index
|
32
main.py
32
main.py
@ -2,14 +2,12 @@ import pygame
|
||||
# wersja 1.05
|
||||
|
||||
from Main import Board, driving, drawUI
|
||||
from Main.Tractor import Tractor
|
||||
from Main.constants import *
|
||||
from Main.Field import Field
|
||||
|
||||
pygame.init()
|
||||
|
||||
# display size in pixels
|
||||
display = pygame.display.set_mode((DISPLAY_SIZE_HORIZONTAL, DISPLAY_SIZE_VERTICAL))
|
||||
# program name
|
||||
pygame.display.set_caption('Tractor')
|
||||
|
||||
working = True
|
||||
@ -18,13 +16,11 @@ cruiseControl = True
|
||||
horizontal_change = 0
|
||||
vertical_change = 0
|
||||
|
||||
change_tile = False
|
||||
board = Board.generate()
|
||||
color = BLACK
|
||||
clock = pygame.time.Clock()
|
||||
|
||||
tractor_horizontal_index = 0
|
||||
tractor_vertical_index = 0
|
||||
tractor = Tractor(horizontal_index=0, vertical_index=0)
|
||||
|
||||
clock = pygame.time.Clock()
|
||||
|
||||
while working:
|
||||
for event in pygame.event.get():
|
||||
@ -32,24 +28,22 @@ while working:
|
||||
working = False
|
||||
if event.type == pygame.KEYDOWN:
|
||||
if event.key == pygame.K_SPACE:
|
||||
field = board[tractor_horizontal_index][tractor_vertical_index]
|
||||
field = board[tractor.horizontal_index][tractor.vertical_index]
|
||||
field.state = 4
|
||||
horizontal_change, vertical_change = driving.manualTurning(event, tractor_horizontal_index,
|
||||
tractor_vertical_index, horizontal_change,
|
||||
horizontal_change, vertical_change = driving.manualTurning(event, tractor.horizontal_index,
|
||||
tractor.vertical_index, horizontal_change,
|
||||
vertical_change)
|
||||
tractor_horizontal_index += horizontal_change
|
||||
tractor_vertical_index += vertical_change
|
||||
tractor.horizontal_index += horizontal_change
|
||||
tractor.vertical_index += vertical_change
|
||||
|
||||
horizontal_change, vertical_change = driving.cruiseControl(cruiseControl, horizontal_change, vertical_change,
|
||||
tractor.horizontal_index, tractor.vertical_index)
|
||||
|
||||
drawUI.drawUI(board, display, tractor_horizontal_index, tractor_vertical_index)
|
||||
|
||||
drawUI.drawUI(board, display, tractor.horizontal_index, tractor.vertical_index)
|
||||
|
||||
clock.tick(FPS)
|
||||
|
||||
horizontal_change, vertical_change = driving.cruiseControl(cruiseControl, horizontal_change, vertical_change,
|
||||
tractor_horizontal_index, tractor_vertical_index)
|
||||
|
||||
print(tractor_horizontal_index + horizontal_change, " ", tractor_vertical_index + vertical_change)
|
||||
print(tractor.horizontal_index + horizontal_change, " ", tractor.vertical_index + vertical_change)
|
||||
print(horizontal_change, " ", vertical_change)
|
||||
|
||||
pygame.quit()
|
||||
|
Loading…
Reference in New Issue
Block a user