Skip to content

Commit d766bc7

Browse files
madebricculus
authored andcommitted
Add hints option to Dragon's Lair
The hint mode will display arrows and a sword when the action is available. They are also color coded: green means okay, red means not okay (=death).
1 parent 5b87b7a commit d766bc7

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

data/games/lair/game.lua

Lines changed: 41 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,14 @@ local starting_lives = 5
1212
local infinite_lives = false -- set to true to not lose a life on failure.
1313
local god_mode = false -- if true, game plays correct moves automatically, so you never fail.
1414
local play_sounds = true -- if true, beeps and buzzes play when appropriate, otherwise, skipped.
15+
local draw_hints = true -- if true, draws hint on what button to press.
1516

1617
DirkSimple.cvars = {
1718
{ name="starting_lives", desc="Number of lives player starts with", values="5|4|3|2|1", setter=function(name, value) starting_lives = DirkSimple.to_int(value) end },
1819
{ name="infinite_lives", desc="Don't lose a life when failing", values="false|true", setter=function(name, value) infinite_lives = DirkSimple.to_bool(value) end },
1920
{ name="god_mode", desc="Game plays itself perfectly, never failing", values="false|true", setter=function(name, value) god_mode = DirkSimple.to_bool(value) end },
20-
{ name="play_sounds", desc="Play input sounds", values="true|false", setter=function(name, value) play_sounds = DirkSimple.to_bool(value) end }
21+
{ name="play_sounds", desc="Play input sounds", values="true|false", setter=function(name, value) play_sounds = DirkSimple.to_bool(value) end },
22+
{ name="draw_hints", desc="Show hints", values="true|false", setter=function(name, value) draw_hints = DirkSimple.to_bool(value) end },
2123
}
2224

2325

@@ -286,6 +288,41 @@ local function kill_player()
286288
end
287289
end
288290

291+
local hint_sprite_data = {
292+
up = { sprite = "hints", index = 0, x = .45, y = .0, w = .1, h = .1 },
293+
upright = { sprite = "hints", index = 1, x = .9, y = .0, w = .1, h = .1 },
294+
right = { sprite = "hints", index = 2, x = .9, y = .45, w = .1, h = .1 },
295+
downright = { sprite = "hints", index = 3, x = .9, y = .9, w = .1, h = .1 },
296+
down = { sprite = "hints", index = 4, x = .45, y = .9, w = .1, h = .1 },
297+
downleft = { sprite = "hints", index = 5, x = .0, y = .9, w = .1, h = .1 },
298+
left = { sprite = "hints", index = 6, x = .0, y = .45, w = .1, h = .1 },
299+
upleft = { sprite = "hints", index = 7, x = .0, y = .0, w = .1, h = .1 },
300+
action = { sprite = "hints", index = 8, x = .45, y = .45, w = .1, h = .1 },
301+
}
302+
303+
-- This function assumes the actions are grouped by input, and sorted by time
304+
local function draw_hint_sprites(actions)
305+
local last_action_drawn = nil
306+
307+
for i=1,#actions do
308+
local action = actions[i]
309+
if scene_manager.current_sequence_ticks <= action.to and (not last_action_drawn or last_action_drawn.input ~= action.input) then
310+
local hl = hint_sprite_data[action.input]
311+
if hl then
312+
r = 0
313+
g = 0
314+
if scene_manager.current_scene[action.nextsequence].kills_player then
315+
r = 255
316+
else
317+
g = 255
318+
end
319+
DirkSimple.draw_sprite(hl.sprite, 32 * hl.index, 0, 32, 32, DirkSimple.video_width * hl.x, DirkSimple.video_height * hl.y, DirkSimple.video_width * hl.w, DirkSimple.video_height * hl.h, r, g, 0)
320+
end
321+
last_action_drawn = action
322+
end
323+
end
324+
end
325+
289326
local function check_actions(inputs)
290327
-- we don't care about inserting coins, but we'll play the sound if you
291328
-- hit the coinslot button.
@@ -299,6 +336,9 @@ local function check_actions(inputs)
299336

300337
local actions = scene_manager.current_sequence.actions
301338
if actions ~= nil then
339+
if draw_hints then
340+
draw_hint_sprites(actions)
341+
end
302342
for i,v in ipairs(actions) do
303343
-- ignore if not in the time window for this input.
304344
if (scene_manager.current_sequence_ticks >= v.from) and (scene_manager.current_sequence_ticks <= v.to) then

data/games/lair/hints.bmp

36.1 KB
Binary file not shown.

0 commit comments

Comments
 (0)