moved the tractor drawing code to the Tractor class

This commit is contained in:
MarRac 2024-04-09 14:57:41 +02:00
parent aa9519bc0f
commit 1f08e350d8

View File

@ -2,11 +2,11 @@
import pygame
from area.constants import WIDTH,HEIGHT,FIELD_WIDTH,FIELD_HEIGHT,TILE_SIZE,GREY,ROWS,COLS
from area.tractor import Tractor
from tile import Tile
tiles = []
tractor = Tractor(0*TILE_SIZE, 0*TILE_SIZE)
fieldX = (WIDTH-FIELD_WIDTH)/2
# in center of the screen
fieldY = 100
@ -17,8 +17,7 @@ def positionFieldElements():
for t in tiles:
t.x += fieldX
t.y += fieldY
tractor.x += fieldX
tractor.y += fieldY
def createTiles():
for y in range(0, COLS):
@ -35,11 +34,10 @@ def createField(win):
image = pygame.transform.scale(image, (TILE_SIZE, TILE_SIZE))
win.blit(image, (t.x, t.y))
pygame.display.flip()
imageTractor = pygame.image.load(tractor.image).convert_alpha()
imageTractor = pygame.transform.scale(imageTractor, (TILE_SIZE, TILE_SIZE))
win.blit(imageTractor, (tractor.x, tractor.y))
pygame.display.flip()
def drawWindow(win):
win.fill(GREY)
createField(win)
pygame.display.flip()