add graphics

This commit is contained in:
eugenep 2021-03-27 19:34:41 +01:00
parent 50ad12591a
commit 58d78f83bc
6 changed files with 71 additions and 2 deletions

BIN
images/bomb.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
images/grenade.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.6 MiB

BIN
images/mine.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

BIN
images/robot.bmp Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.5 MiB

10
main.py
View File

@ -20,6 +20,16 @@ class Game:
self.all_sprites = pg.sprite.Group()
self.walls = pg.sprite.Group()
self.player = Player(self, 1, 1)
self.mine1 = Mine(self, 8, 6)
self.mine2 = Mine(self, 7, 6)
self.mine3 = Mine(self, 2, 3)
self.grenade1 = Grenade(self, 1, 8)
self.grenade2 = Grenade(self, 3, 4)
self.grenade3 = Grenade(self, 9, 5)
self.bomb1 = Bomb(self, 6, 7)
self.bomb2 = Bomb(self, 3, 3)
self.bomb3 = Bomb(self, 4, 9)
def run(self):

View File

@ -6,8 +6,10 @@ class Player(pg.sprite.Sprite):
self.groups = game.all_sprites
pg.sprite.Sprite.__init__(self, self.groups)
self.game = game
self.image = pg.Surface((TILESIZE, TILESIZE))
self.image.fill(YELLOW)
#self.image = pg.Surface((TILESIZE, TILESIZE))
self.image = pg.image.load('images/robot.bmp')
#self.image.fill(YELLOW)
self.image = pg.transform.scale(self.image, (TILESIZE, TILESIZE))
self.rect = self.image.get_rect()
self.x = x
self.y = y
@ -20,3 +22,60 @@ class Player(pg.sprite.Sprite):
self.rect.x = self.x * TILESIZE
self.rect.y = self.y * TILESIZE
class Mine(pg.sprite.Sprite):
def __init__(self, game, x, y):
self.groups = game.all_sprites
pg.sprite.Sprite.__init__(self, self.groups)
self.game = game
#self.image = pg.Surface((TILESIZE, TILESIZE))
self.image = pg.image.load('images/mine.bmp')
#self.image.fill(YELLOW)
self.image = pg.transform.scale(self.image, (TILESIZE, TILESIZE))
self.rect = self.image.get_rect()
self.x = x
self.y = y
def update(self):
self.rect.x = self.x * TILESIZE
self.rect.y = self.y * TILESIZE
class Bomb(pg.sprite.Sprite):
def __init__(self, game, x, y):
self.groups = game.all_sprites
pg.sprite.Sprite.__init__(self, self.groups)
self.game = game
#self.image = pg.Surface((TILESIZE, TILESIZE))
self.image = pg.image.load('images/bomb.bmp')
#self.image.fill(YELLOW)
self.image = pg.transform.scale(self.image, (TILESIZE, TILESIZE))
self.rect = self.image.get_rect()
self.x = x
self.y = y
def update(self):
self.rect.x = self.x * TILESIZE
self.rect.y = self.y * TILESIZE
class Grenade(pg.sprite.Sprite):
def __init__(self, game, x, y):
self.groups = game.all_sprites
pg.sprite.Sprite.__init__(self, self.groups)
self.game = game
#self.image = pg.Surface((TILESIZE, TILESIZE))
self.image = pg.image.load('images/grenade.bmp')
#self.image.fill(YELLOW)
self.image = pg.transform.scale(self.image, (TILESIZE, TILESIZE))
self.rect = self.image.get_rect()
self.x = x
self.y = y
def update(self):
self.rect.x = self.x * TILESIZE
self.rect.y = self.y * TILESIZE