diff --git a/src/main.lua b/src/main.lua index c53f87e..672eb54 100644 --- a/src/main.lua +++ b/src/main.lua @@ -1,17 +1,12 @@ -require("pokemon.lua") -require("textbox.lua") require("game.lua") function _init() - cls(0) - states = {} states["start_menu"] = start_menu() states["pick_player"] = pick_state(false, "pick_player", "pick_enemy") states["pick_enemy"] = pick_state(true, "pick_enemy", "appear_enemy") states["appear_enemy"] = appear_enemy() states["appear_player"] = appear_player() - -- states["player_turn"] = new_state("player_turn") gm = new_game("start_menu") states[gm.state].init(gm) diff --git a/src/menu.lua b/src/menu.lua index 1ee44f9..edb01b9 100644 --- a/src/menu.lua +++ b/src/menu.lua @@ -1,7 +1,9 @@ --- Constructor +-- Constants cursor_spr = 207 +-- Constructor + function new_menu(x, y, w, h, options) return { x = x, diff --git a/src/pokemon.lua b/src/pokemon.lua index bde0f86..6cc3a56 100644 --- a/src/pokemon.lua +++ b/src/pokemon.lua @@ -1,16 +1,11 @@ -- Constructor function new_pokemon(name, enemy, front_sprite, back_sprite, cry) - enemy_x = 78 - enemy_y = 8 - player_x = 12 - player_y = 56 - - p_x = player_x - p_y = player_y + p_x = 12 + p_y = 56 if enemy then - p_x = enemy_x - p_y = enemy_y + p_x = 78 + p_y = 8 end return { @@ -19,7 +14,6 @@ function new_pokemon(name, enemy, front_sprite, back_sprite, cry) front_sprite = front_sprite, back_sprite = back_sprite, cry = cry, - -- moves = moves, x = p_x, y = p_y, @@ -38,6 +32,10 @@ function appear(p) p.appeared = true end +function cry(p) + sfx(p.cry) +end + function draw_p(p) if p.enemy then draw_front(p) @@ -54,8 +52,16 @@ function draw_back(p) draw_p_spr(p.back_sprite, p.x, p.y) end -function cry(p) - sfx(p.cry) +function draw_p_spr(start, x, y) + for i=0,3 do + tile_row = 16 * i + spr_row = 8 * i + for k=0,3 do + spr_column = 8 * k + tile = start + tile_row + k + spr(tile, x+spr_column, y+spr_row) + end + end end --Pokemon @@ -76,17 +82,3 @@ function axoleafel(enemy) -- {} ) end - --- Functions - -function draw_p_spr(start, x, y) - for i=0,3 do - tile_row = 16 * i - spr_row = 8 * i - for k=0,3 do - spr_column = 8 * k - tile = start + tile_row + k - spr(tile, x+spr_column, y+spr_row) - end - end -end