mirror of
https://github.com/n0remac/game-jam-2020.git
synced 2025-12-14 18:09:56 -06:00
create new sprites class for holding sprite paths
This commit is contained in:
@@ -3,7 +3,11 @@ config.py
|
|||||||
Holds all constants used for setting up the game.
|
Holds all constants used for setting up the game.
|
||||||
May later hold functions for loading/saving configuration files.
|
May later hold functions for loading/saving configuration files.
|
||||||
"""
|
"""
|
||||||
|
import os
|
||||||
|
|
||||||
|
BASE_PATH = os.path.dirname(os.path.abspath(__file__))
|
||||||
|
RESOURCES = os.path.join(BASE_PATH, "resources")
|
||||||
|
IMAGES = os.path.join(RESOURCES, "images")
|
||||||
|
|
||||||
class Config(object):
|
class Config(object):
|
||||||
"""
|
"""
|
||||||
@@ -23,9 +27,22 @@ class Config(object):
|
|||||||
# Movement speed of player, in pixels per frame
|
# Movement speed of player, in pixels per frame
|
||||||
PLAYER_MOVEMENT_SPEED = 7
|
PLAYER_MOVEMENT_SPEED = 7
|
||||||
|
|
||||||
# How many pixels to keep as a minimum margin between the character
|
# How many pixels to keep as a minimum margin between the character and the edge of the screen.
|
||||||
# and the edge of the screen.
|
|
||||||
LEFT_VIEWPORT_MARGIN = 250
|
LEFT_VIEWPORT_MARGIN = 250
|
||||||
RIGHT_VIEWPORT_MARGIN = 250
|
RIGHT_VIEWPORT_MARGIN = 250
|
||||||
BOTTOM_VIEWPORT_MARGIN = 50
|
BOTTOM_VIEWPORT_MARGIN = 50
|
||||||
TOP_VIEWPORT_MARGIN = 100
|
TOP_VIEWPORT_MARGIN = 100
|
||||||
|
|
||||||
|
|
||||||
|
class Sprites(object):
|
||||||
|
"""
|
||||||
|
Simple class for holding sprite paths.
|
||||||
|
"""
|
||||||
|
|
||||||
|
__MONSTERS = os.path.join(IMAGES, "monsters")
|
||||||
|
|
||||||
|
SKELETON = os.path.join(__MONSTERS, "skeleton.png")
|
||||||
|
GHOST = os.path.join(__MONSTERS, "ghost", "ghost1.png")
|
||||||
|
FROG = os.path.join(__MONSTERS, "frog", "frog1.png")
|
||||||
|
|
||||||
|
print(SKELETON, GHOST, FROG)
|
||||||
@@ -6,9 +6,9 @@ Holds the main game window, as well as manages basic functions for organizing th
|
|||||||
|
|
||||||
import arcade
|
import arcade
|
||||||
|
|
||||||
from config import Config
|
|
||||||
from map import Dungeon
|
from map import Dungeon
|
||||||
from mobs import Player, Enemy
|
from mobs import Player, Enemy
|
||||||
|
from config import Config, Sprites
|
||||||
|
|
||||||
|
|
||||||
class Game(arcade.Window):
|
class Game(arcade.Window):
|
||||||
@@ -59,8 +59,8 @@ class Game(arcade.Window):
|
|||||||
|
|
||||||
# Create monsters
|
# Create monsters
|
||||||
self.enemy_list.extend([
|
self.enemy_list.extend([
|
||||||
Enemy("resources/images/monsters/ghost/ghost1.png", 200, 200).get_enemy(),
|
Enemy(Sprites.GHOST, 200, 200).get_enemy(),
|
||||||
Enemy("resources/images/monsters/frog/frog1.png", 200, 1000).get_enemy()
|
Enemy(Sprites.FROG, 200, 1000).get_enemy()
|
||||||
])
|
])
|
||||||
|
|
||||||
# Create the 'physics engine'
|
# Create the 'physics engine'
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ Organizes all classes related to Mobs, Entities, Enemies, Players and Items.
|
|||||||
|
|
||||||
import arcade
|
import arcade
|
||||||
|
|
||||||
from config import Config
|
from config import Config, Sprites
|
||||||
|
|
||||||
|
|
||||||
class Mob(object):
|
class Mob(object):
|
||||||
@@ -37,8 +37,7 @@ class Player(Mob):
|
|||||||
super(Player, self).__init__(*args, **kwargs)
|
super(Player, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
def setup(self):
|
def setup(self):
|
||||||
image_source = "resources/images/monsters/skeleton.png"
|
self.player_sprite = arcade.Sprite(Sprites.SKELETON, Config.CHARACTER_SCALING)
|
||||||
self.player_sprite = arcade.Sprite(image_source, Config.CHARACTER_SCALING)
|
|
||||||
self.player_sprite.center_x = Config.SCREEN_WIDTH / 2
|
self.player_sprite.center_x = Config.SCREEN_WIDTH / 2
|
||||||
self.player_sprite.center_y = Config.SCREEN_HEIGHT / 2
|
self.player_sprite.center_y = Config.SCREEN_HEIGHT / 2
|
||||||
self.player_sprite.scale = 4
|
self.player_sprite.scale = 4
|
||||||
|
|||||||
Reference in New Issue
Block a user