From d15cf002d8567836e5029a6abe9054430e8bd69a Mon Sep 17 00:00:00 2001 From: kilbith Date: Fri, 8 May 2015 12:48:05 +0200 Subject: [PATCH] Add Tetris Arcade --- computer/init.lua | 130 ++++++------ computer/models/tetris_arcade.obj | 34 +++ computer/recipes.lua | 173 ++++++++------- computer/tetris.lua | 282 +++++++++++++++++++++++++ computer/textures/computer_black.png | Bin 0 -> 82 bytes computer/textures/computer_blue.png | Bin 0 -> 114 bytes computer/textures/computer_cyan.png | Bin 0 -> 114 bytes computer/textures/computer_green.png | Bin 0 -> 114 bytes computer/textures/computer_magenta.png | Bin 0 -> 114 bytes computer/textures/computer_orange.png | Bin 0 -> 114 bytes computer/textures/computer_red.png | Bin 0 -> 114 bytes computer/textures/computer_yellow.png | Bin 0 -> 114 bytes computer/textures/tetris_arcade.png | Bin 0 -> 9326 bytes 13 files changed, 472 insertions(+), 147 deletions(-) create mode 100644 computer/models/tetris_arcade.obj create mode 100644 computer/tetris.lua create mode 100644 computer/textures/computer_black.png create mode 100644 computer/textures/computer_blue.png create mode 100644 computer/textures/computer_cyan.png create mode 100644 computer/textures/computer_green.png create mode 100644 computer/textures/computer_magenta.png create mode 100644 computer/textures/computer_orange.png create mode 100644 computer/textures/computer_red.png create mode 100644 computer/textures/computer_yellow.png create mode 100644 computer/textures/tetris_arcade.png diff --git a/computer/init.lua b/computer/init.lua index 58b2589c..faa42a92 100644 --- a/computer/init.lua +++ b/computer/init.lua @@ -1,100 +1,100 @@ -computer = { }; +computer = { } -computer.register = function ( name, def ) - local nodename = name; - if (name:sub(1, 1) == ":") then name = name:sub(2); end - local modname, basename = name:match("^([^:]+):(.*)"); - local TEXPFX = modname.."_"..basename.."_"; - local ONSTATE = modname..":"..basename; - local OFFSTATE = modname..":"..basename.."_off"; - local def = def; +computer.register = function (name, def) + local nodename = name + if (name:sub(1, 1) == ":") then name = name:sub(2) end + local modname, basename = name:match("^([^:]+):(.*)") + local TEXPFX = modname.."_"..basename.."_" + local ONSTATE = modname..":"..basename + local OFFSTATE = modname..":"..basename.."_off" + local def = def minetest.register_node(ONSTATE, { - drawtype = "nodebox"; - paramtype = "light"; - paramtype2 = "facedir"; - description = def.description; - groups = { snappy=2, choppy=2, oddly_breakable_by_hand=2 }; + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + description = def.description, + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2}, tiles = { TEXPFX.."tp.png", TEXPFX.."bt.png", TEXPFX.."rt.png", TEXPFX.."lt.png", TEXPFX.."bk.png", - TEXPFX.."ft.png", - }; - node_box = def.node_box; - selection_box = def.node_box; - on_rightclick = function ( pos, node, clicker, itemstack) + TEXPFX.."ft.png" + }, + node_box = def.node_box, + selection_box = def.node_box, + on_rightclick = function (pos, node, clicker, itemstack) if (def.on_turn_off) then - if (def.on_turn_off(pos, node, clicker, itemstack)) then return; end + if (def.on_turn_off(pos, node, clicker, itemstack)) then return end end - node.name = OFFSTATE; - minetest.set_node(pos, node); - end; - }); + node.name = OFFSTATE + minetest.set_node(pos, node) + end + }) minetest.register_node(OFFSTATE, { - drawtype = "nodebox"; - paramtype = "light"; - paramtype2 = "facedir"; - groups = { snappy=2, choppy=2, oddly_breakable_by_hand=2, - not_in_creative_inventory=1 }; + drawtype = "nodebox", + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy=2, choppy=2, oddly_breakable_by_hand=2, not_in_creative_inventory=1}, tiles = { (TEXPFX.."tp"..(def.tiles_off.top and "_off" or "")..".png"), (TEXPFX.."bt"..(def.tiles_off.bottom and "_off" or "")..".png"), (TEXPFX.."rt"..(def.tiles_off.right and "_off" or "")..".png"), (TEXPFX.."lt"..(def.tiles_off.left and "_off" or "")..".png"), (TEXPFX.."bk"..(def.tiles_off.back and "_off" or "")..".png"), - (TEXPFX.."ft"..(def.tiles_off.front and "_off" or "")..".png"), - }; - node_box = def.node_box_off or def.node_box; - selection_box = def.node_box_off or def.node_box; - on_rightclick = function ( pos, node, clicker, itemstack) + (TEXPFX.."ft"..(def.tiles_off.front and "_off" or "")..".png") + }, + node_box = def.node_box_off or def.node_box, + selection_box = def.node_box_off or def.node_box, + on_rightclick = function (pos, node, clicker, itemstack) if (def.on_turn_on) then - if (def.on_turn_on(pos, node, clicker, itemstack)) then return; end + if (def.on_turn_on(pos, node, clicker, itemstack)) then return end end - node.name = ONSTATE; - minetest.set_node(pos, node); - end; - drop = ONSTATE; - }); + node.name = ONSTATE + minetest.set_node(pos, node) + end, + drop = ONSTATE + }) end -computer.register_handheld = function ( name, def ) - local nodename = name; - if (name:sub(1, 1) == ":") then name = name:sub(2); end - local modname, basename = name:match("^([^:]+):(.*)"); - local TEXPFX = modname.."_"..basename.."_inv"; - local ONSTATE = modname..":"..basename; - local OFFSTATE = modname..":"..basename.."_off"; - local on_use = def.on_use; +computer.register_handheld = function (name, def) + local nodename = name + if (name:sub(1, 1) == ":") then name = name:sub(2) end + local modname, basename = name:match("^([^:]+):(.*)") + local TEXPFX = modname.."_"..basename.."_inv" + local ONSTATE = modname..":"..basename + local OFFSTATE = modname..":"..basename.."_off" + local on_use = def.on_use minetest.register_craftitem(ONSTATE, { - description = def.description; - inventory_image = TEXPFX..".png"; - wield_image = TEXPFX..".png"; - }); + description = def.description, + inventory_image = TEXPFX..".png", + wield_image = TEXPFX..".png" + }) end -computer.pixelnodebox = function ( size, boxes ) - local fixed = { }; - local i, box; +computer.pixelnodebox = function (size, boxes) + local fixed = { } + local i, box for i, box in ipairs(boxes) do - local x, y, z, w, h, l = unpack(box); + local x, y, z, w, h, l = unpack(box) fixed[#fixed + 1] = { (x / size) - 0.5, (y / size) - 0.5, (z / size) - 0.5, ((x + w) / size) - 0.5, ((y + h) / size) - 0.5, - ((z + l) / size) - 0.5, - }; + ((z + l) / size) - 0.5 + } end return { - type = "fixed"; - fixed = fixed; - }; + type = "fixed", + fixed = fixed + } end -local MODPATH = minetest.get_modpath("computer"); -dofile(MODPATH.."/computers.lua"); -dofile(MODPATH.."/miscitems.lua"); -dofile(MODPATH.."/recipes.lua"); +local MODPATH = minetest.get_modpath("computer") +dofile(MODPATH.."/computers.lua") +dofile(MODPATH.."/miscitems.lua") +dofile(MODPATH.."/recipes.lua") +dofile(MODPATH.."/tetris.lua") diff --git a/computer/models/tetris_arcade.obj b/computer/models/tetris_arcade.obj new file mode 100644 index 00000000..66d651f6 --- /dev/null +++ b/computer/models/tetris_arcade.obj @@ -0,0 +1,34 @@ +# Blender v2.72 (sub 0) OBJ File: '' +# www.blender.org +mtllib vending_machine.mtl +o Cube +v 0.499998 -0.499998 -0.499998 +v 0.499998 -0.499998 0.499998 +v -0.499998 -0.499998 0.499998 +v -0.499998 -0.499998 -0.499998 +v 0.499998 1.499994 -0.499998 +v 0.499998 1.499994 0.499998 +v -0.499998 1.499994 0.499998 +v -0.499998 1.499994 -0.499998 +vt 0.250050 0.250050 +vt 0.000100 0.250050 +vt 0.000100 0.000100 +vt 0.250050 0.000100 +vt 0.250050 0.749950 +vt 0.250050 0.999900 +vt 0.000100 0.999900 +vt 0.000100 0.749950 +vt 0.999900 0.250049 +vt 0.999900 0.749949 +vt 0.749950 0.749950 +vt 0.749950 0.250050 +vt 0.500000 0.749950 +vt 0.500000 0.250050 +usemtl Material +s off +f 1/1 2/2 3/3 4/4 +f 5/5 8/6 7/7 6/8 +f 1/1 5/5 6/8 2/2 +f 2/9 6/10 7/11 3/12 +f 3/12 7/11 8/13 4/14 +f 5/5 1/1 4/14 8/13 diff --git a/computer/recipes.lua b/computer/recipes.lua index e4335a1c..243292af 100644 --- a/computer/recipes.lua +++ b/computer/recipes.lua @@ -3,132 +3,141 @@ -- License is WTFPL (see README.txt). minetest.register_craft({ - output = "computer:shefriendSOO"; + output = "computer:shefriendSOO", recipe = { - { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", }, - { "homedecor:plastic_sheeting", "default:glass", "homedecor:plastic_sheeting", }, - { "homedecor:plastic_sheeting", "default:wood", "homedecor:plastic_sheeting", }, - }; -}); + { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }, + { "homedecor:plastic_sheeting", "default:glass", "homedecor:plastic_sheeting" }, + { "homedecor:plastic_sheeting", "default:wood", "homedecor:plastic_sheeting" } + } +}) minetest.register_craft({ - output = "computer:slaystation"; + output = "computer:slaystation", recipe = { - { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", }, - { "homedecor:plastic_sheeting", "default:wood", "homedecor:plastic_sheeting", }, - }; -}); + { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }, + { "homedecor:plastic_sheeting", "default:wood", "homedecor:plastic_sheeting" } + } +}) minetest.register_craft({ - output = "computer:vanio"; + output = "computer:vanio", recipe = { - { "homedecor:plastic_sheeting", "", "", }, + { "homedecor:plastic_sheeting", "", "" }, { "default:glass", "", "" }, - { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", }, - }; -}); + { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" } + } +}) minetest.register_craft({ - output = "computer:specter"; + output = "computer:specter", recipe = { - { "", "", "homedecor:plastic_sheeting", }, - { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", }, - { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", }, - }; -}); + { "", "", "homedecor:plastic_sheeting" }, + { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }, + { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" } + } +}) minetest.register_craft({ - output = "computer:slaystation2"; + output = "computer:slaystation2", recipe = { - { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", }, - { "homedecor:plastic_sheeting", "default:steel_ingot", "homedecor:plastic_sheeting", }, - }; -}); + { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }, + { "homedecor:plastic_sheeting", "default:steel_ingot", "homedecor:plastic_sheeting" } + } +}) minetest.register_craft({ - output = "computer:admiral64"; + output = "computer:admiral64", recipe = { - { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", }, - { "default:wood", "default:wood", "default:wood", }, - }; -}); + { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }, + { "default:wood", "default:wood", "default:wood" } + } +}) minetest.register_craft({ - output = "computer:admiral128"; + output = "computer:admiral128", recipe = { - { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", }, - { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot", }, - }; -}); + { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }, + { "default:steel_ingot", "default:steel_ingot", "default:steel_ingot" } + } +}) minetest.register_craft({ - output = "computer:wee"; + output = "computer:wee", recipe = { - { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", }, - { "homedecor:plastic_sheeting", "default:copper_ingot", "homedecor:plastic_sheeting", }, - }; -}); + { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }, + { "homedecor:plastic_sheeting", "default:copper_ingot", "homedecor:plastic_sheeting" } + } +}) minetest.register_craft({ - output = "computer:piepad"; + output = "computer:piepad", recipe = { - { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", }, - { "homedecor:plastic_sheeting", "default:glass", "homedecor:plastic_sheeting", }, - }; -}); + { "homedecor:plastic_sheeting", "homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }, + { "homedecor:plastic_sheeting", "default:glass", "homedecor:plastic_sheeting" } + } +}) --new stuff minetest.register_craft({ - output = "computer:monitor"; + output = "computer:monitor", recipe = { - { "homedecor:plastic_sheeting", "default:glass","", }, - { "homedecor:plastic_sheeting", "default:glass","", }, - { "homedecor:plastic_sheeting", "default:mese_crystal_fragment", "homedecor:plastic_sheeting", }, - }; -}); + { "homedecor:plastic_sheeting", "default:glass","" }, + { "homedecor:plastic_sheeting", "default:glass","" }, + { "homedecor:plastic_sheeting", "default:mese_crystal_fragment", "homedecor:plastic_sheeting" } + } +}) minetest.register_craft({ - output = "computer:router"; + output = "computer:router", recipe = { - { "default:steel_ingot","","", }, - { "default:steel_ingot" ,"homedecor:plastic_sheeting", "homedecor:plastic_sheeting", }, - { "default:mese_crystal_fragment","homedecor:plastic_sheeting", "homedecor:plastic_sheeting", }, - }; -}); + { "default:steel_ingot","","" }, + { "default:steel_ingot" ,"homedecor:plastic_sheeting", "homedecor:plastic_sheeting" }, + { "default:mese_crystal_fragment","homedecor:plastic_sheeting", "homedecor:plastic_sheeting" } + } +}) minetest.register_craft({ - output = "computer:tower"; + output = "computer:tower", recipe = { - { "homedecor:plastic_sheeting", "default:steel_ingot", "homedecor:plastic_sheeting", }, - { "homedecor:plastic_sheeting", "default:mese_crystal", "homedecor:plastic_sheeting", }, - { "homedecor:plastic_sheeting", "default:steel_ingot", "homedecor:plastic_sheeting", }, - }; -}); + { "homedecor:plastic_sheeting", "default:steel_ingot", "homedecor:plastic_sheeting" }, + { "homedecor:plastic_sheeting", "default:mese_crystal", "homedecor:plastic_sheeting" }, + { "homedecor:plastic_sheeting", "default:steel_ingot", "homedecor:plastic_sheeting" } + } +}) minetest.register_craft({ - output = "computer:printer"; + output = "computer:printer", recipe = { - { "homedecor:plastic_sheeting", "default:steel_ingot","", }, - { "homedecor:plastic_sheeting", "default:mese_crystal", "homedecor:plastic_sheeting", }, - { "homedecor:plastic_sheeting", "default:coal_lump", "homedecor:plastic_sheeting", }, - }; -}); + { "homedecor:plastic_sheeting", "default:steel_ingot","" }, + { "homedecor:plastic_sheeting", "default:mese_crystal", "homedecor:plastic_sheeting" }, + { "homedecor:plastic_sheeting", "default:coal_lump", "homedecor:plastic_sheeting" } + } +}) minetest.register_craft({ - output = "computer:printer"; + output = "computer:printer", recipe = { - { "homedecor:plastic_sheeting", "default:steel_ingot","", }, - { "homedecor:plastic_sheeting", "default:mese_crystal", "homedecor:plastic_sheeting", }, - { "homedecor:plastic_sheeting", "dye:black", "homedecor:plastic_sheeting", }, - }; -}); + { "homedecor:plastic_sheeting", "default:steel_ingot","" }, + { "homedecor:plastic_sheeting", "default:mese_crystal", "homedecor:plastic_sheeting" }, + { "homedecor:plastic_sheeting", "dye:black", "homedecor:plastic_sheeting", } + } +}) minetest.register_craft({ - output = "computer:server"; + output = "computer:server", recipe = { { "computer:tower", "computer:tower", "computer:tower", }, - { "computer:tower", "computer:tower", "computer:tower", }, - { "computer:tower", "computer:tower", "computer:tower", }, - }; -}); + { "computer:tower", "computer:tower", "computer:tower" }, + { "computer:tower", "computer:tower", "computer:tower" } + } +}) + +minetest.register_craft({ + output = "computer:tetris_arcade", + recipe = { + { "homedecor:plastic_sheeting", "homedecor:power_crystal", "homedecor:plastic_sheeting", }, + { "dye:black", "default:glass", "dye:black" }, + { "homedecor:plastic_sheeting", "homedecor:power_crystal", "homedecor:plastic_sheeting" } + } +}) diff --git a/computer/tetris.lua b/computer/tetris.lua new file mode 100644 index 00000000..ecfb7186 --- /dev/null +++ b/computer/tetris.lua @@ -0,0 +1,282 @@ +local shapes = { + { { x = {0, 1, 0, 1}, y = {0, 0, 1, 1} } }, + + { { x = {1, 1, 1, 1}, y = {0, 1, 2, 3} }, + { x = {0, 1, 2, 3}, y = {1, 1, 1, 1} } }, + + { { x = {0, 0, 1, 1}, y = {0, 1, 1, 2} }, + { x = {1, 2, 0, 1}, y = {0, 0, 1, 1} } }, + + { { x = {1, 0, 1, 0}, y = {0, 1, 1, 2} }, + { x = {0, 1, 1, 2}, y = {0, 0, 1, 1} } }, + + { { x = {1, 2, 1, 1}, y = {0, 0, 1, 2} }, + { x = {0, 1, 2, 2}, y = {1, 1, 1, 2} }, + { x = {1, 1, 0, 1}, y = {0, 1, 2, 2} }, + { x = {0, 0, 1, 2}, y = {0, 1, 1, 1} } }, + + { { x = {1, 1, 1, 2}, y = {0, 1, 2, 2} }, + { x = {0, 1, 2, 0}, y = {1, 1, 1, 2} }, + { x = {0, 1, 1, 1}, y = {0, 0, 1, 2} }, + { x = {0, 1, 2, 2}, y = {1, 1, 1, 0} } }, + + { { x = {1, 0, 1, 2}, y = {0, 1, 1, 1} }, + { x = {1, 1, 1, 2}, y = {0, 1, 2, 1} }, + { x = {0, 1, 2, 1}, y = {1, 1, 1, 2} }, + { x = {0, 1, 1, 1}, y = {1, 0, 1, 2} } } } + +local colors = { "computer_cyan.png", "computer_magenta.png", "computer_red.png", + "computer_blue.png", "computer_green.png", "computer_orange.png", "computer_yellow.png" } + +local background = "image[0,0;3.55,6.66;computer_black.png]" +local buttons = "button[3,4.5;0.6,0.6;left;◄]" + .."button[3.6,4.5;0.6,0.6;rotateleft;L]" + .."button[4.2,4.5;0.6,0.6;down;V]" + .."button[4.2,5.3;0.6,0.6;drop;▼]" + .."button[4.8,4.5;0.6,0.6;rotateright;R]" + .."button[5.4,4.5;0.6,0.6;right;►]" + .."button[3.5,3;2,2;new;New Game]" + +local formsize = "size[5.9,5.7]" +local boardx, boardy = 0, 0 +local sizex, sizey, size = 0.29, 0.29, 0.31 + +local comma = "," +local semi = ";" +local close = "]" + +local concat = table.concat +local insert = table.insert + +local draw_shape = function(id, x, y, rot, posx, posy) + local d = shapes[id][rot] + local scr = {} + local ins = #scr + + for i=1,4 do + local tmp = { "image[", + (d.x[i]+x)*sizex+posx, comma, + (d.y[i]+y)*sizey+posy, semi, + size, comma, size, semi, + colors[id], close } + + ins = ins + 1 + scr[ins] = concat(tmp) + end + + return concat(scr) +end + +local function step(pos, fields) + local meta = minetest.get_meta(pos) + local t = minetest.deserialize(meta:get_string("tetris")) + + local function new_game(pos) + local nex = math.random(7) + + t = { + board = {}, + boardstring = "", + previewstring = draw_shape(nex, 0, 0, 1, 4, 1), + score = 0, + cur = math.random(7), + nex = nex, + x=4, y=0, rot=1 + } + + local timer = minetest.get_node_timer(pos) + timer:set(0.3, 0) + end + + local function update_boardstring() + local scr = {} + local ins = #scr + + for i, line in pairs(t.board) do + for _, tile in pairs(line) do + local tmp = { "image[", + tile[1]*sizex+boardx, comma, + i*sizey+boardy, semi, + size, comma, size, semi, + colors[tile[2]], close } + + ins = ins + 1 + scr[ins] = concat(tmp) + end + end + + t.boardstring = concat(scr) + end + + local function add() + local d = shapes[t.cur][t.rot] + + for i=1,4 do + local l = d.y[i] + t.y + if not t.board[l] then t.board[l] = {} end + insert(t.board[l], {d.x[i] + t.x, t.cur}) + end + end + + local function scroll(l) + for i=l, 1, -1 do + t.board[i] = t.board[i-1] or {} + end + end + + local function check_lines() + for i, line in pairs(t.board) do + if #line >= 10 then + scroll(i) + t.score = t.score + 20 + end + end + end + + local function check_position(x, y, rot) + local d = shapes[t.cur][rot] + + for i=1,4 do + local cx, cy = d.x[i]+x, d.y[i]+y + + if cx < 0 or cx > 9 or cy < 0 or cy > 19 then + return false + end + + for _, tile in pairs(t.board[ cy ] or {}) do + if tile[1] == cx then return false end + end + end + + return true + end + + local function stuck() + if check_position(t.x, t.y+1, t.rot) then return false end + return true + end + + local function tick() + if stuck() then + if t.y <= 0 then + return false end + add() + check_lines() + update_boardstring() + t.cur, t.nex = t.nex, math.random(7) + t.x, t.y, t.rot = 4, 0, 1 + t.previewstring = draw_shape(t.nex, 0, 0, 1, 4.1, 0.6) + else + t.y = t.y + 1 + end + return true + end + + local function move(dx, dy) + local newx, newy = t.x+dx, t.y+dy + if not check_position(newx, newy, t.rot) then return end + t.x, t.y = newx, newy + end + + local function rotate(dr) + local no = #(shapes[t.cur]) + local newrot = (t.rot+dr) % no + + if newrot<1 then newrot = newrot+no end + if not check_position(t.x, t.y, newrot) then return end + t.rot = newrot + end + + local function key() + if fields.left then + move(-1, 0) + end + if fields.rotateleft then + rotate(-1) + end + if fields.down then + t.score = t.score + 1 + move(0, 1) + end + if fields.drop then + while not stuck() do + t.score = t.score + 2 + move(0, 1) + end + end + if fields.rotateright then + rotate(1) + end + if fields.right then + move(1, 0) + end + end + + local run = true + + if fields then + if fields.new then + new_game(pos) + else + key(fields) + end + else + run = tick() + end + + if t ~= nil then + local scr = { formsize, background, + t.boardstring, t.previewstring, + draw_shape(t.cur, t.x, t.y, t.rot, boardx, boardy), + "label[3.8,0.1;Next...]label[3.8,2.7;Score: ", + t.score, close, buttons } + + + meta:set_string("formspec", concat(scr) + ..default.gui_bg..default.gui_bg_img..default.gui_slots) + meta:set_string("tetris", minetest.serialize(t)) + end + + return run +end + +local arcade = { + description="Tetris Arcade", + drawtype = "mesh", + mesh = "tetris_arcade.obj", + tiles = {"tetris_arcade.png"}, + paramtype = "light", + paramtype2 = "facedir", + groups = {snappy=3}, + selection_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 1.5, 0.5} + }, + collision_box = { + type = "fixed", + fixed = {-0.5, -0.5, -0.5, 0.5, 1.5, 0.5} + }, + on_construct = function(pos) + local meta = minetest.get_meta(pos) + meta:set_string("formspec", formsize.."button[2,2.5;2,2;new;New Game]" + ..default.gui_bg..default.gui_bg_img..default.gui_slots) + end, + on_timer = function(pos) + return step(pos, nil) + end, + on_receive_fields = function(pos, formanme, fields, sender) + step(pos, fields) + end, + on_place = function(itemstack, placer, pointed_thing) + local pos = pointed_thing.above + if minetest.get_node({x=pos.x, y=pos.y+1, z=pos.z}).name ~= "air" then + minetest.chat_send_player(placer:get_player_name(), "No room for place the Arcade!") + return end + local dir = placer:get_look_dir() + local node = {name="computer:tetris_arcade", param1=0, param2 = minetest.dir_to_facedir(dir)} + minetest.set_node(pos, node) + itemstack:take_item() + end +} + +minetest.register_node("computer:tetris_arcade", arcade) diff --git a/computer/textures/computer_black.png b/computer/textures/computer_black.png new file mode 100644 index 0000000000000000000000000000000000000000..e4e017f4d22c5f775bad7d676bbe3f2b9a39547b GIT binary patch literal 82 zcmeAS@N?(olHy`uVBq!ia0vp^j3CU&3?x-=hn)ga%mF?ju0VQumF+Dc#pUVZ7{YNq aIRVIKVqkovxW^dCV(@hJb6Mw<&;$TJXAmg> literal 0 HcmV?d00001 diff --git a/computer/textures/computer_blue.png b/computer/textures/computer_blue.png new file mode 100644 index 0000000000000000000000000000000000000000..a5a5977268535b7df9088b10377544bbf7bd9df1 GIT binary patch literal 114 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!93?!50ihlx9oB=)|t_%#*7#Nxu7`C*iFMbRZ zRPl6i4B@z*9I-X)s+Yh<5f`7-h=T_dyredon3zmS)au}1Wn$>>7d~US_<$o&J%gvK KpUXO@geCxqogGpD literal 0 HcmV?d00001 diff --git a/computer/textures/computer_cyan.png b/computer/textures/computer_cyan.png new file mode 100644 index 0000000000000000000000000000000000000000..b2c037ead1e0b1e71e91be02b9b20030601c658a GIT binary patch literal 114 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!93?!50ihlx9oB=)|t_;tfF`PKT@atDSx8hl# zpo*u9V+hCfKQy; L{an^LB{Ts5PG}$< literal 0 HcmV?d00001 diff --git a/computer/textures/computer_green.png b/computer/textures/computer_green.png new file mode 100644 index 0000000000000000000000000000000000000000..444cce542f1dce694b5d4064bfde90ddb9b5e911 GIT binary patch literal 114 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!93?!50ihlx9oB=)|t_*h=81^wR{9>3~YI+eU zsN(737{YNqIbv(pRWE^!A}&6u5eE+_cu8$EF)^8vsMW#2%EZv$FMP&u@c~DmdInEd KKbLh*2~7aGRUP*L literal 0 HcmV?d00001 diff --git a/computer/textures/computer_magenta.png b/computer/textures/computer_magenta.png new file mode 100644 index 0000000000000000000000000000000000000000..e5b9d0448cc1ee33596352d522ac64a6a9a91981 GIT binary patch literal 114 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!93?!50ihlx9oB=)|uFn{sonScei{aPVH>PSp zK^0FI#}JO|$q`$#u6hY<6mjuMjW~Ef!AokRiHXUSM6C`ERwjo2e&I8Qiw`&g)iZdy L`njxgN@xNAc|;(( literal 0 HcmV?d00001 diff --git a/computer/textures/computer_orange.png b/computer/textures/computer_orange.png new file mode 100644 index 0000000000000000000000000000000000000000..27792f7c85549837f677608b2ecc65859d9f42e1 GIT binary patch literal 114 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!93?!50ihlx9oB=)|u6HUJ_C+!Ln#OSW+KQy; L{an^LB{Ts5IMpA{ literal 0 HcmV?d00001 diff --git a/computer/textures/computer_red.png b/computer/textures/computer_red.png new file mode 100644 index 0000000000000000000000000000000000000000..adcd6272f4058b9fb74e23b2b576264d40e78bf4 GIT binary patch literal 114 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!93?!50ihlx9oB=)|uFn`4PB1Y1VqoZBUR?(i zRPl6i4B@z*9I-X)s+Yh<5f`7-h=T_dyredon3zmS)au}1Wn$>>7d~US_<$o&J%gvK KpUXO@geCyV`W`F* literal 0 HcmV?d00001 diff --git a/computer/textures/computer_yellow.png b/computer/textures/computer_yellow.png new file mode 100644 index 0000000000000000000000000000000000000000..29537accbef071b93156984b4672c036d867eaf0 GIT binary patch literal 114 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!93?!50ihlx9oB=)|uFsw^?Ayoi>lZ`VaW*!f zpo*u9V+hCfKQy; L{an^LB{Ts5JXs&Q literal 0 HcmV?d00001 diff --git a/computer/textures/tetris_arcade.png b/computer/textures/tetris_arcade.png new file mode 100644 index 0000000000000000000000000000000000000000..dfd176df1f5865e486e074873853ab0c1ba97bb0 GIT binary patch literal 9326 zcmV-!B$3;RP)tIX*WwJ1;LYHZ?moHaI*zK{`1-IyyTwH99mjIWaLc zHa9vnG&npxKRGx&H#RyuJ3TKhF)%MQHZ?jvKSMn|J~lNu6%-aYIXp2jGY$?96ciOa zJUtT<6A%y)J32oyGB-OqJ{cJrJv~AnA0jO+Fe)l7A|fOf78g1=JS!_OC@3p8I6XT% zI}8jA7Z({gH#jsiH5(fpIy*fkCMg{qA1y61KtDh;H8?>*L^wG*YI=hJlF@%+zGc!0fHaLfvpJsP|c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