added tractor class, fixing sprites problem
This commit is contained in:
parent
600fbcebf2
commit
688ffe51d8
Binary file not shown.
38
main.py
38
main.py
@ -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
45
main2.py
Normal 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
30
src/Tractor.py
Normal 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")
|
||||
|
||||
|
||||
|
BIN
src/__pycache__/Tractor.cpython-310.pyc
Normal file
BIN
src/__pycache__/Tractor.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/__pycache__/plant.cpython-310.pyc
Normal file
BIN
src/__pycache__/plant.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/__pycache__/screen.cpython-310.pyc
Normal file
BIN
src/__pycache__/screen.cpython-310.pyc
Normal file
Binary file not shown.
BIN
src/__pycache__/tractor.cpython-310.pyc
Normal file
BIN
src/__pycache__/tractor.cpython-310.pyc
Normal file
Binary file not shown.
@ -31,3 +31,4 @@ class Plant(Sprite):
|
||||
self.fertilizer="wheat_fertilizer"
|
||||
self.pic_path="assets/Wheat.png"
|
||||
|
||||
|
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user