diff --git a/res/sprite/overworld_sheet.png b/res/sprite/overworld_sheet.png index b76a9c0..ea99e08 100644 Binary files a/res/sprite/overworld_sheet.png and b/res/sprite/overworld_sheet.png differ diff --git a/src/gamestates/none.py b/src/gamestates/none.py index 40e834a..8bb4861 100644 --- a/src/gamestates/none.py +++ b/src/gamestates/none.py @@ -2,4 +2,4 @@ import gamestate # Azért létezik ez a "none" gamestate hogy meghívja az elsö gamestate init() funkcióját def update(game, dt): - gamestate.switch_gamestate(game, "title") + gamestate.switch_gamestate(game, "overworld") diff --git a/src/gamestates/overworld.py b/src/gamestates/overworld.py index 50c1d3d..2f867b8 100644 --- a/src/gamestates/overworld.py +++ b/src/gamestates/overworld.py @@ -19,14 +19,18 @@ OVERWORLD_LB_X = 0 OVERWORLD_LB_Y = 0 OVERWORLD_TILE_WIDTH = 16 OVERWORLD_TILE_HEIGHT = 16 +OVERWORLD_WIDTH = 4 +OVERWORLD_HEIGHT = 4 OVERWORLD_MAP = [ - [1,0,0,0], - [1,0,1,0], - [0,1,0,0], - [0,0,0,0], + [5,3,3,6], + [1,0,0,2], + [1,0,0,2], + [7,4,4,8], ] -class BalthasarController: +WALK_SPEED = 32 + +class BalthasarRenderer: def __init__(self): self.direction = DIR_UP self.walking = False @@ -60,13 +64,19 @@ class BalthasarController: class OverworldMap: def __init__(self): self.sprites = [] + + self.scroll_x = 0 + self.scroll_y = 0 x = 0 y = len(OVERWORLD_MAP) for row in OVERWORLD_MAP: for tile in row: self.sprites.append([ - assets.sprites["overworld"].get_texture(arcade.LBWH((tile % 16) * 16, (tile // 16) * 12, OVERWORLD_TILE_WIDTH, OVERWORLD_TILE_HEIGHT)), + assets.sprites["overworld"].get_texture( + arcade.LBWH((tile % 4) * OVERWORLD_TILE_WIDTH, (tile // 4) * OVERWORLD_TILE_HEIGHT, + OVERWORLD_TILE_WIDTH, OVERWORLD_TILE_HEIGHT) + ), arcade.LBWH( (x * OVERWORLD_TILE_WIDTH), (y * OVERWORLD_TILE_HEIGHT), @@ -84,45 +94,48 @@ class OverworldMap: arcade.draw_texture_rect( s[0], s[1].move( - (game.screen_width / 2), - (game.screen_height / 2) + self.scroll_x + (game.screen_width / 2) - ((OVERWORLD_WIDTH * OVERWORLD_TILE_WIDTH) / 2), + self.scroll_y + (game.screen_height / 2) - ((OVERWORLD_HEIGHT * OVERWORLD_TILE_HEIGHT) / 2) ), pixelated=True ) -controller = BalthasarController() +balthasar = BalthasarRenderer() overworld = OverworldMap() def switch(game): pass def update(game, dt): - controller.update() + balthasar.update() if controls.is_control_pressed(0): # Fel - controller.set_direction(DIR_UP) + balthasar.set_direction(DIR_UP) elif controls.is_control_pressed(1): # Le - controller.set_direction(DIR_DOWN) + balthasar.set_direction(DIR_DOWN) elif controls.is_control_pressed(2): # Bal - controller.set_direction(DIR_LEFT) + balthasar.set_direction(DIR_LEFT) elif controls.is_control_pressed(3): # Jobb - controller.set_direction(DIR_RIGHT) + balthasar.set_direction(DIR_RIGHT) + + walking = False if controls.is_control_held(0): # Fel - - controller.set_walking(True) + overworld.scroll_y -= WALK_SPEED * dt + walking = True elif controls.is_control_held(1): # Le - - controller.set_walking(True) - elif controls.is_control_held(2): # Bal - - controller.set_walking(True) + overworld.scroll_y += WALK_SPEED * dt + walking = True + + if controls.is_control_held(2): # Bal + overworld.scroll_x += WALK_SPEED * dt + walking = True elif controls.is_control_held(3): # Jobb - - controller.set_walking(True) - else: - controller.set_walking(False) + overworld.scroll_x -= WALK_SPEED * dt + walking = True + + balthasar.set_walking(walking) def draw(game): - controller.render(game) - overworld.render(game) \ No newline at end of file + overworld.render(game) + balthasar.render(game)