Merge pull request #16 from n0remac/monster-generation

Monster generation
This commit is contained in:
Lief9100
2020-04-19 13:00:25 -07:00
committed by GitHub
13 changed files with 36 additions and 2 deletions

View File

@@ -9,6 +9,7 @@ import arcade
from config import Config from config import Config
from map import Level from map import Level
from mobs import Player from mobs import Player
from mobs import Enemy
class Game(arcade.Window): class Game(arcade.Window):
@@ -24,6 +25,7 @@ class Game(arcade.Window):
# go into a list. # go into a list.
self.wall_list = None self.wall_list = None
self.floor_list = None self.floor_list = None
self.enemy_list = None
self.player_list = None self.player_list = None
# Separate variable that holds the player sprite # Separate variable that holds the player sprite
@@ -44,14 +46,20 @@ class Game(arcade.Window):
def setup(self): def setup(self):
""" Set up the game here. Call this function to restart the game. """ """ Set up the game here. Call this function to restart the game. """
# Create the Sprite lists # Create the Sprite lists
self.wall_list = arcade.SpriteList() self.wall_list = arcade.SpriteList()
self.floor_list = arcade.SpriteList() self.floor_list = arcade.SpriteList()
self.enemy_list = arcade.SpriteList()
# Set up the player, specifically placing it at these coordinates. # Set up the player, specifically placing it at these coordinates.
Player.setup(self) Player.setup(self)
# Create the level # Create the level
self.floor_list, self.wall_list = Level.load_file('resources/levels/box.json') self.floor_list, self.wall_list = Level.load_file('resources/levels/test1.json')
# Create monsters
self.enemy_list.append(Enemy("resources/images/monsters/ghost/ghost1.png", 200, 200).get_enemy())
self.enemy_list.append(Enemy("resources/images/monsters/frog/frog1.png", 200, 1000).get_enemy())
# Create the 'physics engine' # Create the 'physics engine'
self.physics_engine = arcade.PhysicsEngineSimple(self.player_sprite, self.wall_list) self.physics_engine = arcade.PhysicsEngineSimple(self.player_sprite, self.wall_list)
@@ -65,6 +73,7 @@ class Game(arcade.Window):
# Draw our sprites # Draw our sprites
self.floor_list.draw() self.floor_list.draw()
self.player_sprite.draw() self.player_sprite.draw()
self.enemy_list.draw()
self.wall_list.draw() self.wall_list.draw()
def on_key_press(self, key, modifiers): def on_key_press(self, key, modifiers):

View File

@@ -12,11 +12,14 @@ class Mob(object):
""" """
Represents a Mob. No defined behaviour, it has no intelligence. Represents a Mob. No defined behaviour, it has no intelligence.
""" """
def __init__(self, sprite, max_health=100, max_armor=0) -> None: def __init__(self, sprite, x, y, max_health=100, max_armor=0) -> None:
self.sprite_path = sprite self.sprite_path = sprite
self.sprite = arcade.Sprite(self.sprite_path, Config.CHARACTER_SCALING) self.sprite = arcade.Sprite(self.sprite_path, Config.CHARACTER_SCALING)
self.max_health, self.max_armor = max_health, max_armor self.max_health, self.max_armor = max_health, max_armor
self.health, self.armor = max_health, max_armor self.health, self.armor = max_health, max_armor
self.sprite.scale = 4
self.sprite.center_x = x
self.sprite.center_y = y
def tick(self) -> None: def tick(self) -> None:
""" """
@@ -56,6 +59,9 @@ class Enemy(Mob):
def __init__(self, *args, **kwargs) -> None: def __init__(self, *args, **kwargs) -> None:
super(Enemy, self).__init__(*args, **kwargs) super(Enemy, self).__init__(*args, **kwargs)
def get_enemy(self):
return self.sprite
def tick(self) -> None: def tick(self) -> None:
""" """
A on_update function, the Enemy Mob should scan for the player, decide how to path to it, and A on_update function, the Enemy Mob should scan for the player, decide how to path to it, and

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 294 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 303 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 305 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 276 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 321 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 317 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 331 B

View File

Binary file not shown.

After

Width:  |  Height:  |  Size: 317 B

View File

@@ -0,0 +1,19 @@
{
"elements" : {
"w" : "resources/images/tiles/wall_tile.png",
" " : "resources/images/tiles/floor_tile.png",
"e" : ""
},
"structure" : [
["w", "w", "w", "w", "w", "w", "w", "w", "w", "w"],
["w", " ", " ", "w", " ", " ", "w", " ", " ", "w"],
["w", " ", " ", "w", " ", " ", "w", " ", " ", "w"],
["w", " ", " ", "w", " ", " ", "w", " ", " ", "w"],
["w", " ", " ", " ", " ", " ", " ", " ", " ", "w"],
["w", " ", " ", " ", " ", " ", " ", " ", " ", "w"],
["w", " ", " ", "w", " ", " ", "w", " ", " ", "w"],
["w", " ", " ", "w", " ", " ", "w", " ", " ", "w"],
["w", " ", " ", "w", " ", " ", "w", " ", " ", "w"],
["w", "w", "w", "w", "w", "w", "w", "w", "w", "w"]
]
}