some code refactors

This commit is contained in:
jedryb 2022-03-22 19:41:37 +01:00
parent 365b33ffa3
commit de745275bf
10 changed files with 78 additions and 42 deletions

11
.idea/ai-project.iml Normal file
View File

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" />
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="jdk" jdkName="Python 3.9 (ai-project)" jdkType="Python SDK" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>

View File

@ -0,0 +1,20 @@
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
<inspection_tool class="PyPackageRequirementsInspection" enabled="true" level="WARNING" enabled_by_default="true">
<option name="ignoredPackages">
<value>
<list size="7">
<item index="0" class="java.lang.String" itemvalue="pandas" />
<item index="1" class="java.lang.String" itemvalue="selenium" />
<item index="2" class="java.lang.String" itemvalue="streamlit" />
<item index="3" class="java.lang.String" itemvalue="matplotlib" />
<item index="4" class="java.lang.String" itemvalue="plotly" />
<item index="5" class="java.lang.String" itemvalue="requests" />
<item index="6" class="java.lang.String" itemvalue="numpy" />
</list>
</value>
</option>
</inspection_tool>
</profile>
</component>

View File

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.10" project-jdk-type="Python SDK" />
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.9 (ai-project)" project-jdk-type="Python SDK" />
</project>

View File

@ -2,7 +2,7 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/Inteligentny_Traktor_Grupa_16.iml" filepath="$PROJECT_DIR$/.idea/Inteligentny_Traktor_Grupa_16.iml" />
<module fileurl="file://$PROJECT_DIR$/.idea/ai-project.iml" filepath="$PROJECT_DIR$/.idea/ai-project.iml" />
</modules>
</component>
</project>

14
.idea/webResources.xml Normal file
View File

@ -0,0 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="WebResourcesPaths">
<contentEntries>
<entry url="file://$PROJECT_DIR$">
<entryData>
<resourceRoots>
<path value="file://$PROJECT_DIR$/assets" />
</resourceRoots>
</entryData>
</entry>
</contentEntries>
</component>
</project>

View File

@ -1,24 +0,0 @@
class Vehicle:
def __init__(self,
numWheels,
engine,
numDoors,
colour):
self.numWheels = numWheels
self.engine = engine
self.numDoors = numDoors
self.colour = colour
class Tractor(Vehicle):
def __init__(self,
numWheels,
engine,
numDoors,
colour,
addition,
trajectory):
super().__init__(numWheels, engine, numDoors, colour)
self.addition = addition
self.trajectory = trajectory
tractor = Tractor(4, "spalinowy", 2, "czerwony", "dodatek", "trajektoria")

29
main.py
View File

@ -1,31 +1,28 @@
import pygame
from pygame.locals import *
from world_creator import World
SCREEN_WIDTH = 1100
SCREEN_HEIGHT = 1100
from src.world_creator import World
from settings import Settings
def draw_line(screen: pygame.display, tile_size):
def draw_line(screen: pygame.display, tile_size, settings):
for line in range(0, 11):
pygame.draw.line(screen, (255, 255, 255), (0, line * tile_size), (SCREEN_WIDTH, line*tile_size))
pygame.draw.line(screen, (255, 255, 255), (line * tile_size, 0), (line * tile_size, SCREEN_HEIGHT))
pygame.draw.line(screen, (255, 255, 255), (0, line * tile_size), (settings.screen_width, line*tile_size))
pygame.draw.line(screen, (255, 255, 255), (line * tile_size, 0), (line * tile_size, settings.screen_height))
def main():
print('siema')
pygame.init()
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
tile_size = 110
world = World(tile_size)
settings = Settings()
screen = pygame.display.set_mode((settings.screen_width, settings.screen_height))
world = World(settings.screen_title_size)
pygame.display.set_caption('TRAKTOHOLIK')
background_image = pygame.image.load('assets/images/sky.png')
background_image = pygame.transform.scale(background_image, (SCREEN_WIDTH, SCREEN_HEIGHT))
tractor_image = pygame.transform.scale(pygame.image.load('assets/images/tractor.png'), (0.9*tile_size, 0.9*tile_size))
background_image = pygame.transform.scale(background_image, (settings.screen_width, settings.screen_height))
tractor_image = pygame.transform.scale(pygame.image.load('assets/images/tractor.png'),
(0.9*settings.screen_title_size, 0.9*settings.screen_title_size))
run = True
@ -33,8 +30,8 @@ def main():
screen.blit(background_image, (0, 0))
world.draw(screen)
draw_line(screen, tile_size)
screen.blit(tractor_image, (6*tile_size, 5*tile_size))
draw_line(screen, settings.screen_title_size, settings)
screen.blit(tractor_image, (6*settings.screen_title_size, 5*settings.screen_title_size))
for event in pygame.event.get():
if event.type == pygame.QUIT:

8
src/settings.py Normal file
View File

@ -0,0 +1,8 @@
class Settings:
""" A class to represent all settings for the game, maybe later as .cfg """
def __init__(self):
# Screen settings
self.screen_width = 1100
self.screen_height = 1100
self.screen_title_size = 110

9
src/tractor.py Normal file
View File

@ -0,0 +1,9 @@
class Tractor:
""" A class to represent our agent """
def __init__(self, engine, addition, trajectory):
self.engine = engine
self.addition = addition
self.trajectory = trajectory

View File

@ -2,6 +2,7 @@ import pygame
class World:
""" A class to represent game board """
world_data = [
[1, 1, 1, 1, 0, 0, 1, 1, 1, 1],