1
0
forked from s444417/ProjektAI

Merge branch 'adam_branch' of s444417/ProjektAI into master

This commit is contained in:
Mikołaj Krzymiński 2020-03-22 17:28:46 +00:00 committed by Gogs
commit 2dd3357a2c
7 changed files with 180 additions and 147 deletions

112
.gitignore vendored Normal file
View File

@ -0,0 +1,112 @@
# Created by https://www.gitignore.io/api/python
# Edit at https://www.gitignore.io/?templates=python
### Python ###
# Byte-compiled / optimized / DLL files
__pycache__/
*.py[cod]
*$py.class
# C extensions
*.so
# Distribution / packaging
.Python
build/
develop-eggs/
dist/
downloads/
eggs/
.eggs/
lib/
lib64/
parts/
sdist/
var/
wheels/
pip-wheel-metadata/
share/python-wheels/
*.egg-info/
.installed.cfg
*.egg
/idea/workspace.xml
MANIFEST
# PyInstaller
# Usually these files are written by a python script from a template
# before PyInstaller builds the exe, so as to inject date/other infos into it.
*.manifest
*.spec
# Installer logs
pip-log.txt
pip-delete-this-directory.txt
# Unit test / coverage reports
htmlcov/
.tox/
.nox/
.coverage
.coverage.*
.cache
nosetests.xml
coverage.xml
*.cover
.hypothesis/
.pytest_cache/
# Translations
*.mo
*.pot
# Scrapy stuff:
.scrapy
# Sphinx documentation
docs/_build/
# PyBuilder
target/
# pyenv
.python-version
# pipenv
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
# However, in case of collaboration, if having platform-specific dependencies or dependencies
# having no cross-platform support, pipenv may install dependencies that don't work, or not
# install all needed dependencies.
#Pipfile.lock
# celery beat schedule file
celerybeat-schedule
# SageMath parsed files
*.sage.py
# Spyder project settings
.spyderproject
.spyproject
# Rope project settings
.ropeproject
# Mr Developer
.mr.developer.cfg
.project
.pydevproject
# mkdocs documentation
/site
# mypy
.mypy_cache/
.dmypy.json
dmypy.json
# Pyre type checker
.pyre/
# End of https://www.gitignore.io/api/python

View File

@ -1,6 +0,0 @@
<component name="InspectionProjectProfileManager">
<settings>
<option name="USE_PROJECT_PROFILE" value="false" />
<version value="1.0" />
</settings>
</component>

View File

@ -1,13 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="PYTHON_MODULE" version="4">
<component name="NewModuleRootManager">
<content url="file://$MODULE_DIR$">
<excludeFolder url="file://$MODULE_DIR$/venv" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
<component name="TestRunnerService">
<option name="PROJECT_TEST_RUNNER" value="Unittests" />
</component>
</module>

View File

@ -1,7 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="JavaScriptSettings">
<option name="languageLevel" value="ES6" />
</component>
<component name="ProjectRootManager" version="2" project-jdk-name="Python 3.7 (kelner)" project-jdk-type="Python SDK" />
</project>

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/.idea/kelner.iml" filepath="$PROJECT_DIR$/.idea/kelner.iml" />
</modules>
</component>
</project>

View File

@ -1,90 +0,0 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="4be2149b-d9bc-4e21-8365-293320ae7f92" name="Default Changelist" comment="" />
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" />
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileTemplateManagerImpl">
<option name="RECENT_TEMPLATES">
<list>
<option value="Python Script" />
</list>
</option>
</component>
<component name="ProjectId" id="1ZSC25l5bE6jvUIMcW31QzsqTTN" />
<component name="PropertiesComponent">
<property name="WebServerToolWindowFactoryState" value="false" />
<property name="settings.editor.selected.configurable" value="vcs.Git" />
</component>
<component name="RecentsManager">
<key name="MoveFile.RECENT_KEYS">
<recent name="J:\PycharmProjects\kelner" />
</key>
</component>
<component name="RunDashboard">
<option name="ruleStates">
<list>
<RuleState>
<option name="name" value="ConfigurationTypeDashboardGroupingRule" />
</RuleState>
<RuleState>
<option name="name" value="StatusDashboardGroupingRule" />
</RuleState>
</list>
</option>
</component>
<component name="RunManager">
<configuration name="main" type="PythonConfigurationType" factoryName="Python" temporary="true">
<module name="kelner" />
<option name="INTERPRETER_OPTIONS" value="" />
<option name="PARENT_ENVS" value="true" />
<envs>
<env name="PYTHONUNBUFFERED" value="1" />
</envs>
<option name="SDK_HOME" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$" />
<option name="IS_MODULE_SDK" value="true" />
<option name="ADD_CONTENT_ROOTS" value="true" />
<option name="ADD_SOURCE_ROOTS" value="true" />
<EXTENSION ID="PythonCoverageRunConfigurationExtension" runner="coverage.py" />
<option name="SCRIPT_NAME" value="$PROJECT_DIR$/main.py" />
<option name="PARAMETERS" value="" />
<option name="SHOW_COMMAND_LINE" value="false" />
<option name="EMULATE_TERMINAL" value="false" />
<option name="MODULE_MODE" value="false" />
<option name="REDIRECT_INPUT" value="false" />
<option name="INPUT_FILE" value="" />
<method v="2" />
</configuration>
<recent_temporary>
<list>
<item itemvalue="Python.main" />
</list>
</recent_temporary>
</component>
<component name="SvnConfiguration">
<configuration />
</component>
<component name="TaskManager">
<task active="true" id="Default" summary="Default task">
<changelist id="4be2149b-d9bc-4e21-8365-293320ae7f92" name="Default Changelist" comment="" />
<created>1584822897275</created>
<option name="number" value="Default" />
<option name="presentableId" value="Default" />
<updated>1584822897275</updated>
<workItem from="1584822899496" duration="10270000" />
<workItem from="1584835781926" duration="189000" />
</task>
<servers />
</component>
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="com.intellij.coverage.CoverageDataManagerImpl">
<SUITE FILE_PATH="coverage/kelner$main.coverage" NAME="main Coverage Results" MODIFIED="1584835787208" SOURCE_PROVIDER="com.intellij.coverage.DefaultCoverageFileProvider" RUNNER="coverage.py" COVERAGE_BY_TEST_ENABLED="true" COVERAGE_TRACING_ENABLED="false" WORKING_DIRECTORY="$PROJECT_DIR$" />
</component>
</project>

View File

@ -1,33 +1,76 @@
import pygame
import time
#initialize the pygame
# initialize the pygame
pygame.init()
#create the screen
# initiate variables
screen = pygame.display.set_mode((1000,1000))
#caption
pygame.display.set_caption("Bardzo mądry kelner")
#grid
# Grid variables
gridImg = pygame.image.load("20x20grid.png")
gridX = 0
gridY = 0
#weiter
# Waiter variables
waiterImg = pygame.image.load("waiter.png")
waiterX = 10
waiterY = 1
waiterY = 10
# TODO: classes in separate folders
class Grid:
def __init__(self, g_x, g_y, grid_img):
self.g_x = g_x
self.g_y = g_y
self.grid_img = grid_img
def draw_grid(self):
global screen
screen.blit(self.grid_img, (self.g_x, self.g_y))
class Waiter:
def __init__(self, w_x, w_y, waiter_img):
self.waiter_img = waiter_img
self.w_x = w_x
self.w_y = w_y
self.position = [w_x, w_y]
def draw_waiter(self):
global screen
screen.blit(self.waiter_img, self.position)
def move_left(self, w_x):
self.position[0] = (self.position[0]-w_x) % 1000
screen.blit(self.waiter_img, self.position)
def move_right(self, w_x):
self.position[0] = (self.position[0]+w_x) % 1000
screen.blit(self.waiter_img, self.position)
def move_up(self, w_y):
self.position[1] = (self.position[1]-w_y) % 1000
screen.blit(self.waiter_img, self.position)
def move_down(self, w_y):
self.position[1] = (self.position[1]+w_y) % 1000
screen.blit(self.waiter_img, self.position)
# waiter
waiterX_change = 0
waiterY_change = 0
def grid():
screen.blit(gridImg, (gridX,gridY))
grid = Grid(gridX, gridY, gridImg)
waiter = Waiter(waiterX, waiterY, waiterImg)
def waiter(x, y):
screen.blit(waiterImg, (x,y))
#loop
# loop
running = True
while running:
@ -37,24 +80,26 @@ while running:
for event in pygame.event.get():
if event.type == pygame.QUIT:
running = False
# TODO: switch case
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_LEFT:
waiterX_change = -50
waiter.move_left(20)
if event.key == pygame.K_RIGHT:
waiterX_change = 50
waiter.move_right(20)
if event.key == pygame.K_UP:
waiterY_change = -50
waiter.move_up(20)
if event.key == pygame.K_DOWN:
waiterY_change = 50
waiter.move_down(20)
# do czego to ???
if event.type == pygame.KEYUP:
if event.key == pygame.K_LEFT or event.key == pygame.K_RIGHT:
waiterX_change = 0
if event.key == pygame.K_UP or event.key == pygame.K_DOWN:
waiterY_change = 0
grid()
waiterX += waiterX_change
waiterY += waiterY_change
waiter(waiterX, waiterY)
pygame.display.update()
grid.draw_grid()
waiter.draw_waiter()
pygame.display.update()
time.sleep(0.1)