diff options
-rw-r--r-- | ghost.lua | 2 | ||||
-rwxr-xr-x | hud.lua (renamed from scorehud.lua) | 13 | ||||
-rw-r--r-- | init.lua | 2 |
3 files changed, 12 insertions, 5 deletions
@@ -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} @@ -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 @@ -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 |