diff options
| author | DonBatman <serfdon@gmail.com> | 2015-10-22 09:25:40 -0700 | 
|---|---|---|
| committer | DonBatman <serfdon@gmail.com> | 2015-10-22 09:25:40 -0700 | 
| commit | f8e75176876652333b376398d982ad06ac26b66f (patch) | |
| tree | 5dc85a8e0640c685507e7ff761a5132029f1c2d9 | |
| parent | 834797777bbd6c2510742885a192987fdbfb3d79 (diff) | |
Added score to table. Changed craft items to nodes. Changed sounds. Changed blocks to immortal
| -rw-r--r-- | blocks.lua | 8 | ||||
| -rw-r--r-- | craftitems.lua | 98 | ||||
| -rwxr-xr-x | gamestate.lua | 9 | ||||
| -rw-r--r-- | ghost.lua | 4 | 
4 files changed, 102 insertions, 17 deletions
| @@ -1,7 +1,7 @@  local sbox =  {  		type = "fixed",  		fixed = { -			{0, 0, 0, 0, 0, 0} +			{-0.5, -0.5, -0.0625, 0.5, 0.5, 0.0625}  		}  	}  local cbox =  { @@ -40,7 +40,7 @@ minetest.register_node("mypacman:"..itm, {  	paramtype2 = "facedir",  	light_source = lit,  	walkable = tf, -	groups = {disable_jump = 1, not_in_creative_inventory = 1}, +	groups = {disable_jump = 1, immortal=1, not_in_creative_inventory = 1},  	selection_box = sbox,  	collision_box = cbox, @@ -53,7 +53,7 @@ minetest.register_node("mypacman:glass", {  	drawtype = "glasslike",  	paramtype = "light",  	paramtype2 = "facedir", -	groups = {cracky=3,not_in_creative_inventory = 1}, +	groups = {immortal=1,not_in_creative_inventory = 1},  	selection_box = cbox,  	collision_box = cbox, @@ -65,7 +65,7 @@ minetest.register_node("mypacman:glassw", {  	paramtype = "light",  	paramtype2 = "facedir",  	walkable = false, -	groups = {cracky=3,not_in_creative_inventory = 1}, +	groups = {immortal=1,not_in_creative_inventory = 1},  	selection_box = cbox,  	colision_box = cbox, diff --git a/craftitems.lua b/craftitems.lua index 34948d8..8648363 100644 --- a/craftitems.lua +++ b/craftitems.lua @@ -1,19 +1,97 @@ +local cherry_box = { +		type = "fixed", +		fixed = { +			{0, -0.375, -0.0625, 0.25, 0, 0.0625}, +			{-0.0625, -0.3125, -0.0625, 0.3125, -0.0625, 0.0625}, +			{-0.3125, -0.25, -0.0625, -0.125, 0.125, 0.0625}, +			{-0.375, -0.1875, -0.0625, -0.125, 0.0625, 0.0625}, +			{-0.125, -0.0625, -0.0625, -0.0625, 0.125, 0.0625}, +			{-0.0625, 0, -0.0625, 0, 0.0625, 0.0625}, +			{-0.0625, 0.125, -0.0625, 0, 0.1875, 0.0625}, +			{0, 0.1875, -0.0625, 0.125, 0.25, 0.0625}, +			{0.125, 0.25, -0.0625, 0.375, 0.3125, 0.0625}, +			{0.25, 0.3125, -0.0625, 0.375, 0.375, 0.0625}, +			{0.1875, 0.125, -0.0625, 0.25, 0.25, 0.0625}, +			{0.125, 0.0625, -0.0625, 0.1875, 0.125, 0.0625}, +			{0.0625, 0, -0.0625, 0.125, 0.0625, 0.0625}, +		} +	} +local strawberry_box = { +		type = "fixed", +		fixed = { +			{-0.0625, 0.3125, -0.0625, 0, 0.375, 0.0625}, +			{-0.25, 0.25, -0.0625, 0.1875, 0.3125, 0.0625}, +			{-0.3125, 0.1875, -0.0625, 0.25, 0.25, 0.0625}, +			{-0.375, -0.0625, -0.0625, 0.3125, 0.1875, 0.0625}, +			{-0.3125, -0.1875, -0.0625, 0.25, -0.0625, 0.0625}, +			{-0.25, -0.25, -0.0625, 0.1875, -0.1875, 0.0625}, +			{-0.1875, -0.3125, -0.0625, 0.125, -0.25, 0.0625}, +			{-0.0625, -0.375, -0.0625, 0, -0.3125, 0.0625}, +		} +	} +local apple_box = { +		type = "fixed", +		fixed = { +			{-0.3125, -0.125, -0.0625, 0.375, 0.25, 0.0625}, +			{-0.375, -0.125, -0.0625, -0.3125, 0.1875, 0.0625}, +			{-0.3125, -0.25, -0.0625, 0.3125, -0.125, 0.0625}, +			{-0.25, -0.3125, -0.0625, 0.25, -0.25, 0.0625}, +			{0.0625, -0.375, -0.0625, 0.1875, -0.3125, 0.0625}, +			{-0.1875, -0.375, -0.0625, 0, -0.3125, 0.0625}, +			{0.125, 0.25, -0.0625, 0.3125, 0.3125, 0.0625}, +			{0, 0.25, -0.0625, 0.0625, 0.3125, 0.0625}, +			{-0.25, 0.25, -0.0625, -0.0625, 0.3125, 0.0625}, +			{-0.0625, 0.3125, -0.0625, 0, 0.375, 0.0625}, +		} +	} +local orange_box = { +		type = "fixed", +		fixed = { +			{-0.375, -0.125, -0.0625, 0.375, 0.125, 0.0625}, +			{-0.3125, -0.25, -0.0625, 0.3125, 0.1875, 0.0625}, +			{-0.25, -0.3125, -0.0625, 0.25, 0.25, 0.0625}, +			{0.0625, -0.375, -0.0625, 0.1875, -0.3125, 0.0625}, +			{-0.1875, -0.375, -0.0625, 0, -0.3125, 0.0625}, +			{0, 0.25, -0.0625, 0.0625, 0.375, 0.0625}, +			{-0.25, 0.3125, -0.0625, 0.0625, 0.375, 0.0625}, +			{-0.1875, 0.25, -0.0625, -0.0625, 0.4375, 0.0625}, +			{-0.25, 0.25, -0.0625, -0.1875, 0.3125, 0.0625}, +		} +	} +  local pelletitems = { -	{"cherrys", "Cherrys","2"}, -	{"apple", "Apple","3"}, -	{"peach", "Peach","4"}, -	{"strawberry", "Strawberry","2"}, +	{"cherrys", "Cherrys","2",cherry_box}, +	{"apple", "Apple","3",apple_box}, +	{"orange", "Orange","4",orange_box}, +	{"strawberry", "Strawberry","2",strawberry_box},  	}  for i in ipairs (pelletitems) do  	local itm = pelletitems[i][1] -	local desc = pelletitems[i][1] -	local hlth = pelletitems[i][1] - +	local desc = pelletitems[i][2] +	local hlth = pelletitems[i][3] +	local cbox = pelletitems[i][4] -minetest.register_craftitem("mypacman:"..itm,{ +minetest.register_node("mypacman:"..itm,{  	description = desc,  	inventory_image = "mypacman_"..itm..".png", -	on_use = minetest.item_eat(2), -	groups = {not_in_creative_inventory = 1}, +	tiles = { +			"mypacman_"..itm..".png", +			"mypacman_"..itm..".png", +			"mypacman_"..itm..".png", +			"mypacman_"..itm..".png", +			"mypacman_"..itm..".png", +			"mypacman_"..itm..".png^[transformFX", +			}, +	drawtype = "nodebox", +	paramtype = "light", +	paramtype2 = "facedir", +	walkable = false, +	light_source = 14, +	groups = {cracky=3,not_in_creative_inventory = 0}, +	node_box = cbox, +	collision_box = cbox, +	after_destruct = function(pos, oldnode) +		mypacman.on_player_got_fruit() +	end,  })  end diff --git a/gamestate.lua b/gamestate.lua index 476590a..fd073e0 100755 --- a/gamestate.lua +++ b/gamestate.lua @@ -28,6 +28,7 @@ function mypacman.game_start(pos, player)  		level = 1,  		speed = 2,  		lives = 3, +		score = 0,  	}   	mypacman.games[id] = gamestate  	minetest.log("action","New pacman game started at " .. id .. " by " .. gamestate.player_name) @@ -115,7 +116,9 @@ function mypacman.on_player_got_pellet(player)  	if not gamestate then return end  	gamestate.pellet_count = gamestate.pellet_count + 1 -	if gamestate.pellet_count >= 20 then -- 252 +	gamestate.score = gamestate.score + 10 +	minetest.chat_send_player(name, "Your score is "..gamestate.score) +	if gamestate.pellet_count >= 252 then -- 252  		minetest.chat_send_player(name, "You cleared the board!")  		mypacman.remove_ghosts(gamestate.id) @@ -144,9 +147,11 @@ function mypacman.on_player_got_power_pellet(player)  	minetest.chat_send_player(name, "You got a POWER PELLET")  	gamestate.power_pellet = os.time() + power_pellet_duration +	gamestate.score = gamestate.score + 50 +	minetest.chat_send_player(name, "Your score is "..gamestate.score)  	local boardcenter = vector.add(gamestate.pos, {x=13,y=0.5,z=15}) -	local powersound = minetest.sound_play("mypacman_beginning", {pos = boardcenter,max_hear_distance = 20, object=player, loop=true}) +	local powersound = minetest.sound_play("mypacman_powerup", {pos = boardcenter,max_hear_distance = 20, object=player, loop=true})  	minetest.after(power_pellet_duration, function()  		if os.time() >= (gamestate.power_pellet or 0) then @@ -28,7 +28,8 @@ for i in ipairs(ghosts) do  		},  		groups = {immortal = 1},  		velocity = {x=math.random(-1,1), y=0, z=math.random(-1,1)}, -		collisionbox = {-0.25, -1.0, -0.25, 0.25, 0.48, 0.25}, +		collisionbox = {-0.01, -0.5, -0.01, 0.01, -0.49, 0.01}, +		--collisionbox = {-0.25, -1.0, -0.25, 0.25, 0.48, 0.25},  		is_visible = true,  		automatic_rotate = true,  		automatic_face_movement_dir = -90, -- set yaw direction in degrees, false to disable @@ -96,6 +97,7 @@ for i in ipairs(ghosts) do  						minetest.chat_send_player(gamestate.player_name,"Game Over")  						player:moveto(vector.add(gamestate.pos,{x=0.5,y=0.5,z=-1.5}))  						mypacman.game_end(self.gameid) +						minetest.sound_play("mypacman_death", {pos = boardcenter,max_hear_distance = 20, object=player, loop=false})  					elseif gamestate.lives == 1 then  						minetest.chat_send_player(gamestate.player_name,"This is your last life") | 
