diff options
Diffstat (limited to 'mario/gamestate.lua')
-rwxr-xr-x | mario/gamestate.lua | 27 |
1 files changed, 13 insertions, 14 deletions
diff --git a/mario/gamestate.lua b/mario/gamestate.lua index 59e535b..2572a99 100755 --- a/mario/gamestate.lua +++ b/mario/gamestate.lua @@ -31,8 +31,10 @@ function mario.game_start(pos, player, gamedef) player_name = player_name, pos = pos, player_start = vector.add(pos, (gamedef.player_start or {x=16,y=0,z=1})), + turtle1_start = vector.add(pos, (gamedef.turtle1_start or {x=3,y=12,z=1})), turtle2_start = vector.add(pos, (gamedef.turtle1_start or {x=30,y=12,z=1})), + coin_total = gamedef.coin_total or 84, speed = gamedef.speed or 2, lives = gamedef.lives or 3, @@ -51,6 +53,9 @@ function mario.game_start(pos, player, gamedef) local schem = gamedef minetest.place_schematic({x=pos.x-1,y=pos.y-2,z=pos.z-2},gamedef.schematic,0, "air", true) + -- initialize player + player:set_physics_override(1,1,0.3,true,false) + -- Set start positions mario.game_reset(id, player) mario.update_hud(id, player) @@ -76,6 +81,8 @@ function mario.game_end(id) minetest.chat_send_player(gamestate.player_name, "You made it to the highscores! Your Ranking: " .. ranking) end end + -- Restore normal physics + player:set_physics_override(1,1,1,true,false) -- Clear the data mario.games[id] = nil mario.players[id] = nil @@ -95,6 +102,7 @@ function mario.game_reset(id, player) -- Position the player local player = player or minetest.get_player_by_name(gamestate.player_name) player:setpos(gamestate.player_start) + local pos = gamestate.pos -- Spawn the turtles and assign the game id to each turtle minetest.after(2, function() @@ -150,9 +158,9 @@ function mario.add_mushroom(id) if not gamestate then return end local node = {} -- Different mushroom will be used depending on the level - if gamestate.level == 1 then + --if gamestate.level == 1 then node.name = "mario:mushroom" - end + --end local pos = vector.add(gamestate.player_start,{x=0,y=12,z=0}) minetest.set_node(pos, node) print(node.param2) @@ -171,7 +179,7 @@ function mario.on_player_got_coin(player) mario.update_hud(gamestate.id, player) minetest.sound_play("mario-coin", {object = player, max_hear_distance = 6}) - if gamestate.coin_count == 70 or gamestate.coin_count == 180 then + if gamestate.coin_count == 10 then mario.add_mushroom(gamestate.id) elseif gamestate.coin_count >= gamestate.coin_total then minetest.chat_send_player(name, "You cleared the board!") @@ -257,18 +265,9 @@ local function on_player_gamestep(player, gameid) if node.name == "mario:coin" then minetest.remove_node(pos) mario.on_player_got_coin(player) - elseif node.name == "mario:cherrys" then - minetest.remove_node(pos) - mario.on_player_got_mushroom(player, 100) - elseif node.name == "mario:strawberry" then - minetest.remove_node(pos) - mario.on_player_got_mushroom(player, 300) - elseif node.name == "mario:orange" then - minetest.remove_node(pos) - mario.on_player_got_mushroom(player, 500) - elseif node.name == "mario:apple" then + elseif node.name == "mario:mushroom" then minetest.remove_node(pos) - mario.on_player_got_mushroom(player, 700) + mario.on_player_got_mushroom(player, 15) end end end |