boot splash
This commit is contained in:
28
game.lua
28
game.lua
@@ -18,9 +18,10 @@ COLOR_GREEN = 6
|
|||||||
COLOR_NPC = 8
|
COLOR_NPC = 8
|
||||||
|
|
||||||
-- Game state
|
-- Game state
|
||||||
STATE_MENU = 0
|
STATE_SPLASH = 0
|
||||||
STATE_GAME = 1
|
STATE_MENU = 1
|
||||||
STATE_DIALOG = 2
|
STATE_GAME = 2
|
||||||
|
STATE_DIALOG = 3
|
||||||
|
|
||||||
-- Player constants
|
-- Player constants
|
||||||
PLAYER_WIDTH = 8
|
PLAYER_WIDTH = 8
|
||||||
@@ -41,9 +42,10 @@ MOVE_SPEED = 1.5
|
|||||||
MAX_JUMPS = 2
|
MAX_JUMPS = 2
|
||||||
|
|
||||||
-- Global variables (initialized)
|
-- Global variables (initialized)
|
||||||
gameState = STATE_MENU
|
gameState = STATE_SPLASH
|
||||||
currentScreen = 1
|
currentScreen = 1
|
||||||
dialog_text = ""
|
dialog_text = ""
|
||||||
|
splash_timer = 120 -- 2 seconds at 60fps
|
||||||
|
|
||||||
-- Player properties
|
-- Player properties
|
||||||
player = {
|
player = {
|
||||||
@@ -68,6 +70,19 @@ ground = {
|
|||||||
menuItems = {"Play", "Exit"}
|
menuItems = {"Play", "Exit"}
|
||||||
selectedMenuItem = 1
|
selectedMenuItem = 1
|
||||||
|
|
||||||
|
function draw_splash()
|
||||||
|
cls(COLOR_BLACK)
|
||||||
|
print("Mr. Anderson's", 78, 60, COLOR_LIGHT_GREY)
|
||||||
|
print("Addventure", 90, 70, COLOR_LIGHT_GREY)
|
||||||
|
end
|
||||||
|
|
||||||
|
function update_splash()
|
||||||
|
splash_timer = splash_timer - 1
|
||||||
|
if splash_timer <= 0 then
|
||||||
|
gameState = STATE_MENU
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function draw_top_bar(title)
|
function draw_top_bar(title)
|
||||||
rect(0, 0, SCREEN_WIDTH, 10, COLOR_BLACK)
|
rect(0, 0, SCREEN_WIDTH, 10, COLOR_BLACK)
|
||||||
print(title, 3, 2, COLOR_LIGHT_GREY)
|
print(title, 3, 2, COLOR_LIGHT_GREY)
|
||||||
@@ -256,7 +271,10 @@ function update_dialog()
|
|||||||
end
|
end
|
||||||
|
|
||||||
function TIC()
|
function TIC()
|
||||||
if gameState == STATE_MENU then
|
if gameState == STATE_SPLASH then
|
||||||
|
update_splash()
|
||||||
|
draw_splash()
|
||||||
|
elseif gameState == STATE_MENU then
|
||||||
update_menu()
|
update_menu()
|
||||||
draw_menu()
|
draw_menu()
|
||||||
elseif gameState == STATE_GAME then
|
elseif gameState == STATE_GAME then
|
||||||
|
|||||||
Reference in New Issue
Block a user