mirror of
https://github.com/LDDestroier/CC/
synced 2024-12-04 15:29:56 +00:00
Prettied it up
This commit is contained in:
parent
9cd8f7da4b
commit
b5f6f7cf7c
44
dodge.lua
44
dodge.lua
@ -9,14 +9,18 @@
|
||||
--]]
|
||||
|
||||
local scr_x, scr_y = term.getSize()
|
||||
local keysDown = {} --holds all pressed keys. It's way better than using "key" event for movement
|
||||
local walls = {} --holds all screen data for walls. I could do slants if I wanted, not just walls
|
||||
local frame = 0 --for every screen update-oh, you know what a frame is
|
||||
local maxFrame = 26 --max frames until new wall
|
||||
local fframe = 0 --not a typo. is the buffer of spaces until the spaces between walls shrinks
|
||||
local maxFFrame = 6 --max fframes until the space between walls gets slightly tighter (down to 5, good luck m8)
|
||||
local pause = false --pausing is a nice thing
|
||||
local tsv = term.current().setVisible --it is my belief that monitors and normal computers do not have the setVisible method for term.current()
|
||||
local keysDown = {} -- holds all pressed keys. It's way better than using "key" event for movement
|
||||
local walls = {} -- holds all screen data for walls. I could do slants if I wanted, not just walls
|
||||
local frame = 0 -- for every screen update-oh, you know what a frame is
|
||||
local maxFrame = 26 -- max frames until new wall
|
||||
local fframe = 0 -- not a typo. is the buffer of spaces until the spaces between walls shrinks
|
||||
local maxFFrame = 6 -- max fframes until the space between walls gets slightly tighter (down to 5, good luck m8)
|
||||
local pause = false -- pausing is a nice thing
|
||||
local tsv = function(visible) -- monitors don't have term.current().setVisible, damn you
|
||||
if term.current().setVisible then
|
||||
term.current().setVisible(visible)
|
||||
end
|
||||
end
|
||||
for a = 1, scr_x do
|
||||
table.insert(walls,{top=1,bottom=scr_y,color=colors.black})
|
||||
end
|
||||
@ -65,7 +69,7 @@ local trymove = function(dir)
|
||||
end
|
||||
|
||||
local render = function()
|
||||
if tsv then tsv(false) end
|
||||
tsv(false)
|
||||
term.setBackgroundColor(colors.white)
|
||||
term.setTextColor(colors.white)
|
||||
term.clear()
|
||||
@ -78,11 +82,11 @@ local render = function()
|
||||
term.clearLine()
|
||||
for x = 1, #walls do
|
||||
term.setBackgroundColor(walls[x].color)
|
||||
for y = 1, walls[x].top do
|
||||
for y = 2, walls[x].top do
|
||||
term.setCursorPos(x,y)
|
||||
term.write(" ")
|
||||
end
|
||||
for y = walls[x].bottom, scr_y do
|
||||
for y = walls[x].bottom, scr_y - 1 do
|
||||
term.setCursorPos(x,y)
|
||||
term.write(" ")
|
||||
end
|
||||
@ -90,7 +94,7 @@ local render = function()
|
||||
term.setCursorPos(2,1)
|
||||
term.setBackgroundColor(colors.black)
|
||||
term.write("SCORE: "..score.." | TIME: "..time)
|
||||
if tsv then tsv(true) end
|
||||
tsv(true)
|
||||
end
|
||||
|
||||
local keepTime = function()
|
||||
@ -113,9 +117,9 @@ local doGame = function()
|
||||
if frame >= maxFrame then
|
||||
frame = 0
|
||||
fframe = fframe + 1
|
||||
ypos = math.random(4,scr_y-3)
|
||||
ypos = math.random(4, scr_y-3)
|
||||
wf = 3
|
||||
randomcol = 2^math.random(1,14)
|
||||
randomcol = 2^math.random(1, 14)
|
||||
end
|
||||
if wf > 0 then
|
||||
wf = wf - 1
|
||||
@ -123,7 +127,7 @@ local doGame = function()
|
||||
if not term.isColor() then
|
||||
randomcol = colors.black --Shame.
|
||||
end
|
||||
addNewWall(ypos-gap,ypos+gap,randomcol)
|
||||
addNewWall(ypos-gap, ypos+gap, randomcol)
|
||||
else
|
||||
frame = frame + 1
|
||||
addNewWall(1,scr_y,colors.black)
|
||||
@ -147,8 +151,8 @@ local doGame = function()
|
||||
end
|
||||
render()
|
||||
end
|
||||
sleep(0)
|
||||
if guyY<=walls[guyX].top or guyY>=walls[guyX].bottom then
|
||||
sleep(0.05)
|
||||
if guyY <= walls[guyX].top or guyY >= walls[guyX].bottom then
|
||||
return "dead"
|
||||
end
|
||||
end
|
||||
@ -169,7 +173,7 @@ local getInput = function()
|
||||
"Paused. Press 'P' to resume",
|
||||
"The game is paused",
|
||||
"GAME PAUSE !",
|
||||
"What, gotta catch your breath??",
|
||||
"What, gotta catch your breath?",
|
||||
"Paused, the game is, hmmm?",
|
||||
"PAUSED GAME",
|
||||
"GAME PAUSED",
|
||||
@ -179,8 +183,6 @@ local getInput = function()
|
||||
"UNPAUSE WITH 'P'",
|
||||
"Tip: press UP to go up",
|
||||
"Tip: press DOWN to go down",
|
||||
"Tip: read Narbonic comic, you tool",
|
||||
"Tip: read Skin Horse comic, you twat",
|
||||
"YOU HAVE NO CHANCE TO SURVIVE MAKE YOUR TIME",
|
||||
"-PAUSED-",
|
||||
"=PAUSED=",
|
||||
@ -203,7 +205,7 @@ local getInput = function()
|
||||
end
|
||||
end
|
||||
|
||||
local uut = parallel.waitForAny(getInput,doGame,keepTime)
|
||||
local uut = parallel.waitForAny(getInput, doGame, keepTime)
|
||||
if uut == 2 then
|
||||
renderTEXT()
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user