add arrow keys operation and mine classes

This commit is contained in:
Mateusz Walas 2021-03-29 18:26:40 +02:00
parent bdddb68e90
commit 2513f49fdc
4 changed files with 19 additions and 4 deletions

6
src/ap_mine.py Normal file
View File

@ -0,0 +1,6 @@
#anti-personnel mine
from src.mine import Mine
class AP_Mine(Mine):
pass

6
src/at_mine.py Normal file
View File

@ -0,0 +1,6 @@
#anti-tank mine
from src.mine import Mine
class AT_Mine(Mine):
pass

View File

@ -26,13 +26,13 @@ def main():
if event.type == pg.QUIT:
running = False
elif event.type == pg.KEYDOWN:
if event.key == pg.K_d and agent.x*80 < 700:
if event.key == pg.K_d or event.key == pg.K_RIGHT and agent.x*80 < 700:
game_ui.move('x', 1)
elif event.key == pg.K_a and agent.x*80 > 5:
elif event.key == pg.K_a or event.key == pg.K_LEFT and agent.x*80 > 5:
game_ui.move('x', -1)
elif event.key == pg.K_s and agent.y*80 < 700:
elif event.key == pg.K_s or event.key == pg.K_DOWN and agent.y*80 < 700:
game_ui.move('y', 1)
elif event.key == pg.K_w and agent.y*80 > 0:
elif event.key == pg.K_w or event.key == pg.K_UP and agent.y*80 > 0:
game_ui.move('y', -1)
elif event.key == pg.K_SPACE:
if env.field[agent.y][agent.x].number > 3:

3
src/mine.py Normal file
View File

@ -0,0 +1,3 @@
class Mine:
def __init__(self, isArmed):
self.isArmed = isArmed