Game: LaserBlast
#1
Posted 04 March 2012 - 03:59 PM
It took about 5 hours to write, I have no idea where I got the idea from- I think I might have played something similar on my dad's Powerbook when I was 10 or something.
It's actually pretty good fun to play.
I've recently update this for colour as well, but is still compatible on B&W monitors.
Controls:
Arrow Keys- move left and right
Space Bar- fire laser
Enter- quit game
Instructions:
Collect the powerup P's while shooting down asteroid O's and fragment *'s.
Download: http://pastebin.com/uBfD8SAe
#2
Posted 04 March 2012 - 04:35 PM
All of your computer's programs can be found here:
.minecraftsavesYOURWORLDcomputer
Within this folder there will be numbered directories.
Each number represents the ID of a computer and within each will be your programs for that computer.
Hope that helps.
#3
Posted 04 March 2012 - 04:53 PM
Sleep is not coming tonight so I may as well upload the source. It's just below.
That was a lot of fun to make, hope someone has fun playing it.
w,h = term.getSize()
plpos = w/2
--music stuff
minterval = 1
mtimer = 1
left = false
level = 1
score = 0
gameover=false
killc = 0
--x,y,dir
projlist = {}
--x,y,intvspeed,dtimer
baddylist = {}
btimer = 0
bintv = 1
utime = 0.05
bsmp = 6
powerup = 0
function drawHeader()
term.setCursorPos(5, 1)
term.write("Score: "..score)
if score~=0 then term.write("00") end
local lstr = "Level: "..level
term.setCursorPos(w-#lstr-5,1)
term.write(lstr)
end
function drawWorld()
term.clear()
drawHeader()
drawLandscape()
term.setCursorPos(plpos-1, h-1)
term.write("@@@")
for i=1,#projlist do
local proj = projlist[i]
term.setCursorPos(proj.x, proj.y)
term.write("|")
end
for i=1,#baddylist do
local baddy = baddylist[i]
term.setCursorPos(baddy.x, baddy.y)
if baddy.dtimer==0 then
if baddy.pup then term.write("P")
elseif baddy.frag then term.write("*")
else term.write("O") end
else
term.write("#")
end
end
end
function drawLandscape()
term.setCursorPos(1,h)
local land = string.rep("-", w)
term.write(land)
local m6=" _____________ "
local m5=" _______ / ____ "
local m4=" / ___/___ ________"
local m3=" / "
local m2=" / ________ "
local m1="______/ ______________"
term.setCursorPos(1, h-8)
term.write(m6)
term.setCursorPos(1, h-7)
term.write(m5)
term.setCursorPos(1, h-6)
term.write(m4)
term.setCursorPos(1, h-5)
term.write(m3)
term.setCursorPos(1, h-4)
term.write(m2)
term.setCursorPos(1, h-3)
term.write(m1)
end
function updateWorld()
--The music stuff
redstone.setOutput("back", false)
mtimer=mtimer-utime
if mtimer<=0 then
mtimer = minterval
if left then
redstone.setOutput("left", true)
redstone.setOutput("right", false)
else
redstone.setOutput("left", false)
redstone.setOutput("right", true)
end
left = not left
end
local i=1
while i<=#projlist do
projlist[i].y = projlist[i].y+projlist[i].dir
if projlist[i].y < 0 or projlist[i].y > h-1 then
table.remove(projlist,i)
i=i-1
end
i=i+1
end
i=1
while i<=#baddylist do
local baddy = baddylist[i]
baddy.timer=baddy.timer+utime
if baddy.y==h-1 and math.abs(baddy.x-plpos)<2 then
if baddy.pup then powerup = 10
else
gameover = true
redstone.setOutput("back", true)
end
end
j=1
while j<=#projlist do
local proj = projlist[j]
if baddy.x==proj.x and math.abs(baddy.y-proj.y)<2
and baddy.dtimer==0 then
baddy.dtimer = 0.5
table.remove(projlist,j)
j=j-1
score=score+5
redstone.setOutput("back", true)
killc=killc+1
if killc>5+(level*5) and level<10 then levelUp() end
--Adds fragments
if math.random(1, 5) == 2 and not baddy.frag then
table.insert(baddylist, {
x = baddy.x-1,
y = baddy.y,
pup = false,
frag = true,
timer = 0,
dtimer = 0,
speed = baddy.speed/2
})
table.insert(baddylist, {
x = baddy.x+1,
y = baddy.y,
pup = false,
frag = true,
timer = 0,
dtimer = 0,
speed = baddy.speed/2
})
end
end
j=j+1
end
if baddy.timer>baddy.speed and baddy.dtimer==0 then
baddy.y=baddy.y+1
baddy.timer = 0
if baddy.y==h then
table.remove(baddylist,i)
i=i-1
score=score-1
end
elseif baddy.dtimer>0 then
baddy.dtimer=baddy.dtimer-utime
if baddy.dtimer<=0 then
table.remove(baddylist,i)
i=i-1
end
end
i=i+1
end
btimer=btimer+utime
if btimer > bintv then
table.insert(baddylist, {
x = math.random(w/4, 3*(w/4)),
y = 1,
speed = utime*bsmp,
timer = 0,
dtimer = 0,
pup = math.random(1,20)==5,
frag = false
})
btimer=0
end
end
function levelUp()
level=level+1
bintv=bintv-0.10
bsmp=bsmp-0.5
killc=0
minterval=minterval-0.10
end
function updatePlayer(key)
if powerup>0 then
powerup = powerup-utime
end
if key==203 and plpos>1 then
plpos=plpos-1
elseif key==205 and plpos<w then
plpos=plpos+1
elseif key==57 then
if powerup>0 then
table.insert(projlist, {
dir = -1,
x = plpos+1,
y = h-2
})
table.insert(projlist, {
dir = -1,
x = plpos-1,
y = h-2
})
else
table.insert(projlist, {
dir = -1,
x = plpos,
y = h-2
})
end
end
end
local wtimer os.startTimer(utime)
while not gameover do
local e, v = os.pullEvent()
if e=="timer" then
updateWorld()
wtimer = os.startTimer(utime)
elseif e=="key" then
if v==28 then break end
updatePlayer(v)
end
drawWorld()
end
term.setCursorPos(plpos-1, h-1)
term.write("###")
local go = "Game Over!"
term.setCursorPos(w/2 - #go/2, 10)
term.write(go)
term.setCursorPos(1,h)
sleep(5)
redstone.setOutput("back", false)
term.clear()
</w>
#4
Posted 04 March 2012 - 05:29 PM
#5
Posted 04 March 2012 - 05:31 PM
But no biggie, thanks for sharing!
#6
Posted 05 March 2012 - 09:55 AM
I agree the game is too hard, I've modified it so level progression is 50% slower and I cap at level 10 rather than that fiendish level 6.
That one seemed to do alright, and it was a lot of fun to make. I might do another one at some stage- probably keep it in the one post so as not to bloat the forums.
Thanks for playing!
#7
Posted 05 March 2012 - 04:18 PM
bios:206: [string "LaserBlast"]:38 '=' expected
what whould i do to fix it?
#8
Posted 05 March 2012 - 08:21 PM
Baldfrost, on 05 March 2012 - 04:18 PM, said:
Go to the line it tells you and see if it's different to what you've copied by hand.
Sometimes it's not exacty on the given line, but 1 above or below.
It's just some missing brackets or something similar, I'm sure.
#9
Posted 05 March 2012 - 10:29 PM
found it.
now just to fix some other mistypes.
thx for the help.
There was one problem i couldn't find any mistakes anywhere.
It says
LaserBlast:34: attempt to index ? (a nil value)
couldn't find any mistakes in the code i copied.
#10
Posted 05 March 2012 - 11:58 PM
Line 34 on my version calls term.clear() so I have no idea how that error has occurred.
I've added a download to mediafire at the top of the page so might be worth trying that one.
Edited by nitrogenfingers, 06 March 2012 - 12:05 AM.
#11
Posted 06 March 2012 - 09:10 AM
#12
Posted 06 March 2012 - 09:39 AM
nitrogenfingers, on 05 March 2012 - 11:58 PM, said:
Line 34 on my version calls term.clear() so I have no idea how that error has occurred.
I've added a download to mediafire at the top of the page so might be worth trying that one.
it works for me in singleplayer where i put it in the save game folder, the bug is on multiplayer.
#13
Posted 06 March 2012 - 12:02 PM
Baldfrost, on 06 March 2012 - 09:39 AM, said:
nitrogenfingers, on 05 March 2012 - 11:58 PM, said:
Line 34 on my version calls term.clear() so I have no idea how that error has occurred.
I've added a download to mediafire at the top of the page so might be worth trying that one.
it works for me in singleplayer where i put it in the save game folder, the bug is on multiplayer.
The code should be executing exactly the same - it is probably an issue with typing it out, or the person who put it on the server.
#14
Posted 06 March 2012 - 02:57 PM
Cloudy, on 06 March 2012 - 12:02 PM, said:
Baldfrost, on 06 March 2012 - 09:39 AM, said:
nitrogenfingers, on 05 March 2012 - 11:58 PM, said:
Line 34 on my version calls term.clear() so I have no idea how that error has occurred.
I've added a download to mediafire at the top of the page so might be worth trying that one.
it works for me in singleplayer where i put it in the save game folder, the bug is on multiplayer.
The code should be executing exactly the same - it is probably an issue with typing it out, or the person who put it on the server.
it was me who put in on the server (typing it on the computer) and fixed all the mistypes, think the last mistype was on line 186 or something and then there was a mistake on line 34 yesterday which aren't there today or maybe because i deleted some code and re typed it exacly like it was before.
#15
Posted 07 March 2012 - 04:54 PM
nitrogenfingers, on 05 March 2012 - 11:58 PM, said:
Line 34 on my version calls term.clear() so I have no idea how that error has occurred.
I've added a download to mediafire at the top of the page so might be worth trying that one.
i no longer have that bug. now it just give me a number, so far i it have said 13 12 and 16.
#16
Posted 13 May 2012 - 01:13 PM
#17
Posted 14 May 2012 - 01:08 AM
#18
Posted 14 May 2012 - 09:14 AM
#19
Posted 02 November 2012 - 09:23 AM
#20
Posted 02 November 2012 - 09:36 AM
1 user(s) are reading this topic
0 members, 1 guests, 0 anonymous users











