Change image on rotate
This commit is contained in:
parent
1900954708
commit
edb56dac1d
@ -1,10 +1,11 @@
|
||||
from const import SAPPER_IDLE
|
||||
import pygame as pg
|
||||
|
||||
|
||||
class Agent:
|
||||
def __init__(self, x: int = 0, y: int = 0):
|
||||
self.name = "Kapitan Bomba"
|
||||
self.img = SAPPER_IDLE
|
||||
self.img = pg.image.load(SAPPER_IDLE[1])
|
||||
self.dir = 1
|
||||
self.x = x
|
||||
self.y = y
|
||||
|
@ -37,7 +37,13 @@ for name, val in {
|
||||
)
|
||||
|
||||
ICON = main_path + '/images/mine_icon.png'
|
||||
SAPPER_IDLE = pg.image.load(main_path + '/images/sapper_idle/agent.png')
|
||||
SAPPER_IDLE = [main_path + '/images/sapper_idle/agent0.png',
|
||||
main_path + '/images/sapper_idle/agent1.png',
|
||||
main_path + '/images/sapper_idle/agent2.png',
|
||||
main_path + '/images/sapper_idle/agent3.png']
|
||||
|
||||
|
||||
#pg.image.load(main_path + '/images/sapper_idle/agent1.png')
|
||||
#empty space
|
||||
|
||||
|
||||
|
@ -1,4 +1,6 @@
|
||||
import pygame as pg
|
||||
import os
|
||||
main_path = os.path.dirname(os.getcwd())
|
||||
|
||||
from agent import Agent
|
||||
from environment import Environment
|
||||
@ -25,7 +27,6 @@ class GameUi:
|
||||
)
|
||||
self.update()
|
||||
self.clock.tick(15)
|
||||
self.agent.img = SAPPER_IDLE
|
||||
self.update()
|
||||
|
||||
def update(self):
|
||||
@ -38,4 +39,7 @@ class GameUi:
|
||||
def rotate(self, dir):
|
||||
self.agent.dir = (self.agent.dir + dir) % 4
|
||||
print(self.agent.dir)
|
||||
self.agent.img = pg.image.load(SAPPER_IDLE[self.agent.dir])
|
||||
self.update()
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user