Updated games with mouse and touch support

This commit is contained in:
Andre Leiradella 2018-03-29 21:30:06 +01:00
parent 9962b03120
commit 6b9eeb87f9
6 changed files with 393 additions and 218 deletions

View File

@ -1,35 +1,8 @@
local unit1 = system.loadunit 'unit1'
local forms = system.loadunit 'forms'
local controls = system.loadunit 'controls'
local keymap = {
up = { forms.vk_left, forms.vk_up, 'Northwest' },
down = { forms.vk_left, forms.vk_down, 'Southwest' },
x = { forms.vk_right, forms.vk_up, 'Northeast' },
b = { forms.vk_right, forms.vk_down, 'Southeast' },
l1 = { 49, 'Game A' },
r1 = { 50, 'Game B' },
l2 = { 51, 'Time' },
r2 = { 53, 'ACL' }
}
local menu = {
{ unit1.form1.btn_game_a, 'Game A', 49 },
{ unit1.form1.btn_game_b, 'Game B', 50 },
{ unit1.form1.btn_time, 'Time', 51 },
{ unit1.form1.btn_acl, 'ACL', 53 }
}
local timers = {
unit1.form1.timerchance,
unit1.form1.timerclock,
unit1.form1.timerenemy,
unit1.form1.timergameover,
unit1.form1.timermisslong,
unit1.form1.timermissshort,
unit1.form1.timerpoint,
unit1.form1.timership,
unit1.form1.timershowmiss
}
unit1.form1.oncreate()
unit1.apfbeeps[ 1 ].data = system.loadbin( 'Move_Nw.pcm' )
unit1.apfbeeps[ 2 ].data = system.loadbin( 'Move_Ne.pcm' )
@ -39,18 +12,85 @@ unit1.pfgameover.data = system.loadbin( 'Gameover.pcm' )
unit1.pfmiss.data = system.loadbin( 'Miss.pcm' )
unit1.pfpoint.data = system.loadbin( 'Point.pcm' )
unit1.form1.oncreate()
unit1.bsound = true
unit1.imode = 1
unit1.form1.gam_set_mode()
return system.init(
unit1.form1.im_background,
keymap,
function( key ) unit1.form1.onkeydown( nil, key, 0 ) end,
function( key ) unit1.form1.onkeyup( nil, key, 0 ) end,
timers,
{ 175, 95, 305, 199 },
menu
)
local zoom = { left = 175, top = 95, width = 305, height = 199 }
local left, right = system.splith( zoom )
local nw, sw = system.splitv( left )
local ne, se = system.splitv( right )
return system.init{
background = unit1.form1.im_background,
zoom = zoom,
controls = {
{
button = unit1.form1.btn_game_a_top,
label = 'Game A'
},
{
button = unit1.form1.btn_game_b_top,
label = 'Game B'
},
{
button = unit1.form1.btn_time_top,
label = 'Time'
},
{
button = unit1.form1.btn_acl_top,
label = 'ACL'
},
{
button = unit1.form1.btn_1_nw_top,
zone = nw,
label = 'Northwest',
keys = { up = true },
xkeys = { forms.vk_up, forms.vk_left }
},
{
button = unit1.form1.btn_3_sw_top,
zone = sw,
label = 'Southwest',
keys = { down = true },
xkeys = { forms.vk_down, forms.vk_left }
},
{
button = unit1.form1.btn_2_ne_top,
zone = ne,
label = 'Northeast',
keys = { x = true },
xkeys = { forms.vk_up, forms.vk_right }
},
{
button = unit1.form1.btn_4_se_top,
zone = se,
label = 'Southeast',
keys = { b = true },
xkeys = { forms.vk_down, forms.vk_right }
}
},
timers = {
unit1.form1.timerchance,
unit1.form1.timerclock,
unit1.form1.timerenemy,
unit1.form1.timergameover,
unit1.form1.timermisslong,
unit1.form1.timermissshort,
unit1.form1.timerpoint,
unit1.form1.timership,
unit1.form1.timershowmiss
},
onkey = function( key, pressed )
local handler = pressed and unit1.form1.onkeydown or unit1.form1.onkeyup
handler( nil, key, 0 )
end,
onbutton = function( button, pressed )
local handler = pressed and button.onmousedown or button.onmouseup
handler( nil, controls.mbleft, false, 0, 0 )
end
}

View File

@ -1,35 +1,8 @@
local unit1 = system.loadunit 'unit1'
local forms = system.loadunit 'forms'
local controls = system.loadunit 'controls'
local keymap = {
up = { forms.vk_left, forms.vk_up, 'Northwest' },
down = { forms.vk_left, forms.vk_down, 'Southwest' },
x = { forms.vk_right, forms.vk_up, 'Northeast' },
b = { forms.vk_right, forms.vk_down, 'Southeast' },
l1 = { 49, 'Game A' },
r1 = { 50, 'Game B' },
l2 = { 51, 'Time' },
r2 = { 53, 'ACL' }
}
local menu = {
{ unit1.form1.btn_game_a, 'Game A', 49 },
{ unit1.form1.btn_game_b, 'Game B', 50 },
{ unit1.form1.btn_time, 'Time', 51 },
{ unit1.form1.btn_acl, 'ACL', 53 }
}
local timers = {
unit1.form1.timerchance,
unit1.form1.timerclock,
unit1.form1.timerenemy,
unit1.form1.timergameover,
unit1.form1.timermisslong,
unit1.form1.timermissshort,
unit1.form1.timerpoint,
unit1.form1.timership,
unit1.form1.timershowmiss
}
unit1.form1.oncreate()
unit1.apfbeeps[ 1 ].data = system.loadbin( 'Move_Nw.pcm' )
unit1.apfbeeps[ 2 ].data = system.loadbin( 'Move_Ne.pcm' )
@ -39,18 +12,85 @@ unit1.pfgameover.data = system.loadbin( 'Gameover.pcm' )
unit1.pfmiss.data = system.loadbin( 'Miss.pcm' )
unit1.pfpoint.data = system.loadbin( 'Point.pcm' )
unit1.form1.oncreate()
unit1.bsound = true
unit1.imode = 1
unit1.form1.gam_set_mode()
return system.init(
unit1.form1.im_background,
keymap,
function( key ) unit1.form1.onkeydown( nil, key, 0 ) end,
function( key ) unit1.form1.onkeyup( nil, key, 0 ) end,
timers,
{ 175, 96, 305, 207 },
menu
)
local zoom = { left = 175, top = 96, width = 305, height = 207 }
local left, right = system.splith( zoom )
local nw, sw = system.splitv( left )
local ne, se = system.splitv( right )
return system.init{
background = unit1.form1.im_background,
zoom = zoom,
controls = {
{
button = unit1.form1.btn_game_a_top,
label = 'Game A'
},
{
button = unit1.form1.btn_game_b_top,
label = 'Game B'
},
{
button = unit1.form1.btn_time_top,
label = 'Time'
},
{
button = unit1.form1.btn_acl_top,
label = 'ACL'
},
{
button = unit1.form1.btn_1_nw_top,
zone = nw,
label = 'Northwest',
keys = { up = true },
xkeys = { forms.vk_up, forms.vk_left }
},
{
button = unit1.form1.btn_3_sw_top,
zone = sw,
label = 'Southwest',
keys = { down = true },
xkeys = { forms.vk_down, forms.vk_left }
},
{
button = unit1.form1.btn_2_ne_top,
zone = ne,
label = 'Northeast',
keys = { x = true },
xkeys = { forms.vk_up, forms.vk_right }
},
{
button = unit1.form1.btn_4_se_top,
zone = se,
label = 'Southeast',
keys = { b = true },
xkeys = { forms.vk_down, forms.vk_right }
}
},
timers = {
unit1.form1.timerchance,
unit1.form1.timerclock,
unit1.form1.timerenemy,
unit1.form1.timergameover,
unit1.form1.timermisslong,
unit1.form1.timermissshort,
unit1.form1.timerpoint,
unit1.form1.timership,
unit1.form1.timershowmiss
},
onkey = function( key, pressed )
local handler = pressed and unit1.form1.onkeydown or unit1.form1.onkeyup
handler( nil, key, 0 )
end,
onbutton = function( button, pressed )
local handler = pressed and button.onmousedown or button.onmouseup
handler( nil, controls.mbleft, false, 0, 0 )
end
}

View File

@ -1,34 +1,8 @@
local unit1 = system.loadunit 'unit1'
local forms = system.loadunit 'forms'
local controls = system.loadunit 'controls'
local keymap = {
left = { forms.vk_left, 'Left' },
right = { forms.vk_right, 'Right' },
a = { forms.vk_right, 'Right' },
l1 = { 49, 'Game A' },
r1 = { 50, 'Game B' },
l2 = { 51, 'Time' },
r2 = { 53, 'Light' }
}
local menu = {
{ unit1.form1.btn_mode_down, 'Time', 51 },
{ unit1.form1.btn_game_a_down, 'Game A', 49 },
{ unit1.form1.btn_game_b_down, 'Game B', 50 },
{ unit1.form1.btn_light_down, 'Light', 53 }
}
local timers = {
unit1.form1.timerbonus,
unit1.form1.timerclock,
unit1.form1.timerdate,
unit1.form1.timergame,
unit1.form1.timergameover,
unit1.form1.timergamestart,
unit1.form1.timergot,
unit1.form1.timermiss,
unit1.form1.timerstartup
}
unit1.form1.oncreate()
unit1.pfgameover.data = system.loadbin( 'Gameover.pcm' )
unit1.pfgot.data = system.loadbin( 'Got.pcm' )
@ -36,20 +10,77 @@ unit1.pfmiss.data = system.loadbin( 'Miss.pcm' )
unit1.pfmove.data = system.loadbin( 'Move.pcm' )
unit1.pfstart.data = system.loadbin( 'Start.pcm' )
unit1.form1.oncreate()
unit1.form1.vid_showall( true )
unit1.bsound = true
unit1.imode = 0
unit1.form1.gam_setmode()
-- this game doesn't have a acl mode so we have to reblit all images
do
unit1.form1.vid_showall( true )
end
return system.init(
unit1.form1.im_background,
keymap,
function( key ) unit1.form1.onkeydown( nil, key, 0 ) end,
function( key ) unit1.form1.onkeyup( nil, key, 0 ) end,
timers,
{ 200, 99, 159, 207 },
menu
)
--unit1.imode = 0
--unit1.form1.gam_setmode()
local zoom = { left = 200, top = 99, width = 159, height = 207 }
local left, right = system.splith( zoom )
return system.init{
background = unit1.form1.im_background,
zoom = zoom,
controls = {
{
button = unit1.form1.btn_mode_top,
label = 'Time'
},
{
button = unit1.form1.btn_game_a_top,
label = 'Game A'
},
{
button = unit1.form1.btn_game_b_top,
label = 'Game B'
},
{
button = unit1.form1.btn_light_top,
label = 'Light'
},
{
button = unit1.form1.btn_left_down,
zone = left,
label = 'Left',
lbl_dy = 32,
keys = { left = true },
xkeys = { forms.vk_left }
},
{
button = unit1.form1.btn_right_down,
zone = right,
label = 'Right',
lbl_dy = 32,
keys = { right = true, a = true },
xkeys = { forms.vk_right }
}
},
timers = {
unit1.form1.timerbonus,
unit1.form1.timerclock,
unit1.form1.timerdate,
unit1.form1.timergame,
unit1.form1.timergameover,
unit1.form1.timergamestart,
unit1.form1.timergot,
unit1.form1.timermiss,
unit1.form1.timerstartup
},
onkey = function( key, pressed )
local handler = pressed and unit1.form1.onkeydown or unit1.form1.onkeyup
handler( nil, key, 0 )
end,
onbutton = function( button, pressed )
local handler = pressed and button.onmousedown or button.onmouseup
handler( nil, controls.mbleft, false, 0, 0 )
end
}

View File

@ -1,31 +1,8 @@
local unit1 = system.loadunit 'unit1'
local forms = system.loadunit 'forms'
local controls = system.loadunit 'controls'
local keymap = {
left = { forms.vk_left, 'Left' },
right = { forms.vk_right, 'Right' },
a = { forms.vk_right, 'Right' },
l1 = { 49, 'Game A' },
r1 = { 50, 'Game B' },
l2 = { 51, 'Time' }
}
local menu = {
{ unit1.form1.btn_game_a_down, 'Game A', 49 },
{ unit1.form1.btn_game_b_down, 'Game B', 50 },
{ unit1.form1.btn_mode_down, 'Time', 51 }
}
local timers = {
unit1.form1.timeralarm,
unit1.form1.timerclock,
unit1.form1.timerdate,
unit1.form1.timergame,
unit1.form1.timergameover,
unit1.form1.timergamestart,
unit1.form1.timermiss,
unit1.form1.timerpoint
}
unit1.form1.oncreate()
unit1.pfgameover.data = system.loadbin( 'Gameover.pcm' )
unit1.pfmiss.data = system.loadbin( 'Miss.pcm' )
@ -34,18 +11,68 @@ unit1.pfstart.data = system.loadbin( 'Start.pcm' )
unit1.apfmove[ 1 ].data = system.loadbin( 'Moveup.pcm' )
unit1.apfmove[ 2 ].data = system.loadbin( 'Movedown.pcm' )
unit1.form1.oncreate()
unit1.form1.vid_showall( true )
unit1.form1.vid_showscore( 8888, true )
unit1.bsound = true
return system.init(
unit1.form1.im_background,
keymap,
function( key ) unit1.form1.onkeydown( nil, key, 0 ) end,
function( key ) unit1.form1.onkeyup( nil, key, 0 ) end,
timers,
{ 153, 50, 259, 194 },
menu
)
-- this game doesn't have a acl mode so we have to reblit all images
do
unit1.form1.vid_showall( true )
unit1.form1.vid_showscore( 8888, true )
end
local zoom = { left = 153, top = 50, width = 259, height = 194 }
local left, right = system.splith( zoom )
return system.init{
background = unit1.form1.im_background,
zoom = zoom,
controls = {
{
button = unit1.form1.btn_game_a_top,
label = 'Game A'
},
{
button = unit1.form1.btn_game_b_top,
label = 'Game B'
},
{
button = unit1.form1.btn_mode_top,
label = 'Time'
},
{
button = unit1.form1.btn_left_down,
zone = left,
label = 'Left',
keys = { left = true },
xkeys = { forms.vk_left }
},
{
button = unit1.form1.btn_right_down,
zone = right,
label = 'Right',
keys = { right = true, a = true },
xkeys = { forms.vk_right }
}
},
timers = {
unit1.form1.timeralarm,
unit1.form1.timerclock,
unit1.form1.timerdate,
unit1.form1.timergame,
unit1.form1.timergameover,
unit1.form1.timergamestart,
unit1.form1.timermiss,
unit1.form1.timerpoint
},
onkey = function( key, pressed )
local handler = pressed and unit1.form1.onkeydown or unit1.form1.onkeyup
handler( nil, key, 0 )
end,
onbutton = function( button, pressed )
local handler = pressed and button.onmousedown or button.onmouseup
handler( nil, controls.mbleft, false, 0, 0 )
end
}

View File

@ -1,52 +1,8 @@
local unit1 = system.loadunit 'unit1'
local forms = system.loadunit 'forms'
local controls = system.loadunit 'controls'
local keymap = {
left = { forms.vk_left, 'Left' },
right = { forms.vk_right, 'Right' },
b = { forms.vk_control, 'Fire' },
l1 = { 49, 'Power' },
r1 = { 51, 'Start' },
l2 = { 50, 'Select' }
}
local menu = {
{ unit1.form1.btn_power_on, 'Power', 49 },
{ unit1.form1.btn_select_down, 'Select', 50 },
{ unit1.form1.btn_start_down, 'Start', 51 }
}
local timers = {
unit1.form1.timer_demo_1,
unit1.form1.timer_demo_2,
unit1.form1.timer_game_start,
unit1.form1.timer_game_over,
unit1.form1.timer_keypress,
unit1.form1.timer_phase123_player_fire,
unit1.form1.timer_phase123_miss,
unit1.form1.timer_phase123_enemy_fire,
unit1.form1.timer_phase1_enemy_row8,
unit1.form1.timer_phase1_enemy_row7,
unit1.form1.timer_phase1_enemy_attacking,
unit1.form1.timer_phase1_enemy_rows78_hit,
unit1.form1.timer_phase1_enemy_attacking_hit,
unit1.form1.timer_phase1_reprise,
unit1.form1.timer_phase1_complete,
unit1.form1.timer_phase2_enemy_attacking,
unit1.form1.timer_phase2_reprise,
unit1.form1.timer_phase2_enemy_attacking_hit,
unit1.form1.timer_phase2_complete,
unit1.form1.timer_phase3_mothership,
unit1.form1.timer_phase3_reprise,
unit1.form1.timer_phase3_mothership_hit,
unit1.form1.timer_phase3_complete,
unit1.form1.timer_phase4_shuttle_thrust,
unit1.form1.timer_phase4_shuttle_thrust_display,
unit1.form1.timer_phase4_shuttle_down,
unit1.form1.timer_phase4_dock,
unit1.form1.timer_phase4_miss_dock,
unit1.form1.timer_phase4_bonus
}
unit1.form1.oncreate()
unit1.pfs_bonus.data = system.loadbin( 'Bonus.pcm' )
unit1.pfs_complete.data = system.loadbin( 'Complete.pcm' )
@ -67,18 +23,95 @@ if system.GW_VERSION and system.GW_VERSION >= 0x010400 then
unit1.pfs_thrust.loop = true
end
unit1.form1.oncreate()
unit1.form1.im_background_screen.layer = 0;
unit1.bsound = true
return system.init(
unit1.form1.im_background,
keymap,
function( key ) unit1.form1.onkeydown( nil, key, 0 ) end,
function( key ) unit1.form1.onkeyup( nil, key, 0 ) end,
timers,
{ 216, 104, 93, 302 },
menu
)
local zoom = { left = 216, top = 104, width = 93, height = 302 }
local fire, bottom = system.splitv( zoom )
local left, right = system.splith( bottom )
return system.init{
background = unit1.form1.im_background,
zoom = zoom,
controls = {
{
button = unit1.form1.btn_power_top,
label = 'Power'
},
{
button = unit1.form1.btn_select_top,
label = 'Select'
},
{
button = unit1.form1.btn_start_top,
label = 'Start'
},
{
button = unit1.form1.btn_joystick_left,
zone = left,
label = 'Left',
keys = { left = true },
xkeys = { forms.vk_left }
},
{
button = unit1.form1.btn_joystick_right,
zone = right,
label = 'Right',
keys = { right = true, a = true },
xkeys = { forms.vk_right }
},
{
button = unit1.form1.btn_fire_top,
zone = fire,
label = 'Fire',
keys = { b = true },
xkeys = { forms.vk_control }
}
},
timers = {
unit1.form1.timer_demo_1,
unit1.form1.timer_demo_2,
unit1.form1.timer_game_start,
unit1.form1.timer_game_over,
unit1.form1.timer_keypress,
unit1.form1.timer_phase123_player_fire,
unit1.form1.timer_phase123_miss,
unit1.form1.timer_phase123_enemy_fire,
unit1.form1.timer_phase1_enemy_row8,
unit1.form1.timer_phase1_enemy_row7,
unit1.form1.timer_phase1_enemy_attacking,
unit1.form1.timer_phase1_enemy_rows78_hit,
unit1.form1.timer_phase1_enemy_attacking_hit,
unit1.form1.timer_phase1_reprise,
unit1.form1.timer_phase1_complete,
unit1.form1.timer_phase2_enemy_attacking,
unit1.form1.timer_phase2_reprise,
unit1.form1.timer_phase2_enemy_attacking_hit,
unit1.form1.timer_phase2_complete,
unit1.form1.timer_phase3_mothership,
unit1.form1.timer_phase3_reprise,
unit1.form1.timer_phase3_mothership_hit,
unit1.form1.timer_phase3_complete,
unit1.form1.timer_phase4_shuttle_thrust,
unit1.form1.timer_phase4_shuttle_thrust_display,
unit1.form1.timer_phase4_shuttle_down,
unit1.form1.timer_phase4_dock,
unit1.form1.timer_phase4_miss_dock,
unit1.form1.timer_phase4_bonus
},
onkey = function( key, pressed )
local handler = pressed and unit1.form1.onkeydown or unit1.form1.onkeyup
handler( nil, key, 0 )
end,
onbutton = function( button, pressed )
local handler = pressed and button.onmousedown or button.onmouseup
if handler then
handler( nil, controls.mbleft, false, 0, 0 )
end
end
}

View File

@ -38,6 +38,10 @@ unit1.pf_miss.data = system.loadbin( 'Miss.pcm' )
unit1.pf_shot.data = system.loadbin( 'Shot.pcm' )
unit1.pf_start.data = system.loadbin( 'Start.pcm' )
for i = 8, 9 do
unit1.rgamelevels[ i ].ienemyspeed = {}
end
unit1.form1.oncreate()
unit1.bsound = true