summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFernando Carmona Varo <ferkiwi@gmail.com>2015-10-28 00:03:28 +0100
committerFernando Carmona Varo <ferkiwi@gmail.com>2015-10-28 00:03:28 +0100
commit4c03a0e5880e44e920007ead8212025858a1fb21 (patch)
tree20e7ec370ea0f95a93d2402e7f897e09729a7966
parent3eb0d44c20383a1c3d0fe4552b169b223010a46e (diff)
parent55ba62165293b6bf8f3f78e2e5fc3bb5152400f4 (diff)
Merge branch 'master' of https://github.com/DonBatman/myarcade
Conflicts: mario/gamestate.lua mario/hud.lua mario/init.lua
-rw-r--r--mario/blocks.lua2
-rwxr-xr-xmario/gamestate.lua27
-rw-r--r--mario/init.lua13
-rw-r--r--mario/schems/mario2.mtsbin0 -> 566 bytes
-rw-r--r--mario/turtle.lua15
5 files changed, 22 insertions, 35 deletions
diff --git a/mario/blocks.lua b/mario/blocks.lua
index 7005de3..f44f61f 100644
--- a/mario/blocks.lua
+++ b/mario/blocks.lua
@@ -80,6 +80,7 @@ minetest.register_node("mario:mushroom",{
},
drawtype = "nodebox",
paramtype = "light",
+ walkable = false,
groups = {cracky = 3},
node_box = nbox,
on_destruct = function(pos)
@@ -99,6 +100,7 @@ minetest.register_node("mario:mushroom_green",{
},
drawtype = "nodebox",
paramtype = "light",
+ walkable = false,
groups = {cracky = 3},
node_box = nbox,
on_destruct = function(pos)
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
diff --git a/mario/init.lua b/mario/init.lua
index 283492c..7f60785 100644
--- a/mario/init.lua
+++ b/mario/init.lua
@@ -7,6 +7,7 @@ dofile(minetest.get_modpath("mario").."/turtle.lua")
dofile(minetest.get_modpath("mario").."/gamestate.lua")
dofile(minetest.get_modpath("mario").."/hud.lua")
+
minetest.register_node("mario:placer",{
description = "Reset",
tiles = {
@@ -21,17 +22,10 @@ minetest.register_node("mario:placer",{
paramtype = "light",
groups = {cracky = 3},
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
- local schem = minetest.get_modpath("mario").."/schems/mario.mts"
- minetest.place_schematic({x=pos.x-1,y=pos.y-2,z=pos.z-2},schem,0, "air", true)
- player:setpos({x=pos.x+16,y=pos.y+0.1,z=pos.z+1})
- player:set_physics_override(1,1,0.3,true,false)
-
mario.game_start(pos, player, {
schematic = minetest.get_modpath("mario").."/schems/mario.mts",
scorename = "mario:classic_board",
})
-
- minetest.sound_play("mario-game-start", {pos = pos,max_hear_distance = 40,gain = 10.0,})
end,
})
minetest.register_node("mario:placer2",{
@@ -67,9 +61,8 @@ minetest.register_node("mario:exit",{
paramtype = "light",
groups = {cracky = 3},
on_rightclick = function(pos, node, player, itemstack, pointed_thing)
- player:setpos({x=pos.x-5,y=pos.y+0.1,z=pos.z-3})
- print(name)
- player:set_physics_override(1,1,1,true,false)
+ local game = mario.get_game_by_player(player:get_player_name())
+ mario.game_end(game.id)
end,
})
diff --git a/mario/schems/mario2.mts b/mario/schems/mario2.mts
new file mode 100644
index 0000000..c20db22
--- /dev/null
+++ b/mario/schems/mario2.mts
Binary files differ
diff --git a/mario/turtle.lua b/mario/turtle.lua
index ef9a624..546123f 100644
--- a/mario/turtle.lua
+++ b/mario/turtle.lua
@@ -104,16 +104,7 @@ for i in ipairs(turtles) do
if distance < 1.5 then
-- player touches ghost!!
- if gamestate.power_pellet then
- -- Player eats ghost! move it to spawn
- local ghost_spawn = vector.add(gamestate.pos, {x=13,y=0.5,z=19})
- self.object:setpos(ghost_spawn)
- -- set the timer negative so it'll have to wait extra time
- self.timer = -ghosts_death_delay
- -- play sound and reward player
- minetest.sound_play("mario_eatghost", {pos = boardcenter,max_hear_distance = 6, object=player, loop=false})
- player:get_inventory():add_item('main', 'mario:cherrys')
- else
+
-- Ghost catches the player!
gamestate.lives = gamestate.lives - 1
if gamestate.lives < 1 then
@@ -128,8 +119,10 @@ for i in ipairs(turtles) do
minetest.chat_send_player(gamestate.player_name,"You have ".. gamestate.lives .." lives left")
mario.game_reset(self.gameid, player)
end
- end
+ --end
mario.update_hud(self.gameid, player)
+
+
else
local vec = {x=p.x-s.x, y=p.y-s.y, z=p.z-s.z}