mirror of https://github.com/LDDestroier/CC/
Added chip selector, win/lose, vulcan flinch
What an update, like damn
This commit is contained in:
parent
23aa819c24
commit
f4d7b3f893
|
@ -20,7 +20,7 @@ return {
|
||||||
info.player.cooldown.shoot = 4
|
info.player.cooldown.shoot = 4
|
||||||
return false
|
return false
|
||||||
elseif info.frame % 2 == 0 then
|
elseif info.frame % 2 == 0 then
|
||||||
act.projectile.newProjectile(info.x, info.y, info.player, "vulcan_internal")
|
act.projectile.newProjectile(info.x, info.y, info.player, "vulcan_internal", frame < 12 * 2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -20,7 +20,7 @@ return {
|
||||||
info.player.cooldown.shoot = 4
|
info.player.cooldown.shoot = 4
|
||||||
return false
|
return false
|
||||||
elseif info.frame % 2 == 0 then
|
elseif info.frame % 2 == 0 then
|
||||||
act.projectile.newProjectile(info.x, info.y, info.player, "vulcan_internal")
|
act.projectile.newProjectile(info.x, info.y, info.player, "vulcan_internal", info.frame < 3 * 2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -20,7 +20,7 @@ return {
|
||||||
info.player.cooldown.shoot = 4
|
info.player.cooldown.shoot = 4
|
||||||
return false
|
return false
|
||||||
elseif info.frame % 2 == 0 then
|
elseif info.frame % 2 == 0 then
|
||||||
act.projectile.newProjectile(info.x, info.y, info.player, "vulcan_internal")
|
act.projectile.newProjectile(info.x, info.y, info.player, "vulcan_internal", info.frame < 5 * 2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -20,7 +20,7 @@ return {
|
||||||
info.player.cooldown.shoot = 4
|
info.player.cooldown.shoot = 4
|
||||||
return false
|
return false
|
||||||
elseif info.frame % 2 == 0 then
|
elseif info.frame % 2 == 0 then
|
||||||
act.projectile.newProjectile(info.x, info.y, info.player, "vulcan_internal")
|
act.projectile.newProjectile(info.x, info.y, info.player, "vulcan_internal", info.frame < 7 * 2)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
return true
|
return true
|
||||||
|
|
|
@ -11,12 +11,12 @@ return {
|
||||||
logic = function(info)
|
logic = function(info)
|
||||||
info.x = info.x + (3 / stage.panelWidth) * info.direction
|
info.x = info.x + (3 / stage.panelWidth) * info.direction
|
||||||
|
|
||||||
act.stage.setDamage(info.x, info.y, 10, info.owner, 1, true)
|
act.stage.setDamage(info.x, info.y, 10, info.owner, 1, info.noFlinch)
|
||||||
|
|
||||||
local struckPlayer, struckObject = act.projectile.checkProjectileCollisions(info)
|
local struckPlayer, struckObject = act.projectile.checkProjectileCollisions(info)
|
||||||
|
|
||||||
if info.frame > 50 or struckPlayer or struckObject then
|
if info.frame > 50 or struckPlayer or struckObject then
|
||||||
act.stage.setDamage(info.x + info.direction, info.y, 10, info.owner, 1, true)
|
act.stage.setDamage(info.x + info.direction, info.y, 10, info.owner, 1, info.noFlinch)
|
||||||
return false
|
return false
|
||||||
else
|
else
|
||||||
return true, {{images.cannon, info.x, info.y}}
|
return true, {{images.cannon, info.x, info.y}}
|
||||||
|
|
655
CCBN/ccbn.lua
655
CCBN/ccbn.lua
|
@ -12,9 +12,22 @@ config.objectDir = fs.combine(config.mainDir, "objectdata")
|
||||||
local players = {}
|
local players = {}
|
||||||
local objects = {}
|
local objects = {}
|
||||||
local projectiles = {}
|
local projectiles = {}
|
||||||
|
local game = {
|
||||||
|
custom = 0,
|
||||||
|
customMax = 200,
|
||||||
|
customSpeed = 1,
|
||||||
|
inChipSelect = true,
|
||||||
|
paused = false
|
||||||
|
}
|
||||||
|
|
||||||
local you = 1
|
local you = 1
|
||||||
local yourID = os.getComputerID()
|
local yourID = os.getComputerID()
|
||||||
|
|
||||||
|
local revKeys = {}
|
||||||
|
for k,v in pairs(keys) do
|
||||||
|
revKeys[v] = k
|
||||||
|
end
|
||||||
|
|
||||||
-- recommended at 0.1 for netplay, which you'll be doing all the time so yeah
|
-- recommended at 0.1 for netplay, which you'll be doing all the time so yeah
|
||||||
local gameDelayInit = 0.05
|
local gameDelayInit = 0.05
|
||||||
|
|
||||||
|
@ -82,6 +95,8 @@ local stage = {
|
||||||
scrollY = 6
|
scrollY = 6
|
||||||
}
|
}
|
||||||
|
|
||||||
|
stage.scrollX = -1 + (scr_x - (6 * stage.panelWidth)) / 2
|
||||||
|
|
||||||
local stageChanged = true
|
local stageChanged = true
|
||||||
|
|
||||||
local round = function(num)
|
local round = function(num)
|
||||||
|
@ -308,8 +323,93 @@ local receive = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
local images = {
|
local images = {
|
||||||
win = {{" ","
"," "," "," "},{"dd ddfdddfddd dd dd dddddddddf ddfdf","ffdfdddd ddddd dd dd fd dd dd ddfd ddfdd"," dddd dd dddd dd dd ddd dd dd ddddfddddd"," dd df fdddd dd fdfdfdfd dd dd dfdd dd"," dd dddddddddddd ddd ddd dddddddd dd dd"},{"df dfdddddfdf df df dfdddddfdd dfddd","ddfddfdf fdfdf df df dd df df dddf dfddd"," fdff df dfdf df df ddf df df dffdddffdf"," df dd ddfdf df dddddddd df df fddf ff"," df fdddfffdddff ddf ddf dddddfdf df df"}},
|
logo = {
|
||||||
lose = {{" "," ","
"," "," "},{"eeeff eeeeeeee eeeeeeeeeeeeeeeeeeeeeff ","ee eeeee ee ee ee ee ee eee","ee eeeeeee ee eeeee ee eeeee ee ee","ee feeee ee ee ee ee ee fee","eeeee eeeeeeeeeeeeeeeeee ee eeeeeeeeeee "},{"eeeee eeeeefef eeeeefeeeeefeeeeefeeeee","ef fefef ef ef ef ef ef fef","ef efeffff ef effff ef effff ef ef","ef eefef ef ef ef ef ef eef","eeeff eeeeefeeeeefeeeeef ef eeeeefeeeff "}},
|
{
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
"
",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
"
",
|
||||||
|
"
",
|
||||||
|
" ",
|
||||||
|
"
",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
" f3ff3f333 f333ff3f3333f33f3f3f3ff3f3f3ff333333 ",
|
||||||
|
" b ffbfbbbbfbbbbfbfb b fbbfbfbb ffbfbbbbfbb b ",
|
||||||
|
" bbbbbbbb bbb bbbb b bbbbbbbbbbbbbbbfbbb b ",
|
||||||
|
" a11aa11a11a111a11a1aaa111aaaaaaaaaa3fa ",
|
||||||
|
" aaa1aaa1aa1aaaa1aa1aa1aaaaeeeeeeee33aaa",
|
||||||
|
" a1a1a1a1aa1aaaa1aa1aa1aaaeeeeeee00eeeef",
|
||||||
|
" faaa1a1a1aa1aaaa1aaaa11aa1eeeee00eeeeeea",
|
||||||
|
"faaaa1a1111a11a1aaaaaa1a1a1a1a1aaa1eee00eeeeeeeea",
|
||||||
|
"f1a1a11aaaaa1aaa1a11a1a1aa11aa11a1aa33eeeeeeeeea ",
|
||||||
|
"f1a1a11aaaaa1aa1aa1aa1a1aa11aa111aaa33aeeeeeeea ",
|
||||||
|
"a1aa111111a11aaa11a11aa11111a111a11aaaaaaaaaa ",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
" 3f33f3f3f 3f3f33f3ff3f3ff3f3f3f33f3f3f33ffff3f ",
|
||||||
|
" b bbfbfbffbfbffbfbf b bffbfbfb bbfbfbfbbff b ",
|
||||||
|
" ffffffff fff ffff f fffffffffffffffffff f ",
|
||||||
|
" 1aa11aa1aa1aaa1aa1aaa1aaaaaeeeeeee3aaf ",
|
||||||
|
" 111a1111aa1aaa1aa1aaa111aeeeeeeeee333af",
|
||||||
|
" 1aa11aa1aa1aaa1aa1aaa1aaaeeeeeeeeeeeeaa",
|
||||||
|
" a111a1aa1aa1aaa1aa111a111aeeeeeeeeeeeeaa",
|
||||||
|
"a1aa1a1aaaa1aa1aaaaaa1a1a1a1a1a1a1aeeeeeeeeeeeeaf",
|
||||||
|
"a11a1a111aa1aaa1a11a1aa1a1a111a11aa333eeeeeeeeaa ",
|
||||||
|
"a1aa1a1aaaa1aaaa11a11aa1a1a1a1a1a1aaaaeeeeaaaaf ",
|
||||||
|
" aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaffffffffff ",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
win = {
|
||||||
|
{
|
||||||
|
" ",
|
||||||
|
"
",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"55 55f555f555 55 55 555555555f 55f5f",
|
||||||
|
"ff5f5555 55555 55 55 f5 55 55 55f5 55f55",
|
||||||
|
" 5555 55 5555 55 55 555 55 55 5555f55555",
|
||||||
|
" 55 5f f5555 55 f5f5f5f5 55 55 5f55 55",
|
||||||
|
" 55 555555555555 555f555 55555555 55 55",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"5f 5f55555f5f 5f 5f 5f55555f55 5f555",
|
||||||
|
"55f55f5f f5f5f 5f 5f 55 5f 5f 555f 5f555",
|
||||||
|
" f5ff 5f 5f5f 5f 5f 55f 5f 5f 5ff555ff5f",
|
||||||
|
" 5f 55 55f5f 5f 55555555 5f 5f f55f ff",
|
||||||
|
" 5f f555fff555ff 55ff55f 55555f5f 5f 5f",
|
||||||
|
},
|
||||||
|
},
|
||||||
|
lose = {
|
||||||
|
{
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
"
",
|
||||||
|
" ",
|
||||||
|
" ",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"111ff 11111111 111111111111111111111ff ",
|
||||||
|
"11 11111 11 11 11 11 11 111",
|
||||||
|
"11 1111111 11 11111 11 11111 11 11",
|
||||||
|
"11 f1111 11 11 11 11 11 f11",
|
||||||
|
"11111 111111111111111111 11 11111111111 ",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"11111 11111f1f 11111f11111f11111f11111 ",
|
||||||
|
"1f f1f1f 1f 1f 1f 1f 1f f1f",
|
||||||
|
"1f 1f1ffff 1f 1ffff 1f 1ffff 1f 1f",
|
||||||
|
"1f 11f1f 1f 1f 1f 1f 1f 11f",
|
||||||
|
"111ff 11111f11111f11111f 1f 11111f111ff ",
|
||||||
|
},
|
||||||
|
},
|
||||||
panel = {
|
panel = {
|
||||||
normal = {{"","",""},{"eeeee7","e78877","eeeeee"},{"77777e","78888e","eeeeee"}},
|
normal = {{"","",""},{"eeeee7","e78877","eeeeee"},{"77777e","78888e","eeeeee"}},
|
||||||
cracked = {{"","",""},{"eeeee7","e88888","eeeeee"},{"77777e","87777e","eeeeee"}},
|
cracked = {{"","",""},{"eeeee7","e88888","eeeeee"},{"77777e","87777e","eeeeee"}},
|
||||||
|
@ -324,6 +424,12 @@ local images = {
|
||||||
buster = {{""},{"f4"},{"4f"}}
|
buster = {{""},{"f4"},{"4f"}}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
local cwrite = function(text, y)
|
||||||
|
local cx, cy = term.getCursorPos()
|
||||||
|
term.setCursorPos(scr_x / 2 - #text / 2, y or (scr_y / 2))
|
||||||
|
term.write(text)
|
||||||
|
end
|
||||||
|
|
||||||
local act = {stage = {}, player = {}, projectile = {}, object = {}}
|
local act = {stage = {}, player = {}, projectile = {}, object = {}}
|
||||||
act.stage.newPanel = function(x, y, panelType, owner)
|
act.stage.newPanel = function(x, y, panelType, owner)
|
||||||
stage.panels[y] = stage.panels[y] or {}
|
stage.panels[y] = stage.panels[y] or {}
|
||||||
|
@ -409,6 +515,105 @@ act.stage.getDamage = function(x, y, pID, oID, pIDsafeCheck, oIDsafeCheck)
|
||||||
return totalDamage, flinching
|
return totalDamage, flinching
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local premadeFolders = {
|
||||||
|
[1] = { -- BN2 starting folder, modified slightly
|
||||||
|
{"cannon", "a"},
|
||||||
|
{"cannon", "a"},
|
||||||
|
{"hicannon", "b"},
|
||||||
|
{"hicannon", "b"},
|
||||||
|
{"shotgun", "b"},
|
||||||
|
{"shotgun", "b"},
|
||||||
|
{"vgun", "l"},
|
||||||
|
{"vgun", "l"},
|
||||||
|
{"crossgun", "l"},
|
||||||
|
{"minibomb", "b"},
|
||||||
|
{"minibomb", "b"},
|
||||||
|
{"lilbomb", "b"},
|
||||||
|
{"recov120", "a"},
|
||||||
|
{"recov120", "a"},
|
||||||
|
{"recov80", "l"},
|
||||||
|
{"recov50", "l"},
|
||||||
|
{"recov50", "l"},
|
||||||
|
{"sword", "s"},
|
||||||
|
{"sword", "s"},
|
||||||
|
{"sword", "s"},
|
||||||
|
{"panelreturn", "s"},
|
||||||
|
{"widesword", "s"},
|
||||||
|
{"widesword", "s"},
|
||||||
|
{"longsword", "s"},
|
||||||
|
{"busterup", "s"},
|
||||||
|
{"crackout", "b"},
|
||||||
|
{"shockwave", "b"},
|
||||||
|
{"areagrab", "s"},
|
||||||
|
{"areagrab", "s"},
|
||||||
|
{"panelgrab", "s"},
|
||||||
|
},
|
||||||
|
[2] = {
|
||||||
|
{"cannon", "a"},
|
||||||
|
{"cannon", "a"},
|
||||||
|
{"hicannon", "a"},
|
||||||
|
{"hicannon", "a"},
|
||||||
|
{"mcannon", "a"},
|
||||||
|
{"mcannon", "a"},
|
||||||
|
{"airshot1", "a"},
|
||||||
|
{"airshot1", "a"},
|
||||||
|
{"airshot2", "a"},
|
||||||
|
{"vulcan1", "c"},
|
||||||
|
{"vulcan1", "c"},
|
||||||
|
{"shockwave", "c"},
|
||||||
|
{"minibomb", "c"},
|
||||||
|
{"minibomb", "c"},
|
||||||
|
{"crossbomb", "c"},
|
||||||
|
{"panelreturn", "s"},
|
||||||
|
{"sword", "s"},
|
||||||
|
{"sword", "s"},
|
||||||
|
{"longsword", "s"},
|
||||||
|
{"busterup", "s"},
|
||||||
|
{"widesword", "s"},
|
||||||
|
{"rockcube", "a"},
|
||||||
|
{"areagrab", "s"},
|
||||||
|
{"areagrab", "s"},
|
||||||
|
{"panelgrab", "s"},
|
||||||
|
{"panelshot", "s"},
|
||||||
|
{"panelshot", "s"},
|
||||||
|
{"recov50", "l"},
|
||||||
|
{"recov50", "l"},
|
||||||
|
{"recov50", "l"},
|
||||||
|
},
|
||||||
|
[3] = {
|
||||||
|
{"cannon", "a"},
|
||||||
|
{"hicannon", "a"},
|
||||||
|
{"mcannon", "b"},
|
||||||
|
{"airshot2", "a"},
|
||||||
|
{"airshot2", "a"},
|
||||||
|
{"rockcube", "s"},
|
||||||
|
{"shockwave", "a"},
|
||||||
|
{"lilbomb", "l"},
|
||||||
|
{"lilbomb", "l"},
|
||||||
|
{"areagrab", "s"},
|
||||||
|
{"areagrab", "s"},
|
||||||
|
{"fightersword", "f"},
|
||||||
|
{"panelreturn", "s"},
|
||||||
|
{"panelreturn", "s"},
|
||||||
|
{"panelshot", "f"},
|
||||||
|
{"panelshot", "f"},
|
||||||
|
{"doubleshot", "f"},
|
||||||
|
{"tripleshot", "f"},
|
||||||
|
{"invis", "l"},
|
||||||
|
{"recov30", "l"},
|
||||||
|
{"recov30", "l"},
|
||||||
|
{"vulcan2", "c"},
|
||||||
|
{"vulcan1", "c"},
|
||||||
|
{"vulcan1", "c"},
|
||||||
|
{"geddon1", "f"},
|
||||||
|
{"shotgun", "d"},
|
||||||
|
{"shotgun", "d"},
|
||||||
|
{"vgun", "d"},
|
||||||
|
{"vgun", "d"},
|
||||||
|
{"spreader", "d"},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
act.player.newPlayer = function(x, y, owner, direction, image)
|
act.player.newPlayer = function(x, y, owner, direction, image)
|
||||||
local pID = #players + 1
|
local pID = #players + 1
|
||||||
players[pID] = {
|
players[pID] = {
|
||||||
|
@ -417,11 +622,12 @@ act.player.newPlayer = function(x, y, owner, direction, image)
|
||||||
owner = owner, -- Either 1 or 2, indicates the red/blue alignment
|
owner = owner, -- Either 1 or 2, indicates the red/blue alignment
|
||||||
type = "player", -- Used for quickly identifying a player/object/projectile at a glance
|
type = "player", -- Used for quickly identifying a player/object/projectile at a glance
|
||||||
direction = direction or 1, -- Either -1 or 1, indicates facing left or right
|
direction = direction or 1, -- Either -1 or 1, indicates facing left or right
|
||||||
health = 1000, -- Once it hits 0, your player is deleted
|
health = 600, -- Once it hits 0, your player is deleted
|
||||||
maxHealth = 1000, -- You cannot regen past this value
|
maxHealth = 600, -- You cannot heal past this value
|
||||||
image = image, -- Because of CC limitations, I'm just going to have one player sprite
|
image = image, -- Because of CC limitations, I'm just going to have one player sprite
|
||||||
canMove = true, -- If false, pushing the move buttons won't do diddly fuck
|
canMove = true, -- If false, pushing the move buttons won't do diddly fuck
|
||||||
canShoot = true, -- If false, pushing the shoot buttons won't do fuckly did
|
canShoot = true, -- If false, pushing the shoot buttons won't do fuckly didd
|
||||||
|
isDead = false, -- If true, the current game is over and the opponent wins
|
||||||
busterPower = 2, -- Strength of MegaBuster
|
busterPower = 2, -- Strength of MegaBuster
|
||||||
cooldown = { -- All cooldown values are decremented every tick
|
cooldown = { -- All cooldown values are decremented every tick
|
||||||
move = 0, -- If above 0, you cannot move
|
move = 0, -- If above 0, you cannot move
|
||||||
|
@ -437,11 +643,9 @@ act.player.newPlayer = function(x, y, owner, direction, image)
|
||||||
chip = false,
|
chip = false,
|
||||||
custom = false
|
custom = false
|
||||||
},
|
},
|
||||||
chipQueue = {} -- Attacks are used in a queue, which is filled each turn
|
chipQueue = {}, -- Attacks are used in a queue, which is filled each turn
|
||||||
|
folder = premadeFolders[math.random(1, 3)]
|
||||||
}
|
}
|
||||||
for k,v in pairs(chips) do
|
|
||||||
players[pID].chipQueue[#players[pID].chipQueue + 1] = k
|
|
||||||
end
|
|
||||||
return pID
|
return pID
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -695,12 +899,6 @@ act.projectile.newProjectile = function(x, y, player, chipType, noFlinch, altDam
|
||||||
return id
|
return id
|
||||||
end
|
end
|
||||||
|
|
||||||
for y = 1, 3 do
|
|
||||||
for x = 1, 6 do
|
|
||||||
act.stage.newPanel(x, y, "normal")
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
-- loads all chips and objects from file
|
-- loads all chips and objects from file
|
||||||
local loadChips = function(env)
|
local loadChips = function(env)
|
||||||
local cList = fs.list(config.chipDir)
|
local cList = fs.list(config.chipDir)
|
||||||
|
@ -734,11 +932,6 @@ local loadChips = function(env)
|
||||||
return cOutput, oOutput
|
return cOutput, oOutput
|
||||||
end
|
end
|
||||||
|
|
||||||
chips, objectTypes = loadChips(getfenv())
|
|
||||||
|
|
||||||
act.player.newPlayer(2, 2, 1, 1, "6")
|
|
||||||
act.player.newPlayer(5, 2, 2, -1, "7")
|
|
||||||
|
|
||||||
local stageImageStitch
|
local stageImageStitch
|
||||||
|
|
||||||
local makeStageImageStitch = function()
|
local makeStageImageStitch = function()
|
||||||
|
@ -762,8 +955,8 @@ local makeStageImageStitch = function()
|
||||||
end
|
end
|
||||||
buffer[#buffer + 1] = {
|
buffer[#buffer + 1] = {
|
||||||
im,
|
im,
|
||||||
(x - 1) * stage.panelWidth + 2,
|
(x - 1) * stage.panelWidth + 1,
|
||||||
(y - 1) * stage.panelHeight + 2
|
(y - 1) * stage.panelHeight + 1
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -772,7 +965,7 @@ local makeStageImageStitch = function()
|
||||||
return merge(table.unpack(buffer))
|
return merge(table.unpack(buffer))
|
||||||
end
|
end
|
||||||
|
|
||||||
local render = function()
|
local render = function(extraImage)
|
||||||
local buffer, im = {}
|
local buffer, im = {}
|
||||||
local sx, sy
|
local sx, sy
|
||||||
if stageChanged or true then
|
if stageChanged or true then
|
||||||
|
@ -790,20 +983,29 @@ local render = function()
|
||||||
sortedList[#sortedList+1] = v
|
sortedList[#sortedList+1] = v
|
||||||
end
|
end
|
||||||
table.sort(sortedList, function(a,b) return a.y >= b.y end)
|
table.sort(sortedList, function(a,b) return a.y >= b.y end)
|
||||||
for k,v in pairs(sortedList) do
|
if extraImage then
|
||||||
if v.type == "player" then
|
|
||||||
if v.cooldown.iframe == 0 or (FRAME % 2 == 0) then
|
|
||||||
sx = (v.x - 1) * stage.panelWidth + 3 + stage.scrollX
|
|
||||||
sy = (v.y - 1) * stage.panelHeight - 1 + stage.scrollY
|
|
||||||
buffer[#buffer + 1] = {
|
buffer[#buffer + 1] = {
|
||||||
colorSwap(images.player[v.image], {["f"] = " "}),
|
colorSwap(extraImage[1], {["f"] = " "}),
|
||||||
sx,
|
extraImage[2],
|
||||||
sy
|
extraImage[3]
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
for k,v in pairs(sortedList) do
|
||||||
|
if v.type == "player" then
|
||||||
|
if not v.isDead then
|
||||||
|
if v.cooldown.iframe == 0 or (FRAME % 2 == 0) then
|
||||||
|
sx = (v.x - 1) * stage.panelWidth + 2
|
||||||
|
sy = (v.y - 1) * stage.panelHeight - 2
|
||||||
|
buffer[#buffer + 1] = {
|
||||||
|
colorSwap(images.player[v.image], {["f"] = " "}),
|
||||||
|
sx + stage.scrollX,
|
||||||
|
sy + stage.scrollY
|
||||||
|
}
|
||||||
|
end
|
||||||
|
end
|
||||||
elseif v.type == "projectile" then
|
elseif v.type == "projectile" then
|
||||||
sx = math.floor((v.x - 1) * stage.panelWidth + 4 + stage.scrollX)
|
sx = math.floor((v.x - 1) * stage.panelWidth + 4)
|
||||||
sy = math.floor((v.y - 1) * stage.panelHeight + 1 + stage.scrollY)
|
sy = math.floor((v.y - 1) * stage.panelHeight)
|
||||||
if sx >= -1 and sx <= scr_x and v.imageData then
|
if sx >= -1 and sx <= scr_x and v.imageData then
|
||||||
|
|
||||||
for kk, imd in pairs(v.imageData) do
|
for kk, imd in pairs(v.imageData) do
|
||||||
|
@ -816,12 +1018,12 @@ local render = function()
|
||||||
|
|
||||||
end
|
end
|
||||||
elseif v.type == "object" then
|
elseif v.type == "object" then
|
||||||
sx = (v.x - 1) * stage.panelWidth + 3 + stage.scrollX
|
sx = (v.x - 1) * stage.panelWidth + 3
|
||||||
sy = (v.y - 1) * stage.panelHeight - 1 + stage.scrollY
|
sy = (v.y - 1) * stage.panelHeight
|
||||||
buffer[#buffer + 1] = {
|
buffer[#buffer + 1] = {
|
||||||
colorSwap(v.image, {["f"] = " "}),
|
colorSwap(v.image, {["f"] = " "}),
|
||||||
math.floor((v.x - 1) * stage.panelWidth + 3 + stage.scrollX),
|
math.floor(sx + stage.scrollX),
|
||||||
math.floor((v.y - 1) * stage.panelHeight + 1 + stage.scrollY)
|
math.floor(sy + stage.scrollY)
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
@ -853,6 +1055,32 @@ local render = function()
|
||||||
term.write(player.health)
|
term.write(player.health)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
term.setTextColor(colors.white)
|
||||||
|
term.setBackgroundColor(colors.black)
|
||||||
|
if game.custom == game.customMax and FRAME % 8 <= 5 then
|
||||||
|
cwrite("PUSH '" .. revKeys[control.custom]:upper() .. "'!", 2)
|
||||||
|
end
|
||||||
|
term.setBackgroundColor(colors.gray)
|
||||||
|
term.setCursorPos(6, 1)
|
||||||
|
term.write("[CUSTOM][")
|
||||||
|
local barLength = scr_x - 20
|
||||||
|
if game.custom == game.customMax then
|
||||||
|
term.setBackgroundColor(colors.lime)
|
||||||
|
else
|
||||||
|
term.setBackgroundColor(colors.green)
|
||||||
|
end
|
||||||
|
for i = 1, barLength do
|
||||||
|
if (i / barLength) <= (game.custom / game.customMax) then
|
||||||
|
term.write("=")
|
||||||
|
else
|
||||||
|
term.setBackgroundColor(colors.gray)
|
||||||
|
term.write(" ")
|
||||||
|
end
|
||||||
|
end
|
||||||
|
term.setBackgroundColor(colors.gray)
|
||||||
|
term.write("]")
|
||||||
|
|
||||||
if showDebug then
|
if showDebug then
|
||||||
term.setCursorPos(1, scr_y - 1)
|
term.setCursorPos(1, scr_y - 1)
|
||||||
term.write("Frame: " .. FRAME .. ", isHost = " .. tostring(isHost) .. ", you = " .. tostring(you))
|
term.write("Frame: " .. FRAME .. ", isHost = " .. tostring(isHost) .. ", you = " .. tostring(you))
|
||||||
|
@ -881,14 +1109,187 @@ local getInput = function()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
local chipSelectScreen = function()
|
||||||
|
local inQueue = {} -- selected chips in menu, by folder position
|
||||||
|
local pile = {} -- chips for you to choose from, by folder position
|
||||||
|
local rPile, r = {}
|
||||||
|
local player = players[you]
|
||||||
|
for i = 1, 5 do
|
||||||
|
repeat
|
||||||
|
r = math.random(1, #player.folder)
|
||||||
|
until not rPile[r]
|
||||||
|
pile[#pile + 1] = r
|
||||||
|
rPile[r] = true
|
||||||
|
end
|
||||||
|
local cursor = 1
|
||||||
|
|
||||||
|
local checkIfChoosable = function(c)
|
||||||
|
local chip, compareChip = player.folder[pile[c]]
|
||||||
|
local isSameChip = true
|
||||||
|
local isSameCode = true
|
||||||
|
for i = 1, #inQueue do
|
||||||
|
compareChip = player.folder[inQueue[i]]
|
||||||
|
if compareChip[1] ~= chip[1] then
|
||||||
|
isSameChip = false
|
||||||
|
end
|
||||||
|
if compareChip[2] ~= chip[2] then
|
||||||
|
isSameCode = false
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return isSameCode or isSameChip
|
||||||
|
end
|
||||||
|
|
||||||
|
local renderMenu = function()
|
||||||
|
local chip
|
||||||
|
term.setBackgroundColor(colors.gray)
|
||||||
|
term.setTextColor(colors.yellow)
|
||||||
|
for y = 4, scr_y - 2 do
|
||||||
|
term.setCursorPos(3, y)
|
||||||
|
term.write((" "):rep(scr_x - 4))
|
||||||
|
end
|
||||||
|
cwrite(" Select Chips: ", 3)
|
||||||
|
term.setTextColor(colors.lightGray)
|
||||||
|
cwrite(" (Push '" .. revKeys[control.chip]:upper() .. "' to add / '" .. revKeys[control.buster]:upper() .. "' to remove) ", 4)
|
||||||
|
cwrite(" (Push ENTER to confirm loadout) ", 5)
|
||||||
|
for y = 1, #pile do
|
||||||
|
if checkIfChoosable(y) then
|
||||||
|
if y == cursor then
|
||||||
|
term.setBackgroundColor(colors.lightGray)
|
||||||
|
term.setTextColor(colors.white)
|
||||||
|
else
|
||||||
|
term.setBackgroundColor(colors.gray)
|
||||||
|
term.setTextColor(colors.white)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
if y == cursor then
|
||||||
|
term.setBackgroundColor(colors.lightGray)
|
||||||
|
term.setTextColor(colors.gray)
|
||||||
|
else
|
||||||
|
term.setBackgroundColor(colors.gray)
|
||||||
|
term.setTextColor(colors.lightGray)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
chip = player.folder[pile[y]]
|
||||||
|
term.setCursorPos(4, y + 5)
|
||||||
|
term.write(chips[chip[1]].info.name .. " " .. chip[2]:upper())
|
||||||
|
end
|
||||||
|
term.setBackgroundColor(colors.gray)
|
||||||
|
term.setTextColor(colors.lightBlue)
|
||||||
|
for y = 1, #inQueue do
|
||||||
|
chip = player.folder[inQueue[y]]
|
||||||
|
term.setCursorPos(20, y + 5)
|
||||||
|
term.write(chips[chip[1]].info.name .. " " .. chip[2]:upper())
|
||||||
|
end
|
||||||
|
term.setTextColor(colors.white)
|
||||||
|
if player.folder[pile[cursor]] then
|
||||||
|
term.setCursorPos(5, 12)
|
||||||
|
term.write("Description:")
|
||||||
|
term.setCursorPos(4, 13)
|
||||||
|
term.write(chips[player.folder[pile[cursor]][1]].info.description)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local evt
|
||||||
|
while true do
|
||||||
|
-- render()
|
||||||
|
renderMenu()
|
||||||
|
evt = {os.pullEvent()}
|
||||||
|
if evt[1] == "key" then
|
||||||
|
if evt[2] == keys.up then
|
||||||
|
cursor = math.max(cursor - 1, 1)
|
||||||
|
elseif evt[2] == keys.down then
|
||||||
|
cursor = math.min(cursor + 1, #pile)
|
||||||
|
elseif evt[2] == control.chip then
|
||||||
|
if pile[cursor] then
|
||||||
|
if checkIfChoosable(cursor) then
|
||||||
|
table.insert(inQueue, pile[cursor])
|
||||||
|
table.remove(pile, cursor)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
elseif evt[2] == control.buster then
|
||||||
|
if #inQueue > 0 then
|
||||||
|
table.insert(pile, inQueue[#inQueue])
|
||||||
|
table.remove(inQueue, #inQueue)
|
||||||
|
end
|
||||||
|
elseif evt[2] == keys.enter then
|
||||||
|
player.chipQueue = {}
|
||||||
|
for i = 1, #inQueue do
|
||||||
|
player.chipQueue[#player.chipQueue + 1] = player.folder[inQueue[i]][1]
|
||||||
|
end
|
||||||
|
table.sort(inQueue, function(a,b) return a > b end)
|
||||||
|
for i = 1, #inQueue do
|
||||||
|
table.remove(inQueue, i)
|
||||||
|
end
|
||||||
|
return
|
||||||
|
end
|
||||||
|
cursor = math.min(math.max(cursor, 1), #pile)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local checkDeadPlayers = function()
|
||||||
|
local deadPlayers, thereIsDead = {}, false
|
||||||
|
for id, player in pairs(players) do
|
||||||
|
if player.isDead then
|
||||||
|
deadPlayers[id] = true
|
||||||
|
thereIsDead = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return thereIsDead, deadPlayers
|
||||||
|
end
|
||||||
|
|
||||||
|
local waitingForClientChipSelection = false
|
||||||
local runGame = function()
|
local runGame = function()
|
||||||
local evt, getStateInfo
|
local evt, getStateInfo
|
||||||
|
render()
|
||||||
|
sleep(0.5)
|
||||||
while true do
|
while true do
|
||||||
FRAME = FRAME + 1
|
FRAME = FRAME + 1
|
||||||
|
|
||||||
render()
|
render()
|
||||||
|
|
||||||
|
if game.inChipSelect then
|
||||||
|
chipSelectScreen()
|
||||||
if isHost then
|
if isHost then
|
||||||
|
game.inChipSelect = false
|
||||||
|
game.custom = 0
|
||||||
|
local msg
|
||||||
|
cwrite("Waiting...", scr_y - 3)
|
||||||
|
repeat
|
||||||
|
sleep(0)
|
||||||
|
until cliChipSelect
|
||||||
|
|
||||||
|
players[cliChipSelect.pID].chipQueue = cliChipSelect.chipQueue
|
||||||
|
players[cliChipSelect.pID].folder = cliChipSelect.folder
|
||||||
|
cliChipSelect = false
|
||||||
|
|
||||||
|
transmit({
|
||||||
|
gameID = gameID,
|
||||||
|
command = "turn_ready",
|
||||||
|
pID = you,
|
||||||
|
})
|
||||||
|
else
|
||||||
|
transmit({
|
||||||
|
gameID = gameID,
|
||||||
|
command = "turn_ready",
|
||||||
|
pID = you,
|
||||||
|
chipQueue = players[you].chipQueue,
|
||||||
|
folder = players[you].folder,
|
||||||
|
})
|
||||||
|
cwrite("Waiting...", scr_y - 3)
|
||||||
|
repeat
|
||||||
|
msg = receive()
|
||||||
|
msg = type(msg) == "table" and msg or {}
|
||||||
|
until (
|
||||||
|
msg.gameID == gameID and
|
||||||
|
msg.command == "turn_ready" and
|
||||||
|
players[msg.pID]
|
||||||
|
)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
if isHost then
|
||||||
|
game.custom = math.min(game.customMax, game.custom + 1)
|
||||||
getControls()
|
getControls()
|
||||||
for id, proj in pairs(projectiles) do
|
for id, proj in pairs(projectiles) do
|
||||||
local success, imageData = chips[proj.chipType].logic(proj)
|
local success, imageData = chips[proj.chipType].logic(proj)
|
||||||
|
@ -907,14 +1308,15 @@ local runGame = function()
|
||||||
end
|
end
|
||||||
|
|
||||||
for id, player in pairs(players) do
|
for id, player in pairs(players) do
|
||||||
|
if not player.isDead then
|
||||||
if player.canMove then
|
if player.canMove then
|
||||||
stage.panels[player.y][player.x].reserved = id
|
stage.panels[player.y][player.x].reserved = id
|
||||||
end
|
end
|
||||||
local dmg, flinching = act.stage.getDamage(player.x, player.y, id)
|
local dmg, flinching = act.stage.getDamage(player.x, player.y, id)
|
||||||
if player.cooldown.iframe == 0 and dmg > 0 then
|
if player.cooldown.iframe == 0 and dmg > 0 then
|
||||||
player.health = player.health - dmg
|
player.health = math.max(0, player.health - dmg)
|
||||||
if player.health <= 0 then
|
if player.health == 0 then
|
||||||
table.remove(players, id)
|
player.isDead = true
|
||||||
elseif flinching then
|
elseif flinching then
|
||||||
player.cooldown.iframe = 16
|
player.cooldown.iframe = 16
|
||||||
player.cooldown.move = 8
|
player.cooldown.move = 8
|
||||||
|
@ -929,7 +1331,7 @@ local runGame = function()
|
||||||
for k,v in pairs(chips[player.chipQueue[1]].info.cooldown or {}) do
|
for k,v in pairs(chips[player.chipQueue[1]].info.cooldown or {}) do
|
||||||
player.cooldown[k] = v
|
player.cooldown[k] = v
|
||||||
end
|
end
|
||||||
if false then
|
if true then
|
||||||
table.remove(player.chipQueue, 1)
|
table.remove(player.chipQueue, 1)
|
||||||
else
|
else
|
||||||
player.chipQueue[#player.chipQueue + 1] = player.chipQueue[1]
|
player.chipQueue[#player.chipQueue + 1] = player.chipQueue[1]
|
||||||
|
@ -946,6 +1348,7 @@ local runGame = function()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
for id, object in pairs(objects) do
|
for id, object in pairs(objects) do
|
||||||
local dmg, flinching = act.stage.getDamage(object.x, object.y, nil, not object.friendlyFire and id, nil, id)
|
local dmg, flinching = act.stage.getDamage(object.x, object.y, nil, not object.friendlyFire and id, nil, id)
|
||||||
if object.cooldown.iframe == 0 and dmg > 0 then
|
if object.cooldown.iframe == 0 and dmg > 0 then
|
||||||
|
@ -978,6 +1381,11 @@ local runGame = function()
|
||||||
end
|
end
|
||||||
reduceCooldowns()
|
reduceCooldowns()
|
||||||
movePlayers()
|
movePlayers()
|
||||||
|
if players[you] then
|
||||||
|
if players[you].control.custom and game.custom == game.customMax then
|
||||||
|
game.inChipSelect = true
|
||||||
|
end
|
||||||
|
end
|
||||||
sleep(gameDelayInit)
|
sleep(gameDelayInit)
|
||||||
transmit({
|
transmit({
|
||||||
gameID = gameID,
|
gameID = gameID,
|
||||||
|
@ -985,6 +1393,7 @@ local runGame = function()
|
||||||
players = players,
|
players = players,
|
||||||
projectiles = projectiles,
|
projectiles = projectiles,
|
||||||
objects = objects,
|
objects = objects,
|
||||||
|
game = game,
|
||||||
stageDamage = stage.damage,
|
stageDamage = stage.damage,
|
||||||
stagePanels = stage.panels,
|
stagePanels = stage.panels,
|
||||||
id = id
|
id = id
|
||||||
|
@ -1000,14 +1409,47 @@ local runGame = function()
|
||||||
control = players[you].control
|
control = players[you].control
|
||||||
})
|
})
|
||||||
end
|
end
|
||||||
|
if players[you] then
|
||||||
|
if players[you].control.custom and game.custom == game.customMax then
|
||||||
|
transmit({
|
||||||
|
gameID = gameID,
|
||||||
|
command = "chip_select",
|
||||||
|
id = yourID,
|
||||||
|
})
|
||||||
|
end
|
||||||
|
end
|
||||||
evt, getStateInfo = os.pullEvent("ccbn_get_state")
|
evt, getStateInfo = os.pullEvent("ccbn_get_state")
|
||||||
players = getStateInfo.players
|
players = getStateInfo.players
|
||||||
projectiles = getStateInfo.projectiles
|
projectiles = getStateInfo.projectiles
|
||||||
objects = getStateInfo.objects
|
objects = getStateInfo.objects
|
||||||
|
game = getStateInfo.game
|
||||||
stage.damage = getStateInfo.stageDamage
|
stage.damage = getStateInfo.stageDamage
|
||||||
stage.panels = getStateInfo.stagePanels
|
stage.panels = getStateInfo.stagePanels
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if checkDeadPlayers() then
|
||||||
|
render()
|
||||||
|
break
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
local thereIsDead, deadPlayers = checkDeadPlayers()
|
||||||
|
if thereIsDead then
|
||||||
|
sleep(0.5)
|
||||||
|
parallel.waitForAny(function()
|
||||||
|
while true do
|
||||||
|
if deadPlayers[you] then
|
||||||
|
render({images.lose, true, 6})
|
||||||
|
else
|
||||||
|
render({images.win, true, 6})
|
||||||
|
end
|
||||||
|
sleep(1)
|
||||||
|
render()
|
||||||
|
sleep(0.5)
|
||||||
|
end
|
||||||
|
end, function() os.pullEvent("key") end)
|
||||||
|
sleep(0.05)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -1030,6 +1472,22 @@ local interpretNetMessage = function(msg)
|
||||||
if players[msg.pID] then
|
if players[msg.pID] then
|
||||||
players[msg.pID].control = msg.control
|
players[msg.pID].control = msg.control
|
||||||
end
|
end
|
||||||
|
elseif msg.command == "chip_select" then
|
||||||
|
if game.custom == game.customMax then
|
||||||
|
game.inChipSelect = true
|
||||||
|
end
|
||||||
|
elseif msg.command == "turn_ready" then
|
||||||
|
if (
|
||||||
|
type(msg.chipQueue) == "table" and
|
||||||
|
players[msg.pID] and
|
||||||
|
type(msg.folder) == "table"
|
||||||
|
) then
|
||||||
|
cliChipSelect = {
|
||||||
|
folder = msg.folder,
|
||||||
|
chipQueue = msg.chipQueue,
|
||||||
|
pID = msg.pID
|
||||||
|
}
|
||||||
|
end
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
if msg.command == "get_state" then
|
if msg.command == "get_state" then
|
||||||
|
@ -1037,6 +1495,7 @@ local interpretNetMessage = function(msg)
|
||||||
players = msg.players,
|
players = msg.players,
|
||||||
projectiles = msg.projectiles,
|
projectiles = msg.projectiles,
|
||||||
objects = msg.objects,
|
objects = msg.objects,
|
||||||
|
game = msg.game,
|
||||||
stageDamage = msg.stageDamage,
|
stageDamage = msg.stageDamage,
|
||||||
stagePanels = msg.stagePanels
|
stagePanels = msg.stagePanels
|
||||||
})
|
})
|
||||||
|
@ -1055,22 +1514,33 @@ local networking = function()
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local cwrite = function(text, y)
|
|
||||||
local cx, cy = term.getCursorPos()
|
|
||||||
term.setCursorPos(scr_x / 2 - #text / 2, y or (scr_y / 2))
|
|
||||||
term.write(text)
|
|
||||||
end
|
|
||||||
|
|
||||||
local startGame = function()
|
local startGame = function()
|
||||||
getModem()
|
getModem()
|
||||||
local time = os.epoch("utc")
|
local time = os.epoch("utc")
|
||||||
|
chips, objectTypes = loadChips(getfenv())
|
||||||
|
stage.panels = {}
|
||||||
|
stage.damage = {}
|
||||||
|
players = {}
|
||||||
|
objects = {}
|
||||||
|
projectiles = {}
|
||||||
|
game.custom = 0
|
||||||
|
game.customSpeed = 1
|
||||||
|
game.inChipSelect = true
|
||||||
|
game.paused = false
|
||||||
|
act.player.newPlayer(2, 2, 1, 1, "6")
|
||||||
|
act.player.newPlayer(5, 2, 2, -1, "7")
|
||||||
|
for y = 1, 3 do
|
||||||
|
for x = 1, 6 do
|
||||||
|
act.stage.newPanel(x, y, "normal")
|
||||||
|
end
|
||||||
|
end
|
||||||
transmit({
|
transmit({
|
||||||
gameID = gameID,
|
gameID = gameID,
|
||||||
command = "find_game",
|
command = "find_game",
|
||||||
respond = false,
|
respond = false,
|
||||||
id = yourID,
|
id = yourID,
|
||||||
time = time,
|
time = time,
|
||||||
chips = chips
|
-- chips = chips
|
||||||
})
|
})
|
||||||
local msg
|
local msg
|
||||||
waitingForGame = true
|
waitingForGame = true
|
||||||
|
@ -1080,20 +1550,103 @@ local startGame = function()
|
||||||
msg = receive()
|
msg = receive()
|
||||||
until interpretNetMessage(msg)
|
until interpretNetMessage(msg)
|
||||||
gameID = isHost and gameID or msg.gameID
|
gameID = isHost and gameID or msg.gameID
|
||||||
chips = isHost and chips or msg.chips
|
-- chips = isHost and chips or msg.chips
|
||||||
transmit({
|
transmit({
|
||||||
gameID = gameID,
|
gameID = gameID,
|
||||||
command = "find_game",
|
command = "find_game",
|
||||||
respond = true,
|
respond = true,
|
||||||
id = yourID,
|
id = yourID,
|
||||||
time = isHost and math.huge or -math.huge,
|
time = isHost and math.huge or -math.huge,
|
||||||
chips = isHost and chips
|
-- chips = isHost and chips
|
||||||
})
|
})
|
||||||
waitingForGame = false
|
waitingForGame = false
|
||||||
parallel.waitForAny(runGame, networking)
|
parallel.waitForAny(runGame, networking)
|
||||||
end
|
end
|
||||||
|
|
||||||
parallel.waitForAny(startGame, getInput)
|
local makeMenu = function(x, y, options, _cpos)
|
||||||
|
local cpos = _cpos or 1
|
||||||
|
local cursor = "> "
|
||||||
|
local lastPos = cpos
|
||||||
|
local rend = function()
|
||||||
|
for i = 1, #options do
|
||||||
|
if i == cpos then
|
||||||
|
term.setCursorPos(x, y + (i - 1))
|
||||||
|
term.setTextColor(colors.white)
|
||||||
|
term.write(cursor .. options[i])
|
||||||
|
else
|
||||||
|
if i == lastPos then
|
||||||
|
term.setCursorPos(x, y + (i - 1))
|
||||||
|
term.write((" "):rep(#cursor))
|
||||||
|
lastPos = nil
|
||||||
|
else
|
||||||
|
term.setCursorPos(x + #cursor, y + (i - 1))
|
||||||
|
end
|
||||||
|
term.setTextColor(colors.gray)
|
||||||
|
term.write(options[i])
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local evt
|
||||||
|
rend()
|
||||||
|
while true do
|
||||||
|
evt = {os.pullEvent()}
|
||||||
|
if evt[1] == "key" then
|
||||||
|
if evt[2] == keys.up then
|
||||||
|
lastPos = cpos
|
||||||
|
cpos = (cpos - 2) % #options + 1
|
||||||
|
elseif evt[2] == keys.down then
|
||||||
|
lastPos = cpos
|
||||||
|
cpos = (cpos % #options) + 1
|
||||||
|
elseif evt[2] == keys.home then
|
||||||
|
lastPos = cpos
|
||||||
|
cpos = 1
|
||||||
|
elseif evt[2] == keys["end"] then
|
||||||
|
lastPos = cpos
|
||||||
|
cpos = #options
|
||||||
|
elseif evt[2] == keys.enter then
|
||||||
|
return cpos
|
||||||
|
end
|
||||||
|
elseif evt[1] == "mouse_click" then
|
||||||
|
if evt[4] >= y and evt[4] < y+#options then
|
||||||
|
if cpos == evt[4] - (y - 1) then
|
||||||
|
return cpos
|
||||||
|
else
|
||||||
|
lastPos = cpos
|
||||||
|
cpos = evt[4] - (y - 1)
|
||||||
|
rend()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
if lastPos ~= cpos then
|
||||||
|
rend()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local titleScreen = function()
|
||||||
|
local menuOptions = {
|
||||||
|
"Start Game",
|
||||||
|
"Exit"
|
||||||
|
}
|
||||||
|
local choice
|
||||||
|
while true do
|
||||||
|
term.setBackgroundColor(colors.black)
|
||||||
|
term.clear()
|
||||||
|
drawImage(images.logo, 2, 2)
|
||||||
|
if useSkynet then
|
||||||
|
term.setTextColor(colors.lightGray)
|
||||||
|
cwrite("Skynet Enabled", 2 + #images.logo[1])
|
||||||
|
end
|
||||||
|
choice = makeMenu(2, scr_y - #menuOptions, menuOptions)
|
||||||
|
if choice == 1 then
|
||||||
|
parallel.waitForAny(startGame, getInput)
|
||||||
|
elseif choice == 2 then
|
||||||
|
return
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
titleScreen()
|
||||||
|
|
||||||
term.setBackgroundColor(colors.black)
|
term.setBackgroundColor(colors.black)
|
||||||
term.clear()
|
term.clear()
|
||||||
|
|
Loading…
Reference in New Issue