mirror of
https://github.com/n0remac/2020GameJamPractice.git
synced 2025-12-06 01:13:10 -06:00
Added sprites
This commit is contained in:
@@ -1,3 +1,6 @@
|
||||
"""
|
||||
Platformer Game
|
||||
"""
|
||||
import arcade
|
||||
|
||||
# Constants
|
||||
@@ -5,6 +8,12 @@ SCREEN_WIDTH = 1000
|
||||
SCREEN_HEIGHT = 650
|
||||
SCREEN_TITLE = "Platformer"
|
||||
|
||||
# Constants used to scale our sprites from their original size
|
||||
CHARACTER_SCALING = 1
|
||||
TILE_SCALING = 1
|
||||
COIN_SCALING = 0.5
|
||||
|
||||
|
||||
class MyGame(arcade.Window):
|
||||
"""
|
||||
Main application class.
|
||||
@@ -15,17 +24,61 @@ class MyGame(arcade.Window):
|
||||
# Call the parent class and set up the window
|
||||
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
|
||||
|
||||
# These are 'lists' that keep track of our sprites. Each sprite should
|
||||
# go into a list.
|
||||
self.coin_list = None
|
||||
self.wall_list = None
|
||||
self.player_list = None
|
||||
|
||||
# Separate variable that holds the player sprite
|
||||
self.player_sprite = None
|
||||
|
||||
arcade.set_background_color(arcade.csscolor.CORNFLOWER_BLUE)
|
||||
|
||||
def setup(self):
|
||||
""" Set up the game here. Call this function to restart the game. """
|
||||
pass
|
||||
# Create the Sprite lists
|
||||
self.player_list = arcade.SpriteList()
|
||||
self.wall_list = arcade.SpriteList()
|
||||
self.coin_list = arcade.SpriteList()
|
||||
|
||||
# Set up the player, specifically placing it at these coordinates.
|
||||
image_source = "images/Characters/platformChar_idle.png"
|
||||
self.player_sprite = arcade.Sprite(image_source, CHARACTER_SCALING)
|
||||
self.player_sprite.center_x = 64
|
||||
self.player_sprite.center_y = 128
|
||||
self.player_list.append(self.player_sprite)
|
||||
|
||||
# Create the ground
|
||||
# This shows using a loop to place multiple sprites horizontally
|
||||
for x in range(0, 1250, 64):
|
||||
wall = arcade.Sprite("images/Tiles/platformPack_tile001.png", TILE_SCALING)
|
||||
wall.center_x = x
|
||||
wall.center_y = 32
|
||||
self.wall_list.append(wall)
|
||||
|
||||
# Put some crates on the ground
|
||||
# This shows using a coordinate list to place sprites
|
||||
coordinate_list = [[512, 96],
|
||||
[256, 96],
|
||||
[768, 96]]
|
||||
|
||||
for coordinate in coordinate_list:
|
||||
# Add a crate on the ground
|
||||
wall = arcade.Sprite("images/Tiles/platformPack_tile028.png", TILE_SCALING)
|
||||
wall.position = coordinate
|
||||
self.wall_list.append(wall)
|
||||
|
||||
def on_draw(self):
|
||||
""" Render the screen. """
|
||||
|
||||
# Clear the screen to the background color
|
||||
arcade.start_render()
|
||||
# Code to draw the screen goes here
|
||||
|
||||
# Draw our sprites
|
||||
self.wall_list.draw()
|
||||
self.coin_list.draw()
|
||||
self.player_list.draw()
|
||||
|
||||
|
||||
def main():
|
||||
@@ -36,4 +89,4 @@ def main():
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
main()
|
||||
|
||||
Reference in New Issue
Block a user