mirror of
https://github.com/n0remac/game-jam-2020.git
synced 2025-12-10 02:05:21 -06:00
fix mob movement
This commit is contained in:
@@ -28,14 +28,14 @@ class Config(object):
|
|||||||
|
|
||||||
# Constants used to scale our sprites from their original size
|
# Constants used to scale our sprites from their original size
|
||||||
CHARACTER_SCALING = 1
|
CHARACTER_SCALING = 1
|
||||||
TILE_SCALING = 1
|
TILE_SCALING = 2
|
||||||
TILE_SIZE = TILE_WIDTH * TILE_SCALING
|
TILE_SIZE = TILE_WIDTH * TILE_SCALING
|
||||||
|
|
||||||
# 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 speed of player, in pixels per frame
|
||||||
PLAYER_MOVEMENT_SPEED = 7
|
PLAYER_MOVEMENT_SPEED = 14
|
||||||
|
|
||||||
# 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 = 250
|
LEFT_VIEWPORT_MARGIN = 250
|
||||||
|
|||||||
@@ -186,6 +186,10 @@ class Game(arcade.Window):
|
|||||||
"""
|
"""
|
||||||
Called whenever the mouse is clicked.
|
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
|
# Create a bullet TEMP SPRITE, currently wielding frog slingshot
|
||||||
bullet = Temp()
|
bullet = Temp()
|
||||||
# Position the bullet at the player's current location
|
# Position the bullet at the player's current location
|
||||||
@@ -259,6 +263,8 @@ class Game(arcade.Window):
|
|||||||
self.view_bottom,
|
self.view_bottom,
|
||||||
Config.SCREEN_HEIGHT + self.view_bottom)
|
Config.SCREEN_HEIGHT + self.view_bottom)
|
||||||
|
|
||||||
|
self.enemy_list.update()
|
||||||
|
|
||||||
# Projectile updates
|
# Projectile updates
|
||||||
self.bullet_list.update()
|
self.bullet_list.update()
|
||||||
for bullet in self.bullet_list:
|
for bullet in self.bullet_list:
|
||||||
|
|||||||
@@ -44,22 +44,25 @@ class Mob(arcade.Sprite):
|
|||||||
"""
|
"""
|
||||||
A on_update function, the Mob should decide it's next actions here.
|
A on_update function, the Mob should decide it's next actions here.
|
||||||
"""
|
"""
|
||||||
pos, next = self.nearestPosition(), path[0]
|
curpos, nextpos = self.nearestPosition(), path[1]
|
||||||
|
print(curpos, nextpos)
|
||||||
|
|
||||||
if next[0] > pos[0]:
|
if nextpos[0] > curpos[0]:
|
||||||
self.change_x = Config.PLAYER_MOVEMENT_SPEED
|
self.change_x = Config.PLAYER_MOVEMENT_SPEED - 3
|
||||||
elif next[0] < pos[0]:
|
elif nextpos[0] < curpos[0]:
|
||||||
self.change_x = -Config.PLAYER_MOVEMENT_SPEED
|
self.change_x = -Config.PLAYER_MOVEMENT_SPEED + 3
|
||||||
else:
|
else:
|
||||||
self.change_x = 0
|
self.change_x = 0
|
||||||
|
|
||||||
if next[1] > pos[1]:
|
if nextpos[1] > curpos[1]:
|
||||||
self.change_y = Config.PLAYER_MOVEMENT_SPEED
|
self.change_y = Config.PLAYER_MOVEMENT_SPEED - 3
|
||||||
elif next[1] < pos[1]:
|
elif nextpos[1] < curpos[1]:
|
||||||
self.change_y = Config.PLAYER_MOVEMENT_SPEED
|
self.change_y = -Config.PLAYER_MOVEMENT_SPEED + 3
|
||||||
else:
|
else:
|
||||||
self.change_y = 0
|
self.change_y = 0
|
||||||
|
|
||||||
|
print(self.change_x, self.change_y)
|
||||||
|
|
||||||
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.
|
||||||
|
|||||||
Reference in New Issue
Block a user