- [NEW] draw_shiny_rect()
- [WIP] Menú d'opcions
This commit is contained in:
@@ -1,3 +1,80 @@
|
||||
local shine_step = 1
|
||||
local shine_wait = 0
|
||||
local shine_pos = 0
|
||||
|
||||
function draw_shiny_rect(x, y, w, h, color, shine_color)
|
||||
draw.rect(x,y,w,h,color)
|
||||
|
||||
local shine_w= 18
|
||||
|
||||
-- Convertir el rectangle en una linea en checkpoints
|
||||
local p0 = 0
|
||||
local p1 = p0+w-1
|
||||
local p2 = p1+h
|
||||
local p3 = p2+w
|
||||
local p4 = p3+h
|
||||
|
||||
-- Punt inicial y final de la recta del brillo
|
||||
local s0 = shine_step
|
||||
local s1 = s0+shine_w
|
||||
local y0 = 0
|
||||
|
||||
if s0==p4 then
|
||||
shine_step=0
|
||||
draw.line(x, y, x+shine_w, y, shine_color)
|
||||
elseif s0<p1 then
|
||||
if s1<p1 then
|
||||
draw.line(x+s0, y, x+s1, y, shine_color)
|
||||
elseif s1<p2 then
|
||||
segment = s1-p1
|
||||
draw.line(x+s0, y, x+w-1, y, shine_color)
|
||||
draw.line(x+w-1, y, x+w-1, y+segment, shine_color)
|
||||
end
|
||||
elseif s0<p2 then
|
||||
if s1<p2 then
|
||||
segment = shine_w
|
||||
x0 = x+w-1
|
||||
y0= y+(s0-p1)-1
|
||||
draw.line(x0, y0, x0, y0+segment, shine_color)
|
||||
elseif s1<p3 then
|
||||
segment = s1-p2
|
||||
x0= x+w-1-segment
|
||||
y0= y+h-1
|
||||
draw.line(x0, y0, x0+segment, y0, shine_color)
|
||||
segment = p2-s0-1
|
||||
x0= x+w-1
|
||||
y0= y+(s0-p1)
|
||||
draw.line(x0, y0, x0, y0+segment, shine_color)
|
||||
end
|
||||
elseif s0<p3 then
|
||||
if s1<p3 then
|
||||
segment=shine_w
|
||||
x0 = x+w-1-(s1-p2)
|
||||
y0 = y+h-1
|
||||
draw.line(x0, y0, x0+shine_w, y0, shine_color)
|
||||
elseif s1<p4 then
|
||||
segment = s1-p3
|
||||
y0 = y+h-1
|
||||
draw.line(x,y0,x,y0-segment,shine_color)
|
||||
segment = p3-s0
|
||||
y0 = y+h-1
|
||||
draw.line(x,y0,x+segment,y0,shine_color)
|
||||
end
|
||||
elseif s0<p4 then
|
||||
if s1<p4 then
|
||||
segment = shine_w
|
||||
y0 = y+p4-s1
|
||||
draw.line(x,y0,x,y0+segment,shine_color)
|
||||
else
|
||||
segment = s1-p4
|
||||
draw.line(x,y,x+segment,y,shine_color)
|
||||
segment = p4-s0
|
||||
draw.line(x,y,x,y+segment,shine_color)
|
||||
end
|
||||
end
|
||||
shine_step = shine_step+1
|
||||
end
|
||||
|
||||
function arc_text(str, x, y, col)
|
||||
font.current(font_sf)
|
||||
draw.text(str,x,y,col)
|
||||
|
||||
@@ -12,6 +12,7 @@ require "intro"
|
||||
require "scenes"
|
||||
require "title"
|
||||
require "game"
|
||||
require "opcions"
|
||||
|
||||
--require "fps"
|
||||
--require "title"
|
||||
@@ -103,10 +104,11 @@ function mini.init()
|
||||
logo_config(font_sf)
|
||||
surf.target(0)
|
||||
surf.cls(16)
|
||||
flow:add("logo", logo_init)
|
||||
flow:add("intro", intro_init)
|
||||
flow:add("logo", logo_init)
|
||||
flow:add("intro", intro_init)
|
||||
flow:add("title", title_init)
|
||||
flow:add("game", game_init)
|
||||
flow:add("opcions", opcions_init)
|
||||
-- flow:add("ending", ending_init)
|
||||
-- flow:add("credits", credits_init)
|
||||
flow:add_path( { logo_init, intro_init, title_init, game_init } )
|
||||
|
||||
61
data/opcions.lua
Normal file
61
data/opcions.lua
Normal file
@@ -0,0 +1,61 @@
|
||||
local menu_sel = 0
|
||||
|
||||
function opcions_init()
|
||||
flow:add_path({opcions_show, opcions_end})
|
||||
flow:next()
|
||||
end
|
||||
|
||||
function opcions_draw()
|
||||
surf.cls(16)
|
||||
draw_shiny_rect(56,(56+(20*menu_sel)),146,18,14,15)
|
||||
-- if (not parpadeig) then draw.rect(28*o2aX,(28+(10*menu_sel))*o2aX,73*o2aX,9*o2aX,13) end
|
||||
|
||||
arc_text("MÚSICA", 60, 60, 14); arc_text(music.enabled() and "SI" or "NO",91*o2aX,30*o2aX,15)
|
||||
arc_text("SÓ", 60, 80, 14); arc_text(sound.enabled() and "SI" or "NO",91*o2aX,40*o2aX,15)
|
||||
arc_text("REDEFINIR TECLAT", 60, 100, 14)
|
||||
arc_text("REDEFINIR GAMEPAD", 60, 120, 14)
|
||||
arc_text("TORNAR", 60, 140, 14)
|
||||
end
|
||||
|
||||
function opcions_update()
|
||||
if key.press(keyShoot) or key.press(key.SPACE) or pad.press(pad.A) or pad.press(btnShoot) then
|
||||
if menu_sel==0 then
|
||||
music.enabled(not music.enabled())
|
||||
if music.enabled() then music.play(audio_main_song) end
|
||||
elseif menu_sel==1 then
|
||||
sound.enabled(not sound.enabled())
|
||||
elseif menu_sel==2 then
|
||||
menu_count=0
|
||||
menu_state=update_redefine_keys_menu
|
||||
elseif menu_sel==3 then
|
||||
menu_count=0
|
||||
menu_state=update_redefine_pad_menu
|
||||
else
|
||||
-- menu_count=0
|
||||
-- menu_sel=0
|
||||
-- menu_state=update_main_menu
|
||||
flow:next()
|
||||
end
|
||||
elseif key.press(keyDown) or key.press(key.DOWN) or pad.press(pad.DOWN) or pad.press(btnDown) then
|
||||
menu_sel=menu_sel+1
|
||||
if menu_sel==5 then menu_sel=0 end
|
||||
elseif key.press(keyUp) or key.press(key.UP) or pad.press(pad.UP) or pad.press(btnUp) then
|
||||
menu_sel=menu_sel-1
|
||||
if menu_sel==-1 then menu_sel=4 end
|
||||
elseif key.press(key.ESCAPE) or pad.press(btnPause) then
|
||||
-- menu_count=0
|
||||
-- menu_sel=0
|
||||
-- menu_state=update_main_menu
|
||||
flow:next()
|
||||
end
|
||||
end
|
||||
|
||||
function opcions_show()
|
||||
opcions_draw()
|
||||
opcions_update()
|
||||
end
|
||||
|
||||
function opcions_end()
|
||||
print("opcions_end")
|
||||
flow:restore()
|
||||
end
|
||||
@@ -26,6 +26,9 @@ local cycle_step = 1
|
||||
|
||||
local menu_sel = 0
|
||||
|
||||
local rect_wait = 0
|
||||
|
||||
|
||||
function title_init()
|
||||
title_sf=surf.load("title_tiles.gif")
|
||||
surf.source(title_sf)
|
||||
@@ -133,7 +136,7 @@ function title_end()
|
||||
end
|
||||
|
||||
function title_menu_draw()
|
||||
draw.rect(56,120+(20*menu_sel)-4,146,18,14)
|
||||
draw_shiny_rect(56,120+(20*menu_sel)-4,146,18,14,15)
|
||||
arc_text("JUGAR", 108, 120, 14)
|
||||
arc_text("OPCIONS", 102, 140, 14)
|
||||
end
|
||||
@@ -160,4 +163,5 @@ end
|
||||
|
||||
function to_options()
|
||||
print("to options")
|
||||
flow:call("opcions")
|
||||
end
|
||||
Reference in New Issue
Block a user