added tractor class, fixing sprites problem

This commit is contained in:
Milosz Rolewski 2023-03-19 21:00:49 +01:00
parent 600fbcebf2
commit 688ffe51d8
11 changed files with 101 additions and 25 deletions

Binary file not shown.

38
main.py
View File

@ -1,23 +1,35 @@
import pygame
import sys
import tractor
import screen
import src.screen as screen
import src.plant as plant
from src.Tractor import Tractor as ractor2
#import src.tractor as tractor2
# pygame initialization
pygame.init()
pygame.mouse.set_visible(False)
# #new tractor sprite - todo
# tr=tractor2('oil','manual',36,36)
# tr_group = pygame.sprite.Group()
# tr_group.add()
# creating agent
myTractor = tractor.Tractor
if __name__ == "__main__":
running = True
#if __name__ == "__main__":
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# defines agent movement
tractor.movement(myTractor)
# screen visualisation
screen.set_screen(myTractor)
pygame.quit()
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()
sys.exit()
# defines agent movement
tractor.movement(myTractor)
# screen visualisation
screen.set_screen(myTractor)
#pygame.quit()

45
main2.py Normal file
View File

@ -0,0 +1,45 @@
import pygame
import sys
import tractor
import src.screen as screen
import src.plant as plant
class Tractor2(pygame.sprite.Sprite):
def __init__(self,engine,transmission,pos_x,pos_y):
super.__init__()
self.image=pygame.image.load("../assets/tractor/tractor.png")
self.image=pygame.transform.scale(self,(36,36))
self.rect = self.image.get_rect()
self.engine=engine
self.transmission=transmission
self.pos_x=pos_x
self.pos_y=pos_y
self.fuel=100
def update(self):
self.rect.center=pygame.mouse.get_pos()
# self.pos_x=pos_x
# self.pos_y=pos_y
# pygame initialization
pygame.init()
pygame.mouse.set_visible(False)
myTractor = tractor.Tractor
if __name__ == "__main__":
running = True
while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
pygame.quit()
sys.exit()
# defines agent movement
tractor.movement(myTractor)
# screen visualisation
screen.set_screen(myTractor)

30
src/Tractor.py Normal file
View File

@ -0,0 +1,30 @@
from pygame.sprite import Sprite
import pygame
class Tractor(pygame.sprite.Sprite):
def __init__(self,engine,transmission,pos_x,pos_y):
super.__init__()
self.image=pygame.image.load("../assets/tractor/tractor.png")
self.image=pygame.transform.scale(self,(36,36))
self.rect = self.image.get_rect()
self.engine=engine
self.transmission=transmission
self.pos_x=pos_x
self.pos_y=pos_y
self.fuel=100
def update(self):
self.rect.center=pygame.mouse.get_pos()
# self.pos_x=pos_x
# self.pos_y=pos_y
def movement(self):
print("todo")
def rotation(self,direction):
print("todo")

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@ -31,3 +31,4 @@ class Plant(Sprite):
self.fertilizer="wheat_fertilizer"
self.pic_path="assets/Wheat.png"

View File

@ -1,12 +0,0 @@
from pygame.sprite import Sprite
class Plant(Sprite):
def __init__(self,engine,transmission,pos_x,pos_y):
super.__init__()
self.engine=engine
self.transmission=transmission
self.pos_x=pos_x
self.pos_y=pos_y
self.fuel=100