mirror of
https://github.com/n0remac/game-jam-2020.git
synced 2025-12-08 16:05:17 -06:00
added more monsters to test lag.
This commit is contained in:
@@ -38,10 +38,10 @@ class Config(object):
|
||||
PLAYER_MOVEMENT_SPEED = 14
|
||||
|
||||
# How many pixels to keep as a minimum margin between the characters and the edge of the screen.
|
||||
LEFT_VIEWPORT_MARGIN = 250
|
||||
RIGHT_VIEWPORT_MARGIN = 250
|
||||
BOTTOM_VIEWPORT_MARGIN = 50
|
||||
TOP_VIEWPORT_MARGIN = 100
|
||||
LEFT_VIEWPORT_MARGIN = 500
|
||||
RIGHT_VIEWPORT_MARGIN = 500
|
||||
BOTTOM_VIEWPORT_MARGIN = 250
|
||||
TOP_VIEWPORT_MARGIN = 200
|
||||
|
||||
# All debug statements and renderings should use this
|
||||
DEBUG = True
|
||||
|
||||
@@ -79,6 +79,22 @@ class Game(arcade.Window):
|
||||
mob = Mob(filename="resources/images/monsters/ghost/ghost1.png", dungeon=self.dungeon)
|
||||
mob.center_x, mob.center_y = random.choice(self.dungeon.levelList).center()
|
||||
mob.target = self.player
|
||||
mob.scale = 4
|
||||
self.enemy_list.append(mob)
|
||||
mob = Mob(filename="resources/images/monsters/ghost/ghost1.png", dungeon=self.dungeon)
|
||||
mob.center_x, mob.center_y = random.choice(self.dungeon.levelList).center()
|
||||
mob.target = self.player
|
||||
mob.scale = 4
|
||||
self.enemy_list.append(mob)
|
||||
mob = Mob(filename="resources/images/monsters/ghost/ghost1.png", dungeon=self.dungeon)
|
||||
mob.center_x, mob.center_y = random.choice(self.dungeon.levelList).center()
|
||||
mob.target = self.player
|
||||
mob.scale = 4
|
||||
self.enemy_list.append(mob)
|
||||
mob = Mob(filename="resources/images/monsters/ghost/ghost1.png", dungeon=self.dungeon)
|
||||
mob.center_x, mob.center_y = random.choice(self.dungeon.levelList).center()
|
||||
mob.target = self.player
|
||||
mob.scale = 4
|
||||
self.enemy_list.append(mob)
|
||||
|
||||
# Setup viewport
|
||||
@@ -114,9 +130,9 @@ class Game(arcade.Window):
|
||||
round(y / Config.TILE_SIZE) * Config.TILE_SIZE,
|
||||
Config.TILE_SIZE, Config.TILE_SIZE, arcade.color.RED)
|
||||
self.player.draw_hit_box()
|
||||
arcade.draw_text(str((x, y)), x - 40, y + 50, arcade.color.WHITE, 15, font_name='Arial')
|
||||
arcade.draw_text(f"FPS: {self.fps.get_fps():3.0f}", self.view_left + 50, self.view_bottom + 30,
|
||||
arcade.color.WHITE, 16, font_name='Arial')
|
||||
#arcade.draw_text(str((x, y)), x - 40, y + 50, arcade.color.WHITE, 15, font_name='Arial')
|
||||
#arcade.draw_text(f"FPS: {self.fps.get_fps():3.0f}", self.view_left + 50, self.view_bottom + 30,
|
||||
# arcade.color.WHITE, 16, font_name='Arial')
|
||||
|
||||
# Draw paths for all mobs
|
||||
for mob in self.enemy_list:
|
||||
@@ -124,7 +140,7 @@ class Game(arcade.Window):
|
||||
t1 = time.time()
|
||||
path = mob.get_path()
|
||||
t2 = time.time()
|
||||
print(f'Path acquired in {round(t2 - t1, 4)}s')
|
||||
#print(f'Path acquired in {round(t2 - t1, 4)}s')
|
||||
self.draw_path(path)
|
||||
mob.tick(path)
|
||||
|
||||
@@ -187,8 +203,7 @@ class Game(arcade.Window):
|
||||
Called whenever the mouse is clicked.
|
||||
"""
|
||||
|
||||
for mob in self.enemy_list:
|
||||
mob.center_x, mob.center_y = random.choice(self.dungeon.levelList).center()
|
||||
|
||||
|
||||
# Create a bullet TEMP SPRITE, currently wielding frog slingshot
|
||||
bullet = Temp()
|
||||
@@ -263,17 +278,22 @@ class Game(arcade.Window):
|
||||
self.view_bottom,
|
||||
Config.SCREEN_HEIGHT + self.view_bottom)
|
||||
|
||||
|
||||
self.enemy_list.update()
|
||||
|
||||
# Projectile updates
|
||||
self.bullet_list.update()
|
||||
for bullet in self.bullet_list:
|
||||
|
||||
# Collision Checks
|
||||
hit_list = arcade.check_for_collision_with_list(bullet, self.dungeon.getWalls())
|
||||
|
||||
enemy_hit_list = arcade.check_for_collision_with_list(bullet, self.enemy_list)
|
||||
# If it did, get rid of the bullet
|
||||
if len(hit_list) > 0:
|
||||
bullet.remove_from_sprite_lists()
|
||||
if len(enemy_hit_list):
|
||||
enemy_hit_list[0].remove_from_sprite_lists()
|
||||
|
||||
|
||||
# If the bullet flies off-screen, remove it. TEMP change to range calc
|
||||
if (
|
||||
|
||||
@@ -45,7 +45,7 @@ class Mob(arcade.Sprite):
|
||||
A on_update function, the Mob should decide it's next actions here.
|
||||
"""
|
||||
curpos, nextpos = self.nearestPosition(), path[1]
|
||||
print(curpos, nextpos)
|
||||
# print(curpos, nextpos)
|
||||
|
||||
if nextpos[0] > curpos[0]:
|
||||
self.change_x = Config.PLAYER_MOVEMENT_SPEED - 3
|
||||
@@ -61,7 +61,7 @@ class Mob(arcade.Sprite):
|
||||
else:
|
||||
self.change_y = 0
|
||||
|
||||
print(self.change_x, self.change_y)
|
||||
# print(self.change_x, self.change_y)
|
||||
|
||||
def get_path(self, end: Tuple[int, int] = None) -> List[Tuple[int, int]]:
|
||||
"""
|
||||
|
||||
Reference in New Issue
Block a user