Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added assets/sprites/box_close.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/box_open.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/door_golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/door_golden_side.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/door_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/door_red_side.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/door_silver.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/door_silver_side.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/door_wood.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/door_wood_side.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/enemy_walk0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/enemy_walk1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/enemy_walk2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/enemy_walk3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed assets/sprites/frontwall_left.png
Binary file not shown.
Binary file removed assets/sprites/frontwall_mid.png
Binary file not shown.
Binary file removed assets/sprites/frontwall_right.png
Binary file not shown.
Binary file added assets/sprites/key_golden.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/key_red.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/key_silver.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
File renamed without changes
Binary file added assets/sprites/mc_walk0.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/mc_walk1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/mc_walk2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/mc_walk3.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/sprites/torch.png
24 changes: 7 additions & 17 deletions assets/tilemaps/level1.tmx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.0" orientation="orthogonal" renderorder="right-down" width="80" height="50" tilewidth="32" tileheight="32" infinite="0" nextlayerid="13" nextobjectid="1">
<map version="1.10" tiledversion="1.10.0" orientation="orthogonal" renderorder="right-down" width="80" height="50" tilewidth="32" tileheight="32" infinite="0" nextlayerid="7" nextobjectid="1">
<tileset firstgid="1" source="sprites.tsx"/>
<layer id="2" name="floor" width="80" height="50" locked="1">
<data encoding="base64" compression="zlib">
Expand All @@ -8,7 +8,12 @@
</layer>
<layer id="1" name="walls" width="80" height="50" locked="1">
<data encoding="base64" compression="zlib">
eJztmksOgzAMBeECvf9xKxaoKKog8cvHxjNSNq1s06lRcNNtAwAAAIBM7CxpfdqVm2LUnCtq1sTjT4vHnxaf2V8P8KeR2V+m+3cE+FtbM5I/j9/Z2/1d54R/r+Fvfs4y/ljlTHdyN/PdzYTWa1Hen5WzjO/dS9Z8+PvlHBGHPy0Of1pcJn8te1Hts8TTnmXNqeCp/1aAPw1LT5f9Henz9sZj/0Vi1PxRs0Zd00w8zr/403NGwas/63520uNcuyZXpvs3y++n+NPq4k+riz+tbkZ/rXvfW57/VCL1n0ci+fN8//asiz+tLv60uvjT6uJPq4s/rS7+tLoZ/VnOnaz/LVLOurzlPOK/tYYNcQ==
eJztmtEOwjAIRbcf8P8/1+xh0TRaO25ZQc5J+qIB9IS1w7ltAAAAAFCJnSWtx3Xlphg154qaI/H40+Lxp8VX9jcD/GlU9rdPiM/iz4NK+58Hlfyp15ql5kh8Fn+Wmu9zwqfX8Hd/zjb+WO1Md9Kb+XozofWzKO/flbONn91L1nz4e+X0iMOfFoc/La6Svytn0ei9xK8zy5pTIVL/rQB/Gpaebvs70/edTcT+y4TX/DGyvuEx53sRcf7N1M8Rr1/86Tmt59nJjOfaI7lW+evtcV79F/E370z7H/408KeBP43I/q6eff9y/6eSqf8iksmfx1yo5szkL/L+N7Mu/rS6+NPq4k+riz+tLv60uhX9WZ47Wf9bpDzripbziH8C3pgNFg==
</data>
</layer>
<layer id="6" name="doors" width="80" height="50" locked="1">
<data encoding="base64" compression="zlib">
eJzt18EJACAIBdDm6dD+4zVB0KES8717IEj6bQ0AAACAlRH8HqrwV8isRxfANr0CIJpdBFThzgd+dmvGncyKcicAGdhXf7uRmdyaAADw1gRA8QI/
</data>
</layer>
<layer id="3" name="objects" width="80" height="50" locked="1">
Expand All @@ -21,19 +26,4 @@
eJztzjERAAAIBKBPYy77pzCCk+cCCUgAAAAAAAAAAAAAAAAAAOBWJf19AHYDKYYAhw==
</data>
</layer>
<layer id="5" name="arrows" width="80" height="50" locked="1">
<data encoding="base64" compression="zlib">
eJzt2DkSgCAQBEACj///2Mhwq7Y4FKU7RiWQgaEUAAAAIlvj83vFe1u/CazjSI6TK3xN9t+OnF1mAQDtenfK7B4XddE32Jfhn6xtZlbbKd2fjNXa9Xub6bwE9BHluPUOAOup7R/ODUBWlDPuTQHGuHNXzsLzLhUcAI8=
</data>
</layer>
<layer id="11" name="enemies" width="80" height="50" locked="1">
<data encoding="base64" compression="zlib">
eJzt1ssJADAIREELSP/15mQBQj6wzFTgQZ5WAQAA8Nr6PQAQQUtIZbcBSOGmAan0DZjSDeA2nQEAmr8AAADgjA19dABh
</data>
</layer>
<layer id="10" name="player" width="80" height="50" locked="1">
<data encoding="base64" compression="zlib">
eJztzgENAAAIA6AXsH9dY3w6SEACAAAAAAAAAAAAAAAAAHdNOwAAjyyd+AAO
</data>
</layer>
</map>
28 changes: 19 additions & 9 deletions assets/tilemaps/level2.tmx
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.0" orientation="orthogonal" renderorder="right-down" width="80" height="50" tilewidth="32" tileheight="32" infinite="0" nextlayerid="5" nextobjectid="1">
<map version="1.10" tiledversion="1.10.0" orientation="orthogonal" renderorder="right-down" width="30" height="20" tilewidth="32" tileheight="32" infinite="0" nextlayerid="7" nextobjectid="1">
<tileset firstgid="1" source="sprites.tsx"/>
<layer id="2" name="floor" width="80" height="50">
<layer id="1" name="floor" width="30" height="20">
<data encoding="base64" compression="zlib">
eJzt2FEOgjAQRdHuQJ39L9bwYSREWzpvSof03qSfDvUIEiiFiIiIiIh6enSurWfwas0cdcyXsPDDD795fib6GX74icdc5fo1/PCb6DfqmPjVP/PJyvf/fh9+/vMryu/Yv9/qbKv5KTN+zcQPP/zwW9VvX8+9qGXh6Y5+kfNGLvxivr9a5J7Ud0JX+/U+OxyfI/DT/TzV9jTbJfv5h5/mV7tG8dP9vKnvLTyzMl6/yp5qe802Ez/88MNvdb+t3nvf1X6WcGbLItP5h5++12wz8cMPP/zwww8//O7qR/7ePxWy/Q==
eJwTYGBgEBjFo5gMLATFA+2OUUxe3IzG38BjfiyYHvGCzV4YHrV31F5a2EvLND1Q9hLCAA30JV8=
</data>
</layer>
<layer id="1" name="walls" width="80" height="50">
<layer id="4" name="player" width="30" height="20" locked="1">
<data encoding="base64" compression="zlib">
eJztmksOgzAMBeECvf9xKxaoKKog8cvHxjNSNq1s06lRcNNtAwAAAIBM7CxpfdqVm2LUnCtq1sTjT4vHnxaf2V8P8KeR2V+m+3cE+FtbM5I/j9/Z2/1d54R/r+Fvfs4y/ljlTHdyN/PdzYTWa1Hen5WzjO/dS9Z8+PvlHBGHPy0Of1pcJn8te1Hts8TTnmXNqeCp/1aAPw1LT5f9Henz9sZj/0Vi1PxRs0Zd00w8zr/403NGwas/63520uNcuyZXpvs3y++n+NPq4k+riz+tbkZ/rXvfW57/VCL1n0ci+fN8//asiz+tLv60uvjT6uJPq4s/rS7+tLoZ/VnOnaz/LVLOurzlPOK/tYYNcQ==
eJxjYBgFvAPtgFEwCkbBKBgFo2AUDCsAAHYMAA4=
</data>
</layer>
<layer id="3" name="objects" width="80" height="50">
<layer id="3" name="object" width="30" height="20" locked="1">
<data encoding="base64" compression="zlib">
eJzt2TsKwCAQBUDvEBJIld/975heAoKoi2SmkRXUV/tSAgAAGGvLVpjZVZgBAAD4pyc6AFS6owMAMDV/5jF0bwDQzxkdACDIWXluaRkCqLZ+7O1B70JPR6d7876sNJe07I51eYz0AlJZAoI=
eJxjYBgFwx0Ik6BWnmauGAVDFSgOtANGwbABolQwQ4wKZoyCUUAPAACflgB/
</data>
</layer>
<layer id="4" name="pickables" width="80" height="50">
<layer id="2" name="wall" width="30" height="20">
<data encoding="base64" compression="zlib">
eJztzjERAAAIBKBPYy77pzCCk+cCCUgAAAAAAAAAAAAAAAAAAOBWJf19AHYDKYYAhw==
eJzjY2Bg4BsgjA8QkidH7ai9lNvLiIRhgBENDyf/DgV70cOfEU0NNnls8UdN/9ICDDd7CcULNntx6cGmHxcgJq2S6l9i1A82e0kpr7CZSSjMaeFfYsBgtZdYNbSyl5i8QwomxkwAYyAFTQ==
</data>
</layer>
<layer id="5" name="enemy" width="30" height="20" locked="1">
<data encoding="base64" compression="zlib">
eJxjYBgFlACegXbAKMAAhOJkNM5GwWgaGAWjYBTQGgAAO28AMQ==
</data>
</layer>
<layer id="6" name="arrows" width="30" height="20" locked="1">
<data encoding="base64" compression="zlib">
eJxjYBgFlAI2HOKsdHXFKEAG6HGCHhe44gyb2lEw+AC++CMGsFDFFaNgFAxtwE6h/tGyEj8AACxvADg=
</data>
</layer>
</map>
71 changes: 58 additions & 13 deletions assets/tilemaps/sprites.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset version="1.10" tiledversion="1.10.0" name="sprites" tilewidth="128" tileheight="150" tilecount="25" columns="0">
<tileset version="1.10" tiledversion="1.10.0" name="sprites" tilewidth="128" tileheight="150" tilecount="33" columns="0">
<grid orientation="orthogonal" width="1" height="1"/>
<tile id="0">
<image width="32" height="32" source="../sprites/wall.png"/>
</tile>
<tile id="3">
<image width="32" height="16" source="../sprites/arrow-down.png"/>
</tile>
<tile id="4">
<image width="16" height="32" source="../sprites/arrow-left.png"/>
</tile>
<tile id="5">
<image width="16" height="32" source="../sprites/arrow-right.png"/>
</tile>
<tile id="6">
<image width="32" height="16" source="../sprites/arrow-up.png"/>
</tile>
<tile id="11">
<image width="64" height="64" source="../sprites/enemy.png"/>
</tile>
Expand Down Expand Up @@ -67,31 +79,64 @@
<tile id="37">
<properties>
<property name="file" value="knife.png"/>
<property name="name" value="knife"/>
</properties>
<image width="70" height="70" source="../items/knife.png"/>
</tile>
<tile id="6">
<tile id="38">
<properties>
<property name="dir" value="up"/>
<property name="file" value="door_red.png"/>
<property name="name_color" value="door-red"/>
</properties>
<image width="32" height="32" source="../sprites/arrow-up.png"/>
<image width="64" height="38" source="../sprites/door_red.png"/>
</tile>
<tile id="5">
<tile id="39">
<properties>
<property name="dir" value="right"/>
<property name="file" value="door_golden.png"/>
<property name="name_color" value="door-golden"/>
</properties>
<image width="32" height="32" source="../sprites/arrow-right.png"/>
<image width="64" height="38" source="../sprites/door_golden.png"/>
</tile>
<tile id="4">
<tile id="40">
<properties>
<property name="dir" value="left"/>
<property name="file" value="door_silver.png"/>
<property name="name_color" value="door-silver"/>
</properties>
<image width="32" height="32" source="../sprites/arrow-left.png"/>
<image width="64" height="38" source="../sprites/door_silver.png"/>
</tile>
<tile id="3">
<tile id="41">
<properties>
<property name="file" value="door_wood.png"/>
<property name="name_color" value="door-wood"/>
</properties>
<image width="64" height="38" source="../sprites/door_wood.png"/>
</tile>
<tile id="42">
<properties>
<property name="file" value="door_golden_side.png"/>
<property name="name_color" value="door-golden"/>
</properties>
<image width="14" height="64" source="../sprites/door_golden_side.png"/>
</tile>
<tile id="43">
<properties>
<property name="file" value="door_red_side.png"/>
<property name="name_color" value="door-red"/>
</properties>
<image width="14" height="64" source="../sprites/door_red_side.png"/>
</tile>
<tile id="44">
<properties>
<property name="file" value="door_silver_side.png"/>
<property name="name_color" value="door_silver"/>
</properties>
<image width="14" height="64" source="../sprites/door_silver_side.png"/>
</tile>
<tile id="45">
<properties>
<property name="dir" value="down"/>
<property name="file" value="door_wood_side.png"/>
<property name="name_color" value="door-wood"/>
</properties>
<image width="32" height="32" source="../sprites/arrow-down.png"/>
<image width="14" height="64" source="../sprites/door_wood_side.png"/>
</tile>
</tileset>
29 changes: 29 additions & 0 deletions assets/tilemaps/tutorial_key.tmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.0" orientation="orthogonal" renderorder="right-down" width="10" height="10" tilewidth="32" tileheight="32" infinite="0" nextlayerid="6" nextobjectid="1">
<tileset firstgid="1" source="sprites.tsx"/>
<layer id="1" name="floor" width="10" height="10" locked="1">
<data encoding="base64" compression="zlib">
eJxjYCAe8BPAxKrjp7J5A6VOiER1xAAAEOED9A==
</data>
</layer>
<layer id="2" name="wall" width="10" height="10" locked="1">
<data encoding="base64" compression="zlib">
eJxjZGBgYCQC8zEQBnzDWB0jHrX4+CCgDxVHD09s4QwAylQBMQ==
</data>
</layer>
<layer id="4" name="object" width="10" height="10" locked="1">
<data encoding="base64" compression="zlib">
eJxjYBg8QGmgHUAm0KOiWQAxwABR
</data>
</layer>
<layer id="3" name="key" width="10" height="10" locked="1">
<data encoding="base64" compression="zlib">
eJxjYKAPsKSTPUMdAABDeAA6
</data>
</layer>
<layer id="5" name="player" width="10" height="10" locked="1">
<data encoding="base64" compression="zlib">
eJxjYKA+8KWBmSMFAABgnABO
</data>
</layer>
</map>
29 changes: 29 additions & 0 deletions assets/tilemaps/tutorial_movement.tmx
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<map version="1.10" tiledversion="1.10.0" orientation="orthogonal" renderorder="right-down" width="15" height="15" tilewidth="32" tileheight="32" infinite="0" nextlayerid="7" nextobjectid="1">
<tileset firstgid="1" source="sprites.tsx"/>
<layer id="2" name="floor" width="15" height="15" locked="1">
<data encoding="base64" compression="zlib">
eJxjYKAMCJKBR/WO6h1seoWooJdcAADifQte
</data>
</layer>
<layer id="1" name="wall" width="15" height="15" locked="1">
<data encoding="base64" compression="zlib">
eJxjZGBgYCQT8zGQB/iooBebe8i1lxi30EIvMsAXxoT04pKntl5i45/U+OVDYw+EXmx8UvWSm48AeZUCCQ==
</data>
</layer>
<layer id="5" name="objects" width="15" height="15" locked="1">
<data encoding="base64" compression="zlib">
eJxjYBi8QJRK5ghTyZxRMApoAQBybAAp
</data>
</layer>
<layer id="6" name="help" width="15" height="15" locked="1">
<data encoding="base64" compression="zlib">
eJxjYKAcCBHgjwLqAELhLIRHbigCQn6glh8HOqwAHRsAow==
</data>
</layer>
<layer id="3" name="player" width="15" height="15" locked="1">
<data encoding="base64" compression="zlib">
eJxjYKAM8FKofxSMgpEOAC34AA4=
</data>
</layer>
</map>
27 changes: 24 additions & 3 deletions game/entities/player.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,53 @@
import math
import arcade

from pyglet.math import Vec2

import assets
from game.entities import Entity
from game.views.inventory import Inventory


class Player(Entity):
def __init__(self, game_view):
super().__init__("mc_idle.png")
super().__init__("mc_walk0.png")
self.scale = 0.5
self.center_x, self.center_y = Vec2(0, 0)
self.angle = -90
self.normal_speed = 4.0
self.speed = self.normal_speed
self.game_view = game_view
self.inventory = Inventory()
self.enemy_touch_count = 0
self.holding_item = None

def update_animation(self, delta_time: float = 1 / 60):
pass
self.walk_textures = []
for i in range(4):
texture = arcade.load_texture(assets.sprites.resolve(f"mc_walk{i}.png"))
self.walk_textures.append(texture)

def update_animation(self, delta_time: float = 1 / 60, delta_pos=Vec2(0, 0)):
if delta_pos.x == 0 and delta_pos.y == 0:
self.texture = self.idle_texture
return

# Walking animation
self.cur_texture += 1
if self.cur_texture >= 4 * 8:
self.cur_texture = 0
frame = self.cur_texture // 8
self.texture = self.walk_textures[frame]

def move(self, delta_pos: Vec2, mouse_pos: Vec2):
direction = mouse_pos - self.get_position()
if direction.mag != 0:
direction = direction.normalize()
self.angle = math.degrees(direction.heading)
if delta_pos.mag > 1:
delta_pos = delta_pos * Vec2(0.707, 0.707)
self.center_x += delta_pos.x * self.speed
self.center_y += delta_pos.y * self.speed
self.update_animation(1 / 60, delta_pos)

def update_player(self):
nearest_item, nearest_dist = None, 99999
Expand Down
33 changes: 25 additions & 8 deletions game/views/game_view.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from game.entities.enemy import Enemy
from game.sounds import change_music
from game.views import change_views, return_to_view
from game.views.inventory import Item, get_inventory_ui
from game.views.inventory import Item, Door, get_inventory_ui

arcade.enable_timings()

Expand All @@ -25,6 +25,7 @@ def __init__(self, level):
self.floor = None
self.objects = None
self.pickables = None
self.doors = None
self.player = None
self.physics_engine = None
self.start_time = None
Expand Down Expand Up @@ -74,13 +75,28 @@ def select_level(self, level: int = 1):
self.floor = level_map.sprite_lists["floor"]
self.walls = level_map.sprite_lists["walls"]
self.objects = level_map.sprite_lists["objects"]
self.doors = arcade.SpriteList(use_spatial_hash=True)
self.pickables = arcade.SpriteList(use_spatial_hash=True)

if level_map.sprite_lists.get("pickables") is not None:
for item in level_map.sprite_lists["pickables"]:
self.pickables.append(
Item(item.properties["file"], Vec2(*item.position), item.angle)
for item in level_map.sprite_lists["pickables"]:
self.pickables.append(
Item(
item.properties["file"],
Vec2(*item.position),
item.angle,
name_color=item.properties.get("name_color"),
)
)

for door in level_map.sprite_lists["doors"]:
self.doors.append(
Door(
door.properties["file"],
Vec2(*door.position),
door.angle,
name_color=door.properties["name_color"],
)
)

# Set up the player
self.player = Player(self)
Expand Down Expand Up @@ -249,6 +265,7 @@ def on_draw(self):
self.scene_camera.use()
if self.floor is not None:
self.floor.draw()
self.doors.draw()
self.walls.draw()
if self.objects is not None:
self.objects.draw()
Expand All @@ -257,9 +274,9 @@ def on_draw(self):
self.enemies.draw()

# TODO: remove from final, for debug
if self.enemies[0].arrows:
for i in self.enemies[0].arrows:
i.draw_hit_box()
# if self.enemies[0].arrows:
# for i in self.enemies[0].arrows:
# i.draw_hit_box()

self.player.draw()

Expand Down
Loading