some code refactors
This commit is contained in:
parent
365b33ffa3
commit
de745275bf
11
.idea/ai-project.iml
Normal file
11
.idea/ai-project.iml
Normal 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>
|
20
.idea/inspectionProfiles/Project_Default.xml
Normal file
20
.idea/inspectionProfiles/Project_Default.xml
Normal 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>
|
@ -1,4 +1,4 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<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>
|
</project>
|
@ -2,7 +2,7 @@
|
|||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="ProjectModuleManager">
|
<component name="ProjectModuleManager">
|
||||||
<modules>
|
<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>
|
</modules>
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
14
.idea/webResources.xml
Normal file
14
.idea/webResources.xml
Normal 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>
|
24
Tractor.py
24
Tractor.py
@ -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
29
main.py
@ -1,31 +1,28 @@
|
|||||||
import pygame
|
import pygame
|
||||||
|
|
||||||
from pygame.locals import *
|
from src.world_creator import World
|
||||||
|
from settings import Settings
|
||||||
from world_creator import World
|
|
||||||
|
|
||||||
SCREEN_WIDTH = 1100
|
|
||||||
SCREEN_HEIGHT = 1100
|
|
||||||
|
|
||||||
|
|
||||||
def draw_line(screen: pygame.display, tile_size):
|
def draw_line(screen: pygame.display, tile_size, settings):
|
||||||
for line in range(0, 11):
|
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), (0, line * tile_size), (settings.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), (line * tile_size, 0), (line * tile_size, settings.screen_height))
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
print('siema')
|
print('siema')
|
||||||
pygame.init()
|
pygame.init()
|
||||||
|
|
||||||
screen = pygame.display.set_mode((SCREEN_WIDTH, SCREEN_HEIGHT))
|
settings = Settings()
|
||||||
tile_size = 110
|
screen = pygame.display.set_mode((settings.screen_width, settings.screen_height))
|
||||||
world = World(tile_size)
|
world = World(settings.screen_title_size)
|
||||||
pygame.display.set_caption('TRAKTOHOLIK')
|
pygame.display.set_caption('TRAKTOHOLIK')
|
||||||
|
|
||||||
background_image = pygame.image.load('assets/images/sky.png')
|
background_image = pygame.image.load('assets/images/sky.png')
|
||||||
background_image = pygame.transform.scale(background_image, (SCREEN_WIDTH, SCREEN_HEIGHT))
|
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*tile_size, 0.9*tile_size))
|
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
|
run = True
|
||||||
|
|
||||||
@ -33,8 +30,8 @@ def main():
|
|||||||
|
|
||||||
screen.blit(background_image, (0, 0))
|
screen.blit(background_image, (0, 0))
|
||||||
world.draw(screen)
|
world.draw(screen)
|
||||||
draw_line(screen, tile_size)
|
draw_line(screen, settings.screen_title_size, settings)
|
||||||
screen.blit(tractor_image, (6*tile_size, 5*tile_size))
|
screen.blit(tractor_image, (6*settings.screen_title_size, 5*settings.screen_title_size))
|
||||||
|
|
||||||
for event in pygame.event.get():
|
for event in pygame.event.get():
|
||||||
if event.type == pygame.QUIT:
|
if event.type == pygame.QUIT:
|
||||||
|
8
src/settings.py
Normal file
8
src/settings.py
Normal 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
9
src/tractor.py
Normal 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
|
||||||
|
|
@ -2,6 +2,7 @@ import pygame
|
|||||||
|
|
||||||
|
|
||||||
class World:
|
class World:
|
||||||
|
""" A class to represent game board """
|
||||||
|
|
||||||
world_data = [
|
world_data = [
|
||||||
[1, 1, 1, 1, 0, 0, 1, 1, 1, 1],
|
[1, 1, 1, 1, 0, 0, 1, 1, 1, 1],
|
Loading…
Reference in New Issue
Block a user