Page 5 of 7
Re: Invader: arcade strategy game
Posted: Fri Jul 22, 2011 8:16 am
by kikito
Trappingnoobs wrote:
I don't think the planets are big enough to render it time-saving having to select a percentage.
If there were different size planets, that'd, I guess, be helpfull though.
There would be just 3 buttons in total, not three buttons per planet. That would be crazy.
Re: Invader: arcade strategy game
Posted: Fri Jul 22, 2011 1:32 pm
by Trappingnoobs
kikito wrote:Trappingnoobs wrote:
I don't think the planets are big enough to render it time-saving having to select a percentage.
If there were different size planets, that'd, I guess, be helpfull though.
There would be just 3 buttons in total, not three buttons per planet. That would be crazy.
Oh, I thought you meant that when you clicked, three buttons apeared. I guess that makes sense, but I think it should still be planet-by-planet sending, but you should be able to select multiple by dragging a rectangle (and/or maybe shift clicking).
Re: Invader: arcade strategy game
Posted: Fri Jul 22, 2011 1:42 pm
by GijsB
my sorta beginging clone of it xD =
Code: Select all
bases = {}
dt = 0
math.randomseed(os.time())
for i = 1,10 do
base = nil
function choose()
base = {X = math.floor(math.random(1,7))*100, Y = math.floor(math.random(1,5))*100,M = math.random(2,10)*5,C = 0,O = math.random(1,3)}
for i,v in pairs(bases) do
if v.X == base.X and v.Y == base.Y then
choose()
end
end
end
choose()
table.insert(bases,base)
end
function diffrents(a,b)
if a > b then
return a-b
else
return b-a
end
end
function love.update(d)
dt = dt + d
if dt > 0.5 then
for i,v in pairs(bases) do
if v.C < v.M then
v.C = v.C +1
end
end
dt = 0
end
end
function love.draw()
for i,v in pairs(bases) do
if v.O == 1 then
love.graphics.setColor(255,0,0)
elseif v.O == 2 then
love.graphics.setColor(0,255,0)
elseif v.O == 3 then
love.graphics.setColor(0,0,255)
end
love.graphics.circle("fill",v.X,v.Y,v.M,30)
love.graphics.setColor(255,255,255)
love.graphics.print(tostring(v.C),v.X-5,v.Y-5)
end
if hold and begin then
love.graphics.line(begin.X,begin.Y,love.mouse:getX(),love.mouse:getY())
end
end
hold = false
begin = nil
function love.mousepressed(x,y,mouse)
if mouse == "l" then
hold = true
for i,v in pairs(bases) do
if v.O == 1 then
if diffrents(x,v.X) < v.M and diffrents(y,v.Y) < v.M then
begin = v
end
end
end
end
end
function love.mousereleased(x,y,mouse)
pcall(function()if mouse == "l" then
hold = false
for i,v in pairs(bases) do
if diffrents(x,v.X) < v.M and diffrents(y,v.Y) < v.M then
if v.O == 1 then--friend so give points
for i = 1,v.M-v.C do
if begin.C > 0 then
begin.C = begin.C - 1
v.C = v.C+1
end
end
elseif v.O == 2 or v.O == 3 then
for i = 1,begin.C do
if v.C > 0 then
begin.C = begin.C-1
v.C = v.C-1
if v.C < 1 then
v.O = 1
end
end
end
end
end
end
begin = nil
end end)
end
Re: Invader: arcade strategy game
Posted: Fri Jul 22, 2011 4:38 pm
by tentus
GijsB wrote:my sorta beginging clone of it xD =
Code: Select all
bases = {}
dt = 0
math.randomseed(os.time())
for i = 1,10 do
base = nil
function choose()
base = {X = math.floor(math.random(1,7))*100, Y = math.floor(math.random(1,5))*100,M = math.random(2,10)*5,C = 0,O = math.random(1,3)}
for i,v in pairs(bases) do
if v.X == base.X and v.Y == base.Y then
choose()
end
end
end
choose()
table.insert(bases,base)
end
function diffrents(a,b)
if a > b then
return a-b
else
return b-a
end
end
function love.update(d)
dt = dt + d
if dt > 0.5 then
for i,v in pairs(bases) do
if v.C < v.M then
v.C = v.C +1
end
end
dt = 0
end
end
function love.draw()
for i,v in pairs(bases) do
if v.O == 1 then
love.graphics.setColor(255,0,0)
elseif v.O == 2 then
love.graphics.setColor(0,255,0)
elseif v.O == 3 then
love.graphics.setColor(0,0,255)
end
love.graphics.circle("fill",v.X,v.Y,v.M,30)
love.graphics.setColor(255,255,255)
love.graphics.print(tostring(v.C),v.X-5,v.Y-5)
end
if hold and begin then
love.graphics.line(begin.X,begin.Y,love.mouse:getX(),love.mouse:getY())
end
end
hold = false
begin = nil
function love.mousepressed(x,y,mouse)
if mouse == "l" then
hold = true
for i,v in pairs(bases) do
if v.O == 1 then
if diffrents(x,v.X) < v.M and diffrents(y,v.Y) < v.M then
begin = v
end
end
end
end
end
function love.mousereleased(x,y,mouse)
pcall(function()if mouse == "l" then
hold = false
for i,v in pairs(bases) do
if diffrents(x,v.X) < v.M and diffrents(y,v.Y) < v.M then
if v.O == 1 then--friend so give points
for i = 1,v.M-v.C do
if begin.C > 0 then
begin.C = begin.C - 1
v.C = v.C+1
end
end
elseif v.O == 2 or v.O == 3 then
for i = 1,begin.C do
if v.C > 0 then
begin.C = begin.C-1
v.C = v.C-1
if v.C < 1 then
v.O = 1
end
end
end
end
end
end
begin = nil
end end)
end
That's... a little rude, but OK, whatever. As an effort to help you as a Lover, I made some adjustments to your code:
Code: Select all
function love.load()
bases = {}
dt = 0
math.randomseed(os.time())
for i = 1,10 do
base = nil
function choose()
base = {
X = math.floor(math.random(1,7))*100,
Y = math.floor(math.random(1,5))*100,
M = math.random(2,10)*5,C = 0,O = math.random(1,3)
}
for i,v in pairs(bases) do
if v.X == base.X and v.Y == base.Y then
choose()
end
end
end
choose()
table.insert(bases,base)
end
hold = false
begin = nil
end
function diffrents(a,b)
if a > b then
return a-b
else
return b-a
end
end
function love.update(d)
dt = dt + d
if dt > 0.5 then
for i,v in pairs(bases) do
if v.C < v.M then
v.C = v.C +1
end
end
dt = 0
end
end
function love.draw()
for i,v in pairs(bases) do
if v.O == 1 then
love.graphics.setColor(255,0,0)
elseif v.O == 2 then
love.graphics.setColor(0,255,0)
elseif v.O == 3 then
love.graphics.setColor(0,0,255)
end
love.graphics.circle("fill",v.X,v.Y,v.M,30)
love.graphics.setColor(255,255,255)
love.graphics.print(tostring(v.C),v.X-5,v.Y-5)
end
if hold and begin then
love.graphics.line(begin.X,begin.Y,love.mouse:getX(),love.mouse:getY())
end
end
function love.mousepressed(x,y,mouse)
if mouse == "l" then
hold = true
for i,v in pairs(bases) do
if v.O == 1 then
if diffrents(x,v.X) < v.M and diffrents(y,v.Y) < v.M then
begin = v
end
end
end
end
end
function love.mousereleased(x,y,mouse)
if mouse == "l" then
hold = false
for i,v in pairs(bases) do
if diffrents(x,v.X) < v.M and diffrents(y,v.Y) < v.M then
if v.O == 1 then --friend so give points
for i = 1,v.M-v.C do
if begin.C > 0 then
begin.C = begin.C - 1
v.C = v.C+1
end
end
elseif v.O == 2 or v.O == 3 then
for i = 1,begin.C do
if v.C > 0 then
begin.C = begin.C-1
v.C = v.C-1
if v.C < 1 then
v.O = 1
end
end
end
end
end
end
begin = nil
end
end
The pcall you had made it impossible to play your version for me, so I took it out. Why was it there?
Re: Invader: arcade strategy game
Posted: Fri Jul 22, 2011 4:44 pm
by GijsB
theres some bug i cant find in the code there wich glitches up the 'begin' variable :/
but thanks for the code upgrade
Re: Invader: arcade strategy game
Posted: Fri Jul 22, 2011 5:03 pm
by kraftman
GijsB wrote:theres some bug i cant find in the code there wich glitches up the 'begin' variable :/
but thanks for the code upgrade
Bear with me, this may get complicated:
If you run some code, and it gives you an error, you can use the error message to help find out what the error is!
In this case, if the error says "attempt to index global 'begin' (a nil value.)"
It means that it is attempting to index a global variable called 'begin', but that variable is a nil value.
A good place to start debugging would be to try and work out why begin is a nil value, assuming it shouldn't be.
In this case, a great place to start would be looking at the part of your code which says "begin = nil" (a good indication as to why the variable 'begin' is equal to nil.)
Re: Invader: arcade strategy game
Posted: Fri Jul 22, 2011 5:28 pm
by GijsB
kraftman,
thanks, but i already knew how to debug, and i fixed it now
added circles , but they pretty much have no use yet...
Code: Select all
function love.load()
bases = {}
dt = 0
math.randomseed(os.time())
for i = 1,10 do
base = nil
function choose()
base = {
X = math.floor(math.random(1,7))*100,
Y = math.floor(math.random(1,5))*100,
M = math.random(2,10)*5,
C = 0,
O = math.random(1,3)
}
for i,v in pairs(bases) do
if v.X == base.X and v.Y == base.Y then
choose()
end
end
end
choose()
table.insert(bases,base)
end
hold = false
begin = nil
end
function diffrents(a,b)
if a > b then
return a-b
else
return b-a
end
end
function love.update(d)
dt = dt + d
if dt > 0.5 then
for i,v in pairs(bases) do
if v.C < v.M then
v.C = v.C +1
end
end
dt = 0
end
end
function love.draw()
for i,v in pairs(bases) do
if v.O == 1 then
love.graphics.setColor(255,0,0)
elseif v.O == 2 then
love.graphics.setColor(0,255,0)
elseif v.O == 3 then
love.graphics.setColor(0,0,255)
end
love.graphics.circle("fill",v.X,v.Y,v.M,30)
love.graphics.setColor(255,255,255)
love.graphics.print(tostring(v.C),v.X-5,v.Y-5)
end
if hold and begin then
love.graphics.line(begin.X,begin.Y,love.mouse:getX(),love.mouse:getY())
love.graphics.circle("line",begin.X,begin.Y,begin.C*5+begin.M,30)
end
end
function love.mousepressed(x,y,mouse)
if mouse == "l" then
hold = true
for i,v in pairs(bases) do
if v.O == 1 then
if diffrents(x,v.X) < v.M and diffrents(y,v.Y) < v.M then
begin = v
end
end
end
end
end
function love.mousereleased(x,y,mouse)
if mouse == "l" then
hold = false
for i,v in pairs(bases) do
if diffrents(x,v.X) < v.M and diffrents(y,v.Y) < v.M then
if begin == nil then return end
--BLABLA CHECK IF IN RADIUS OF begin.C*5+begin.M (FANCY WHITE CIRCLE)
if v.O == 1 then --friend so give points
for i = 1,v.M-v.C do
if begin.C > 0 then
begin.C = begin.C - 1
v.C = v.C+1
end
end
elseif v.O == 2 or v.O == 3 then
if begin == nil then return end
for i = 1,begin.C-1 do
if v.C > 0 then
begin.C = begin.C-1
v.C = v.C-1
if v.C == 0 then
v.O = 1
end
end
end
end
end
end
begin = nil
end
end
Re: Invader: arcade strategy game
Posted: Fri Jul 22, 2011 6:19 pm
by Robin
Guys. Please take this to another thread. This one is about Invader and so the previous 5 post here are off-topic.
Thank you.
Re: Invader: arcade strategy game
Posted: Fri Jul 22, 2011 6:54 pm
by GijsB
oke xD
Re: Invader: arcade strategy game
Posted: Thu Feb 23, 2012 4:42 pm
by cattail
I have test the great invader.love , it's looks simple but a lot of fun.
I almost win, but a crush.
Error: [string "systemview.lua"]:143: attempt to index local 'arr' (a nil value)
stack traceback:
[string "systemview.lua"]:143: in function 'update'
[string "main.lua"]
1: in function 'update'
[string "boot.lua"]:1: in function <[string "boot.lua"]:1>
[C]: in function 'xpcall'
AL lib: ALc.c:1818: alcCloseDevice(): deleting 32 Buffer(s)
I'm using debian squeeze, love 0.7.2 (from gz, configure,make,make install)
invader.love is from 20 page's link :
viewtopic.php?f=3&t=2198&start=110
I find invader-p2.love , haven't play with it yet .
BTW: Is a way to select the number of stars?