There would be just 3 buttons in total, not three buttons per planet. That would be crazy.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.
Invader: arcade strategy game
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: Invader: arcade strategy game
When I write def I mean function.
- Trappingnoobs
- Citizen
- Posts: 95
- Joined: Tue Oct 12, 2010 8:52 pm
Re: Invader: arcade strategy game
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).kikito wrote:There would be just 3 buttons in total, not three buttons per planet. That would be crazy.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.
Re: Invader: arcade strategy game
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
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: Invader: arcade strategy game
That's... a little rude, but OK, whatever. As an effort to help you as a Lover, I made some adjustments to your code: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
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
Kurosuke needs beta testers
Re: Invader: arcade strategy game
theres some bug i cant find in the code there wich glitches up the 'begin' variable :/
but thanks for the code upgrade![Very Happy :D](./images/smilies/ms-glad.png)
but thanks for the code upgrade
![Very Happy :D](./images/smilies/ms-glad.png)
Re: Invader: arcade strategy game
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
kraftman,
thanks, but i already knew how to debug, and i fixed it now![Wink ;)](./images/smilies/ms-wink.png)
added circles , but they pretty much have no use yet...
thanks, but i already knew how to debug, and i fixed it now
![Wink ;)](./images/smilies/ms-wink.png)
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
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Invader: arcade strategy game
Guys. Please take this to another thread. This one is about Invader and so the previous 5 post here are off-topic.
Thank you.![Smile :)](./images/smilies/ms-smile.png)
Thank you.
![Smile :)](./images/smilies/ms-smile.png)
Help us help you: attach a .love.
Re: Invader: arcade strategy game
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?
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"]
![Awww :3](./images/smilies/ms-three.png)
[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?
Who is online
Users browsing this forum: Amazon [Bot], Google [Bot] and 2 guests