summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ghost.lua2
-rwxr-xr-xhud.lua (renamed from scorehud.lua)13
-rw-r--r--init.lua2
3 files changed, 12 insertions, 5 deletions
diff --git a/ghost.lua b/ghost.lua
index 7b7eea5..1c9e47e 100644
--- a/ghost.lua
+++ b/ghost.lua
@@ -92,7 +92,6 @@ for i in ipairs(ghosts) do
-- play sound and reward player
minetest.sound_play("mypacman_eatghost", {pos = boardcenter,max_hear_distance = 6, object=player, loop=false})
player:get_inventory():add_item('main', 'mypacman:cherrys')
- mypacman.update_hud(self.gameid, player)
else
-- Ghost catches the player!
gamestate.lives = gamestate.lives - 1
@@ -110,6 +109,7 @@ for i in ipairs(ghosts) do
mypacman.game_reset(self.gameid, player)
end
end
+ mypacman.update_hud(self.gameid, player)
else
local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z}
diff --git a/scorehud.lua b/hud.lua
index dbdfd7f..00f015d 100755
--- a/scorehud.lua
+++ b/hud.lua
@@ -7,16 +7,23 @@ function mypacman.update_hud(id, player)
player = player or minetest.get_player_by_name(game.player_name)
if not player then
return
+ elseif not game then
+ mypacman.remove_hud(player)
+ return
end
+
local hudtext = "Score: " .. game.score
+ .. "\nLevel: " .. game.level
+ .. "\nLives: " .. game.lives
+
local hud = hud_table[game.player_name]
if not hud then
hud = player:hud_add({
hud_elem_type = "text",
- position = {x = 1, y = 0},
- offset = {x=-400, y = 75},
+ position = {x = 0, y = 1},
+ offset = {x=100, y = -100},
scale = {x = 100, y = 100},
- number = 0xFFFFFF, --color
+ number = 0x8888FF, --color
text = hudtext
})
hud_table[game.player_name] = hud
diff --git a/init.lua b/init.lua
index 8e7dbc7..69c0df7 100644
--- a/init.lua
+++ b/init.lua
@@ -8,7 +8,7 @@ dofile(minetest.get_modpath("mypacman").."/ghost.lua")
dofile(minetest.get_modpath("mypacman").."/blocks.lua")
dofile(minetest.get_modpath("mypacman").."/portals.lua")
dofile(minetest.get_modpath("mypacman").."/gamestate.lua")
-dofile(minetest.get_modpath("mypacman").."/scorehud.lua")
+dofile(minetest.get_modpath("mypacman").."/hud.lua")
--Yellow Pellets