mirror of
https://github.com/n0remac/game-jam-2020.git
synced 2025-12-17 14:10:05 -06:00
@@ -34,11 +34,16 @@ class Config(object):
|
|||||||
# The number of pixels across the level
|
# The number of pixels across the level
|
||||||
LEVEL_SIZE = 10 * TILE_SCALING * TILE_WIDTH
|
LEVEL_SIZE = 10 * TILE_SCALING * TILE_WIDTH
|
||||||
|
|
||||||
# Movement speed of player, in pixels per frame
|
# Movement speeds, in pixels per frame
|
||||||
PLAYER_MOVEMENT_SPEED = 14
|
PLAYER_MOVEMENT_SPEED = 14
|
||||||
|
|
||||||
MONSTER_MOVEMENT_SPEED = 11
|
MONSTER_MOVEMENT_SPEED = 11
|
||||||
|
|
||||||
|
# Boon and Recipe constants
|
||||||
|
BOON_LIST = ["heal", "harden", "hurry"]
|
||||||
|
HEAL_AMOUNT = 20
|
||||||
|
ARMOR_AMOUNT = 1
|
||||||
|
SPEED_AMOUNT = 2
|
||||||
|
|
||||||
# How many pixels to keep as a minimum margin between the characters and the edge of the screen.
|
# How many pixels to keep as a minimum margin between the characters and the edge of the screen.
|
||||||
LEFT_VIEWPORT_MARGIN = 700
|
LEFT_VIEWPORT_MARGIN = 700
|
||||||
RIGHT_VIEWPORT_MARGIN = 700
|
RIGHT_VIEWPORT_MARGIN = 700
|
||||||
|
|||||||
@@ -106,6 +106,11 @@ class Game(arcade.Window):
|
|||||||
self.bullet_list.draw()
|
self.bullet_list.draw()
|
||||||
self.Recipe.render()
|
self.Recipe.render()
|
||||||
|
|
||||||
|
# Draw stats
|
||||||
|
arcade.draw_text("Health:"+str(self.player.health)+"/"+str(self.player.max_health), self.view_left+100, self.view_bottom+60, arcade.color.RED, 15, font_name='Arial')
|
||||||
|
arcade.draw_text("Armor:"+str(self.player.armor), self.view_left+100, self.view_bottom+90, arcade.color.BLUE, 15, font_name='Arial')
|
||||||
|
arcade.draw_text("Speed:"+str(self.player.speed), self.view_left+100, self.view_bottom+120, arcade.color.YELLOW, 15, font_name='Arial')
|
||||||
|
|
||||||
if Config.DEBUG:
|
if Config.DEBUG:
|
||||||
x, y = self.player.position
|
x, y = self.player.position
|
||||||
arcade.draw_rectangle_outline(round(x / Config.TILE_SIZE) * Config.TILE_SIZE,
|
arcade.draw_rectangle_outline(round(x / Config.TILE_SIZE) * Config.TILE_SIZE,
|
||||||
@@ -148,16 +153,16 @@ class Game(arcade.Window):
|
|||||||
"""Called whenever a key is pressed. """
|
"""Called whenever a key is pressed. """
|
||||||
|
|
||||||
if key == arcade.key.UP or key == arcade.key.W:
|
if key == arcade.key.UP or key == arcade.key.W:
|
||||||
self.player.change_y = Config.PLAYER_MOVEMENT_SPEED
|
self.player.change_y = self.player.speed
|
||||||
self.prev_keypress.append(key)
|
self.prev_keypress.append(key)
|
||||||
elif key == arcade.key.DOWN or key == arcade.key.S:
|
elif key == arcade.key.DOWN or key == arcade.key.S:
|
||||||
self.player.change_y = -Config.PLAYER_MOVEMENT_SPEED
|
self.player.change_y = -self.player.speed
|
||||||
self.prev_keypress.append(key)
|
self.prev_keypress.append(key)
|
||||||
elif key == arcade.key.LEFT or key == arcade.key.A:
|
elif key == arcade.key.LEFT or key == arcade.key.A:
|
||||||
self.player.change_x = -Config.PLAYER_MOVEMENT_SPEED
|
self.player.change_x = -self.player.speed
|
||||||
self.prev_keypress.append(key)
|
self.prev_keypress.append(key)
|
||||||
elif key == arcade.key.RIGHT or key == arcade.key.D:
|
elif key == arcade.key.RIGHT or key == arcade.key.D:
|
||||||
self.player.change_x = Config.PLAYER_MOVEMENT_SPEED
|
self.player.change_x = self.player.speed
|
||||||
self.prev_keypress.append(key)
|
self.prev_keypress.append(key)
|
||||||
elif key == 65307:
|
elif key == 65307:
|
||||||
self.close()
|
self.close()
|
||||||
@@ -239,8 +244,9 @@ class Game(arcade.Window):
|
|||||||
if len(hit_list) > 0:
|
if len(hit_list) > 0:
|
||||||
bullet.remove_from_sprite_lists()
|
bullet.remove_from_sprite_lists()
|
||||||
if len(enemy_hit_list):
|
if len(enemy_hit_list):
|
||||||
self.player.add_kill(enemy_hit_list[0].monster_type)
|
boon = self.Recipe.add_kill(enemy_hit_list[0].monster_type)
|
||||||
self.Recipe.add_kill(enemy_hit_list[0].monster_type)
|
if boon >= 0:
|
||||||
|
getattr(self.player, Config.BOON_LIST[boon])();
|
||||||
enemy_hit_list[0].remove_from_sprite_lists()
|
enemy_hit_list[0].remove_from_sprite_lists()
|
||||||
bullet.remove_from_sprite_lists()
|
bullet.remove_from_sprite_lists()
|
||||||
|
|
||||||
|
|||||||
@@ -130,7 +130,7 @@ class Mob(arcade.Sprite):
|
|||||||
super(Mob, self).__init__(*args, **kwargs)
|
super(Mob, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
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 = 60, max_armor
|
||||||
self.idle_textures = []
|
self.idle_textures = []
|
||||||
self.walking_textures = []
|
self.walking_textures = []
|
||||||
self.up_textures = []
|
self.up_textures = []
|
||||||
@@ -164,20 +164,19 @@ class Player(Mob):
|
|||||||
self.refreshIndex = 0
|
self.refreshIndex = 0
|
||||||
self.prev = Enums.IDLE
|
self.prev = Enums.IDLE
|
||||||
self.texture = next(self.map[self.prev])
|
self.texture = next(self.map[self.prev])
|
||||||
self.kill_list = []
|
|
||||||
self.cur_recipe = None
|
self.cur_recipe = None
|
||||||
self.speed = 14
|
self.speed = 14
|
||||||
|
|
||||||
def add_kill(self, creature):
|
def heal(self):
|
||||||
# Adds a kill to kill_list. If 3 or more check the recipe then give a power up if it matches.
|
self.health+=Config.HEAL_AMOUNT
|
||||||
self.kill_list.append(creature)
|
if self.health > self.max_health:
|
||||||
print(self.kill_list)
|
self.health = self.max_health
|
||||||
print(self.cur_recipe)
|
|
||||||
if self.cur_recipe == self.kill_list:
|
def harden(self):
|
||||||
print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++")
|
self.armor+=Config.ARMOR_AMOUNT
|
||||||
self.kill_list = []
|
|
||||||
elif len(self.kill_list) >= 3:
|
def hurry(self):
|
||||||
self.kill_list = []
|
self.speed+=Config.SPEED_AMOUNT
|
||||||
|
|
||||||
def update_animation(self, delta_time: float = 1 / 60) -> None:
|
def update_animation(self, delta_time: float = 1 / 60) -> None:
|
||||||
"""
|
"""
|
||||||
@@ -258,8 +257,6 @@ class Enemy(Mob):
|
|||||||
else:
|
else:
|
||||||
self.change_y = 0
|
self.change_y = 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def get_path(self, end: Tuple[int, int] = None) -> List[Tuple[int, int]]:
|
def get_path(self, end: Tuple[int, int] = None) -> List[Tuple[int, int]]:
|
||||||
"""
|
"""
|
||||||
Returns the path to get to the Mob's target in absolute integer positions.
|
Returns the path to get to the Mob's target in absolute integer positions.
|
||||||
|
|||||||
@@ -24,9 +24,11 @@ class ActiveRecipe(arcade.SpriteList):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
super().__init__()
|
super().__init__()
|
||||||
self.active = Recipe.GHOSTS
|
self.active = Recipe.GHOSTS
|
||||||
self.cycle_recipes = [self.set_frogs, self.set_ghosts]
|
self.cycle_recipes = [self.set_ghosts, self.set_frogs, self.set_ggf]
|
||||||
|
self.ghost = arcade.Sprite(filename="resources/images/monsters/ghost/ghost1.png")
|
||||||
|
self.frog = arcade.Sprite(filename="resources/images/monsters/frog/frog1.png")
|
||||||
self.pos = 0
|
self.pos = 0
|
||||||
self.kill_num = 0
|
self.kill_list = []
|
||||||
|
|
||||||
|
|
||||||
def render(self) -> None:
|
def render(self) -> None:
|
||||||
@@ -37,38 +39,54 @@ class ActiveRecipe(arcade.SpriteList):
|
|||||||
sprite.scale = 4
|
sprite.scale = 4
|
||||||
sprite.center_x = screen_right - x
|
sprite.center_x = screen_right - x
|
||||||
sprite.center_y = screen_top
|
sprite.center_y = screen_top
|
||||||
|
x += 70
|
||||||
|
sprite.draw()
|
||||||
|
x = 0
|
||||||
|
for kill in self.kill_list:
|
||||||
|
sprite = getattr(self, kill)
|
||||||
|
screen_right = arcade.get_viewport()[1] - 240
|
||||||
|
screen_top = arcade.get_viewport()[3] - 150
|
||||||
|
sprite.scale = 4
|
||||||
|
sprite.center_x = screen_right + x
|
||||||
|
sprite.center_y = screen_top
|
||||||
x += 70
|
x += 70
|
||||||
sprite.draw()
|
sprite.draw()
|
||||||
|
|
||||||
def next_recipe(self):
|
def next_recipe(self):
|
||||||
self.cycle_recipes[self.pos]()
|
|
||||||
self.pos += 1
|
self.pos += 1
|
||||||
if self.pos == len(self.cycle_recipes):
|
if self.pos == len(self.cycle_recipes):
|
||||||
self.pos = 0
|
self.pos = 0
|
||||||
|
self.cycle_recipes[self.pos]()
|
||||||
|
|
||||||
def add_kill(self, monster_type):
|
def add_kill(self, monster_type) -> int:
|
||||||
for sprite in self.sprite_list:
|
# Adds a kill to kill_list. If 3 or more check the recipe then give a power up if it matches.
|
||||||
if monster_type in "ghost":
|
self.kill_list.append(monster_type)
|
||||||
r, g, b = sprite.color
|
ret_val = -1
|
||||||
darken = lambda c, s: c * (1 - s)
|
if len(self.kill_list) >= 3:
|
||||||
r = darken(r, .5)
|
if self.active == self.kill_list:
|
||||||
g = darken(g, .5)
|
print("+++++++++++++++++++++++++++++++++++++++++++++++++++++++")
|
||||||
b = darken(b, .5)
|
self.kill_list = []
|
||||||
sprite.color = (r, g, b)
|
ret_val = self.pos
|
||||||
return
|
self.kill_list = []
|
||||||
|
return ret_val
|
||||||
|
|
||||||
def set_ghosts(self) -> None:
|
def set_ghosts(self) -> None:
|
||||||
self.active = Recipe.GHOSTS
|
self.active = Recipe.GHOSTS
|
||||||
self.sprite_list = []
|
self.sprite_list = []
|
||||||
self.sprite_list.append(arcade.Sprite(filename="resources/images/monsters/ghost/ghost1.png"))
|
self.sprite_list.append(self.ghost)
|
||||||
self.sprite_list.append(arcade.Sprite(filename="resources/images/monsters/ghost/ghost1.png"))
|
self.sprite_list.append(self.ghost)
|
||||||
self.sprite_list.append(arcade.Sprite(filename="resources/images/monsters/ghost/ghost1.png"))
|
self.sprite_list.append(self.ghost)
|
||||||
|
|
||||||
|
|
||||||
def set_frogs(self) -> None:
|
def set_frogs(self) -> None:
|
||||||
self.active = Recipe.FROGS
|
self.active = Recipe.FROGS
|
||||||
self.sprite_list = []
|
self.sprite_list = []
|
||||||
self.sprite_list.append(arcade.Sprite(filename="resources/images/monsters/frog/frog1.png"))
|
self.sprite_list.append(self.frog)
|
||||||
self.sprite_list.append(arcade.Sprite(filename="resources/images/monsters/frog/frog1.png"))
|
self.sprite_list.append(self.frog)
|
||||||
self.sprite_list.append(arcade.Sprite(filename="resources/images/monsters/frog/frog1.png"))
|
self.sprite_list.append(self.frog)
|
||||||
|
|
||||||
|
def set_ggf(self) -> None:
|
||||||
|
self.active = Recipe.GHOST_FROG
|
||||||
|
self.sprite_list = []
|
||||||
|
self.sprite_list.append(self.frog)
|
||||||
|
self.sprite_list.append(self.ghost)
|
||||||
|
self.sprite_list.append(self.ghost)
|
||||||
Reference in New Issue
Block a user