- Icon resource for Windows added

- Zoom and fullscreen controlled from Lua
- Basic gamepad support
This commit is contained in:
2023-01-20 19:14:59 +01:00
parent 0b2f30bac8
commit db9ce7898b
13 changed files with 75 additions and 65 deletions

1
bin/icon.rc Normal file
View File

@@ -0,0 +1 @@
id ICON "cacaus.ico"

BIN
bin/icon.res Normal file

Binary file not shown.

View File

@@ -81,13 +81,13 @@ function abad_state_normal()
end end
abad_make_safe() abad_make_safe()
if btn(KEY_RIGHT) then if btn(keyRight) or pad(btnRight) then
abad.update=abad_state_walking abad.update=abad_state_walking
abad.flip=false abad.flip=false
elseif btn(KEY_LEFT) then elseif btn(keyLeft) or pad(btnLeft) then
abad.update=abad_state_walking abad.update=abad_state_walking
abad.flip=true abad.flip=true
elseif btn(KEY_UP) then elseif btn(keyUp) or pad(btnUp) then
abad.update=abad_state_jumping abad.update=abad_state_jumping
abad.step=0 abad.step=0
abad.jumpfwd=false abad.jumpfwd=false
@@ -96,11 +96,11 @@ function abad_state_normal()
abad.jump=nil abad.jump=nil
end end
playsnd(audio_abad_jump) playsnd(audio_abad_jump)
elseif btn(KEY_DOWN) then elseif btn(keyDown) or pad(btnDown) then
abad.update=abad_state_crouch abad.update=abad_state_crouch
elseif btn(KEY_Z) then --elseif btn(KEY_Z) then
abad.respawning=240 -- abad.respawning=240
elseif btnp(KEY_SPACE) and cacau.hab==-1 then elseif btn(keyShoot) or pad(btnShoot) and cacau.hab==-1 then
playsnd(audio_abad_shot) playsnd(audio_abad_shot)
abad.update=abad_state_fire abad.update=abad_state_fire
abad.wait=0 abad.wait=0
@@ -116,7 +116,7 @@ function abad_state_crouch()
abad.step=0 abad.step=0
abad.jumpfwd=false abad.jumpfwd=false
if not btn(KEY_DOWN) then if not (btn(keyDown) or pad(btnDown)) then
abad.update=abad_state_normal abad.update=abad_state_normal
abad.bb.y=0 abad.bb.y=0
abad.bb.h=16 abad.bb.h=16
@@ -185,7 +185,7 @@ function abad_state_walking()
abad_make_safe() abad_make_safe()
if btn(KEY_UP) then if btn(keyUp) or pad(btnUp) then
abad.update=abad_state_jumping abad.update=abad_state_jumping
abad.step=0 abad.step=0
abad.jumpfwd=true abad.jumpfwd=true
@@ -195,18 +195,18 @@ function abad_state_walking()
end end
playsnd(audio_abad_jump) playsnd(audio_abad_jump)
return return
elseif btn(KEY_DOWN) then elseif btn(keyDown) or pad(btnDown) then
abad.update=abad_state_crouch abad.update=abad_state_crouch
elseif btn(KEY_SPACE) and cacau.hab==-1 then elseif btn(keyShoot) or pad(btnShoot) and cacau.hab==-1 then
playsnd(audio_abad_shot) playsnd(audio_abad_shot)
abad.update=abad_state_fire abad.update=abad_state_fire
abad.wait=0 abad.wait=0
cacau.init(abad.hab,abad.x+8,abad.y+8,abad.flip) cacau.init(abad.hab,abad.x+8,abad.y+8,abad.flip)
end end
if btn(KEY_RIGHT) then if btn(keyRight) or pad(btnRight) then
abad.flip=false abad.flip=false
elseif btn(KEY_LEFT) then elseif btn(keyLeft) or pad(btnLeft) then
abad.flip=true abad.flip=true
elseif abad.wait==0 then elseif abad.wait==0 then
abad.update=abad_state_normal abad.update=abad_state_normal
@@ -297,15 +297,15 @@ function abad_state_stairs()
if abad.wait==6 then if abad.wait==6 then
abad.wait=0 abad.wait=0
if btn(KEY_RIGHT) then if btn(keyRight) or pad(btnRight) then
abad.flip=false abad.flip=false
abad_advance() abad_advance()
playsnd(audio_low) playsnd(audio_low)
elseif btn(KEY_LEFT) then elseif btn(keyLeft) or pad(btnLeft) then
abad.flip=true abad.flip=true
abad_advance() abad_advance()
playsnd(audio_low) playsnd(audio_low)
elseif btn(KEY_UP) then elseif btn(keyUp) or pad(btnUp) then
if abad.y>0 then if abad.y>0 then
if check_tile(abad.hab,abad.x+4,abad.y+8)==tiletype.stair or (abad.x+4)&7~=0 and check_tile(abad.hab,abad.x+12,abad.y+8)==tiletype.stair then if check_tile(abad.hab,abad.x+4,abad.y+8)==tiletype.stair or (abad.x+4)&7~=0 and check_tile(abad.hab,abad.x+12,abad.y+8)==tiletype.stair then
abad.y=abad.y-2 abad.y=abad.y-2
@@ -316,7 +316,7 @@ function abad_state_stairs()
imp.reset() imp.reset()
abad.y=32 abad.y=32
end end
elseif btn(KEY_DOWN) then elseif btn(keyDown) or pad(btnDown) then
if abad.y<32 then if abad.y<32 then
if check_tile(abad.hab,abad.x+4,abad.y+16)==tiletype.stair or (abad.x+4)&7~=0 and check_tile(abad.hab,abad.x+12,abad.y+16)==tiletype.stair then if check_tile(abad.hab,abad.x+4,abad.y+16)==tiletype.stair or (abad.x+4)&7~=0 and check_tile(abad.hab,abad.x+12,abad.y+16)==tiletype.stair then
abad.y=abad.y+2 abad.y=abad.y+2

View File

@@ -213,12 +213,6 @@ function batman.update_stairs()
if batman.wait>=6 then if batman.wait>=6 then
batman.wait=0 batman.wait=0
--if btn(KEY_RIGHT) then
-- batman.flip=false
-- batman_advance()
--elseif btn(KEY_LEFT) then
-- batman.flip=true
-- batman_advance()
if batman.goup then if batman.goup then
if batman.y>0 then if batman.y>0 then
if check_tile(batman.hab,batman.x+4,batman.y+8)==tiletype.stair or (batman.x+4)&7~=0 and check_tile(batman.hab,batman.x+12,batman.y+8)==tiletype.stair then if check_tile(batman.hab,batman.x+4,batman.y+8)==tiletype.stair or (batman.x+4)&7~=0 and check_tile(batman.hab,batman.x+12,batman.y+8)==tiletype.stair then

View File

@@ -8,7 +8,7 @@ function dead.start()
dead.pos[i]=0 dead.pos[i]=0
dead.vel[i]=(200+rnd(400))/400 dead.vel[i]=(200+rnd(400))/400
end end
_update=dead.update game_update=dead.update
end end
function dead.update() function dead.update()
@@ -39,10 +39,8 @@ function dead.update()
end end
end end
if (dead.count>250 and btnp(KEY_SPACE)) or dead.count>500 then if (dead.count>250 and (btnp(keyShoot) or padp(btnShoot))) or dead.count>500 then
game_exit() game_exit()
game_init(true) game_init(true)
--_init()
--_update=update_game
end end
end end

View File

@@ -223,12 +223,6 @@ function elalien.update_stairs()
if elalien.wait>=6 then if elalien.wait>=6 then
elalien.wait=0 elalien.wait=0
--if btn(KEY_RIGHT) then
-- elalien.flip=false
-- elalien_advance()
--elseif btn(KEY_LEFT) then
-- elalien.flip=true
-- elalien_advance()
if elalien.goup then if elalien.goup then
if elalien.y>0 then if elalien.y>0 then
if check_tile(elalien.hab,elalien.x+4,elalien.y+8)==tiletype.stair or (elalien.x+4)&7~=0 and check_tile(elalien.hab,elalien.x+12,elalien.y+8)==tiletype.stair then if check_tile(elalien.hab,elalien.x+4,elalien.y+8)==tiletype.stair or (elalien.x+4)&7~=0 and check_tile(elalien.hab,elalien.x+12,elalien.y+8)==tiletype.stair then

View File

@@ -24,16 +24,16 @@ fade = {
fadeout = function() fadeout = function()
--print("fading out") --print("fading out")
fade.old_update=_update fade.old_update=game_update
_update=fade.update_fadeout game_update=fade.update_fadeout
fade.wait=0 fade.wait=0
fade.step=0 fade.step=0
end, end,
fadeoutin = function() fadeoutin = function()
--print("fading outin") --print("fading outin")
fade.old_update=_update fade.old_update=game_update
_update=fade.update_fadeout game_update=fade.update_fadeout
fade.wait=0 fade.wait=0
fade.step=0 fade.step=0
fade.outin=true fade.outin=true
@@ -55,7 +55,7 @@ fade = {
end end
fade.step=fade.step+1 fade.step=fade.step+1
if fade.step==7 then if fade.step==7 then
_update = fade.old_update game_update = fade.old_update
if fade.outin then if fade.outin then
fade.outin=false; fade.outin=false;
fade.fadein() fade.fadein()
@@ -66,8 +66,8 @@ fade = {
fadein = function() fadein = function()
--print("fading in") --print("fading in")
fade.old_update=_update fade.old_update=game_update
_update=fade.update_fadein game_update=fade.update_fadein
fade.wait=0 fade.wait=0
fade.step=6 fade.step=6
for i=1,15 do setcolor(i,0,0,0) end for i=1,15 do setcolor(i,0,0,0) end
@@ -91,7 +91,7 @@ fade = {
end end
fade.step=fade.step-1 fade.step=fade.step-1
if fade.step<0 then if fade.step<0 then
_update = fade.old_update game_update = fade.old_update
end end
end end
end end

View File

@@ -6,7 +6,7 @@ function final_init()
current_actor=1 current_actor=1
abad.update = abad_nop abad.update = abad_nop
_update=update_final game_update=update_final
next_actor() next_actor()
playmus(audio_final) playmus(audio_final)
local r,g,b=getcolor(15) local r,g,b=getcolor(15)
@@ -128,7 +128,7 @@ function next_actor()
init_actor("EL ABAD",true,16,16,{0,1,0,2}) init_actor("EL ABAD",true,16,16,{0,1,0,2})
elseif current_actor==14 then elseif current_actor==14 then
final_count=0 final_count=0
_update=update_final2 game_update=update_final2
fade.fadeoutin() fade.fadeoutin()
end end
final_room=final_rooms[current_actor] final_room=final_rooms[current_actor]
@@ -150,7 +150,7 @@ function update_final2()
end end
end end
final_count=final_count+1 final_count=final_count+1
if final_count==200 or btnp(KEY_SPACE) or btnp(KEY_RETURN) then if final_count==200 or (btnp(keyShoot) or padp(btnShoot)) or btnp(KEY_RETURN) then
game_exit() game_exit()
game_init(true) game_init(true)
fade.fadeoutin() fade.fadeoutin()

View File

@@ -133,13 +133,13 @@ function game_init(menu)
if menu then if menu then
abad.update = abad_nop abad.update = abad_nop
_update=update_menu game_update=update_menu
menu_count=0 menu_count=0
menu_change_room=300 menu_change_room=300
menu_room=rnd(60) menu_room=rnd(60)
playmus(audio_main_song) playmus(audio_main_song)
else else
_update=update_game game_update=update_game
stopmusic() stopmusic()
end end
--fade.fadein() --fade.fadein()
@@ -185,10 +185,10 @@ function update_dialog()
text("(Y)es (N)o",25,40,2) text("(Y)es (N)o",25,40,2)
if btnp(KEY_N) then if btnp(KEY_N) then
_update=update_game game_update=update_game
elseif btnp(KEY_Y) then elseif btnp(KEY_Y) then
mapa_save() mapa_save()
_update=update_game game_update=update_game
end end
end end
@@ -220,7 +220,7 @@ function update_game()
elseif btnp(KEY_RETURN) then elseif btnp(KEY_RETURN) then
mode=modes.playing mode=modes.playing
elseif btnp(KEY_S) and (btn(KEY_LCTRL) or btn(KEY_LGUI)) then elseif btnp(KEY_S) and (btn(KEY_LCTRL) or btn(KEY_LGUI)) then
_update=update_dialog game_update=update_dialog
elseif btnp(KEY_C) then elseif btnp(KEY_C) then
mapa_cycle_colors(abad.hab) mapa_cycle_colors(abad.hab)
elseif btnp(KEY_M) then elseif btnp(KEY_M) then
@@ -360,7 +360,7 @@ function update_menu()
fireball.update() fireball.update()
switches.update() switches.update()
if btnp(KEY_SPACE) then if btnp(keyShoot) or padp(btnShoot) then
game_exit() game_exit()
game_init() game_init()
fade.fadeoutin() fade.fadeoutin()
@@ -390,8 +390,8 @@ function pause()
sspr(0,0,128,96,0,0) sspr(0,0,128,96,0,0)
setdest(0) setdest(0)
setsource(tiles) setsource(tiles)
pause_old_update=_update pause_old_update=game_update
_update=update_pause game_update=update_pause
end end
function update_pause() function update_pause()
@@ -405,8 +405,8 @@ function update_pause()
setsource(back) setsource(back)
sspr(0,0,128,96,0,0) sspr(0,0,128,96,0,0)
setsource(tiles) setsource(tiles)
_update = pause_old_update game_update = pause_old_update
elseif btnp(KEY_SPACE) then elseif btnp(keyShoot) or padp(btnShoot) then
game_exit() game_exit()
game_init(true) game_init(true)
end end

View File

@@ -2,7 +2,7 @@ intro_wait=40
intro_step=0 intro_step=0
function intro_init() function intro_init()
_update = intro_intro game_update = intro_intro
intro_wait=400 intro_wait=400
cls(16) cls(16)
setdest(logo) setdest(logo)
@@ -19,9 +19,9 @@ function intro_intro()
--text("JAILGAMES",40,30,15) --text("JAILGAMES",40,30,15)
text("presenta",48,50,14) text("presenta",48,50,14)
intro_wait=intro_wait-1 intro_wait=intro_wait-1
if intro_wait==0 or btnp(KEY_ESCAPE) or btnp(KEY_SPACE) then if intro_wait==0 or btnp(KEY_ESCAPE) or btnp(keyShoot) or padp(btnShoot) then
intro_wait=1 intro_wait=1
_update = intro_update game_update = intro_update
fade.fadeoutin() fade.fadeoutin()
end end
if btnp(KEY_M) then if btnp(KEY_M) then

View File

@@ -1,3 +1,15 @@
keyUp = KEY_UP
keyDown = KEY_DOWN
keyLeft = KEY_LEFT
keyRight = KEY_RIGHT
keyShoot = KEY_SPACE
btnUp = BTN_UP
btnDown = BTN_DOWN
btnLeft = BTN_LEFT
btnRigth = BTN_RIGHT
btnShoot = BTN_A
function _init() function _init()
tiles=loadsurf("tiles.gif") tiles=loadsurf("tiles.gif")
setsource(tiles) setsource(tiles)
@@ -29,4 +41,14 @@ function _init()
--final_init() --final_init()
end end
function _update() end function _update()
if btnp(KEY_F2) then
local val = zoom() + 2
if val >= 10 then val = 2 end
zoom(val)
elseif btnp(KEY_F3) then
fullscreen(not fullscreen())
end
if (game_update) game_update() end
end

View File

@@ -162,7 +162,7 @@ function mapa_create_minimap()
end end
end end
end end
_update=mapa_draw_minimap game_update=mapa_draw_minimap
end end
function mapa_draw_minimap() function mapa_draw_minimap()

View File

@@ -144,8 +144,8 @@ function start_scene(scene,offset)
playmus(scenes.current_scene[scenes.dnum].musica) playmus(scenes.current_scene[scenes.dnum].musica)
end end
if offset then scenes.offset=offset end if offset then scenes.offset=offset end
old_update=_update old_update=game_update
_update=update_scene game_update=update_scene
end end
function playtext(snd) function playtext(snd)
@@ -254,7 +254,7 @@ function update_scene()
final_init() final_init()
fade.fadeoutin() fade.fadeoutin()
else else
_update=old_update game_update=old_update
end end
else else
scenes.dnum=scenes.dnum+1 scenes.dnum=scenes.dnum+1
@@ -283,21 +283,22 @@ function update_scene()
end end
if scenes.step>8 then if scenes.step>8 then
if btnp(KEY_SPACE) or btnp(KEY_DOWN) or btnp(KEY_UP) or btnp(KEY_LEFT) or btnp(KEY_RIGHT) or btnp(KEY_RETURN) then if btnp(keyShoot) or btnp(keyDown) or btnp(keyUp) or btnp(keyLeft) or btnp(keyRight) or btnp(KEY_RETURN) or
padp(btnShoot) or padp(btnDown) or padp(btnUp) or padp(btnLeft) or padp(btnRight) then
if scenes.dnum==#scenes.current_scene then if scenes.dnum==#scenes.current_scene then
stopmusic() stopmusic()
if batman.endgame then if batman.endgame then
final_init() final_init()
fade.fadeoutin() fade.fadeoutin()
else else
_update=old_update game_update=old_update
end end
else else
scenes.dnum=scenes.dnum+1 scenes.dnum=scenes.dnum+1
scenes.step=2 scenes.step=2
end end
end end
elseif btnp(KEY_SPACE) then elseif btnp(keyShoot) or padp(btnShoot) then
scenes.step=8 scenes.step=8
end end
end end