Folder restructure

master
GreenXenith 2020-02-24 18:20:51 -08:00
parent 928ad097a5
commit b52de108ad
25 changed files with 24 additions and 22 deletions

View File

Before

Width:  |  Height:  |  Size: 12 KiB

After

Width:  |  Height:  |  Size: 12 KiB

View File

Before

Width:  |  Height:  |  Size: 1.8 KiB

After

Width:  |  Height:  |  Size: 1.8 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.1 KiB

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.3 KiB

After

Width:  |  Height:  |  Size: 1.3 KiB

View File

Before

Width:  |  Height:  |  Size: 1.2 KiB

After

Width:  |  Height:  |  Size: 1.2 KiB

0
src/__init__.py Normal file
View File

View File

@ -4,7 +4,7 @@ global assets
assets = {}
def load(filename):
assets[filename] = pygame.image.load("textures/" + filename)
assets[filename] = pygame.image.load("assets/" + filename)
return assets[filename]
def get(filename):

View File

@ -1,8 +1,9 @@
import pygame
import os
import sys
import assets
import spritesheet
from . import assets, controller, spritesheet
from .map import Map
from .player import Player
# Constants
SCALE = 4
@ -20,18 +21,16 @@ winsize = [800, 600]
screen = pygame.display.set_mode(winsize) #, pygame.RESIZABLE)
# Load all assets
for filename in os.listdir(os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), "textures")):
for filename in os.listdir(os.path.join(os.path.dirname(os.path.realpath(sys.argv[0])), "assets")):
assets.load(filename)
# Map
from map import Map
map = Map(METER)
map.load("map.json")
import controller
from player import Player
# Player
player = Player()
player.sprite.texture = spritesheet.SpriteSheet("textures/character.png", 16, 24)
player.sprite.texture = spritesheet.SpriteSheet(assets.get("character.png"), 16, 24)
player.sprite.set_rect((0, 0, 16, 24))
# TODO: Use asset loader for spritesheets
player.sprite.texture.set_animation(0, 0, 0)

View File

@ -1,8 +1,8 @@
import assets
import json
import pygame
from math import floor
from vector import Vector
from . import assets
from .vector import Vector
class Map:
map = []

View File

@ -1,8 +1,8 @@
import pygame
import controller
import math
from vector import *
from sprite import Sprite
from . import controller
from .vector import *
from .sprite import Sprite
class Player:
pos = Vector(0, 0)

View File

@ -1,6 +1,5 @@
import pygame
import assets
from vector import *
from . import assets
class Sprite:
texture = None

View File

@ -18,15 +18,13 @@ class SpriteSheet():
frame_index = None
frame = None
def __init__(self, filename, frameWidth, frameHeight = None):
self.file = filename
def __init__(self, texture, frameWidth, frameHeight = None):
self.file = texture
frameHeight = frameHeight or frameWidth
img = pygame.image.load(filename)
width = img.get_width()
height = img.get_height()
width = texture.get_width()
height = texture.get_height()
xframes = math.floor(width / frameWidth)
yframes = math.floor(height / frameHeight)
@ -37,7 +35,7 @@ class SpriteSheet():
y = 0
for _ in range(total):
surface = pygame.Surface((frameWidth, frameHeight), pygame.SRCALPHA, 32)
surface.blit(img, (0, 0), (frameWidth * x, frameHeight * y, width, height))
surface.blit(texture, (0, 0), (frameWidth * x, frameHeight * y, width, height))
self.frames.append(surface.copy())
x = (x + 1) % xframes

6
zoria.py Normal file
View File

@ -0,0 +1,6 @@
"""
Zoria - A Dungeon Crawler
"""
if __name__ == "__main__":
import src.game