Skip to content

Instantly share code, notes, and snippets.

@Snegovikufa
Created March 26, 2020 15:09
Show Gist options
  • Save Snegovikufa/d00cbe497d832506f215219f53b31fc4 to your computer and use it in GitHub Desktop.
Save Snegovikufa/d00cbe497d832506f215219f53b31fc4 to your computer and use it in GitHub Desktop.
Simple game
import arcade
SCREEN_WIDTH = 1000
SCREEN_HEIGHT = 650
SCREEN_TITLE = "Platformer"
class MyGame(arcade.Window):
def __init__(self):
super().__init__(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_TITLE)
self.bg = None
self.coin_list = None
self.wall_list = None
self.player_list = None
self.player_sprite = None
def setup(self):
self.bg = arcade.Sprite("images/bg/bg1.jpg")
self.bg.left = 0
self.bg.bottom = 0
self.player_list = arcade.SpriteList()
self.wall_list = arcade.SpriteList()
self.coin_list = arcade.SpriteList()
self.player_sprite = arcade.Sprite("images/player_1/player_stand.png")
self.player_sprite.center_x = 64
self.player_sprite.center_y = 120
self.player_list.append(self.player_sprite)
for x in range(0, 1250, 64):
wall = arcade.Sprite("images/tiles/grassMid.png", 0.5)
wall.center_x = x
wall.center_y = 32
self.wall_list.append(wall)
coordinate_list = [[512, 96],
[256, 96],
[768, 96]]
for coordinate in coordinate_list:
wall = arcade.Sprite("images/tiles/boxCrate_double.png", 0.5)
wall.position = coordinate
self.wall_list.append(wall)
def on_draw(self):
arcade.start_render()
self.bg.draw()
self.wall_list.draw()
self.coin_list.draw()
self.player_list.draw()
def main():
window = MyGame()
window.setup()
arcade.run()
if __name__ == "__main__":
main()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment