Larsii30 wrote:Now I stopped to program this mini-game because with this game I learned a lot about how to write code and figure things out, but I started very bad to program and its now totally ugly code and it whould be to much work to rewrite it anyway.
The game IS playable but it isn't very difficult to win.
If you got a bit feedback, I whould really interested .
I tried to get the file as small as possible.
AlienInvader005.love
Greets.

Hm. On my machine, the aliens move only occasionally. Is that by design?
Also, please consider this alternative version of your main.lua:
Code: Select all
require "bullets"
require "player"
require "aliens"
require "TEsound"
require "img"
function love.load()
math.randomseed( tonumber(tostring(os.time()):reverse():sub(1,6)) )
lg = love.graphics
lk = love.keyboard
rnd = math.random(1,6)
g = {
State = "menu",
Start = false
}
time = {
timer = 0,
timer2 = 0,
start = 0,
}
reset = 0
aliens.load()
img.load()
end
function love.update(dt)
if g.State == "menu" then
-- do nothing
elseif g.State == "game" then
time.timer = time.timer + dt
time.timer2 = time.timer2 + dt
bullets.shot()
player.move()
aliens.hit()
aliens.start()
TEsound.cleanup()
aliens.checkLast()
end
end
function love.draw()
player.colAliens()
img.draw()
--[[ DEBUG INFO
lg.print ("Debuginfos:",1,1)
lg.print ("playerX:"..player.X,1,20)
lg.print ("bulletsX:"..bullets.X,1,20*2)
lg.print ("bulletsY:"..bullets.Y,1,20*3)
lg.print ("aliens[2].y:"..aliens[2].y,1,20*4)
lg.print ("NR:"..nr,1,20*6)
]]
-- GEWONNEN-TEXT
if aliens.allDead() and player.colAliens() == 0 then
lg.print(" EPIC WIN !", lg.getWidth()/3,lg.getHeight()/3)
lg.print("(press Escape for the main menu)", lg.getWidth()/3-30,lg.getHeight()/3+200)
end
if player.colAliens() == 1 then
g.State = "menu"
end
if g.State == "menu" then
lg.print("Press Enter to Start",lg.getWidth()/3+10,lg.getHeight()/3+100)
end
end
I took out some unneeded newlines and changed some indentation. You've sort of got how indentation is supposed to be used, but not quite. The idea is that its used to show what is inside of what, rather than what follows what, which is how I think you were using it.
Also, I switched an
if out for an
elseif (
elseif g.State == "game" then). The idea is, you only want one of the chunks to run. If the State was "menu", then it couldn't also be "game", so by making the if an elseif, we let the game skip the second chunk. Elseif is a fantastic tool, try to get a good handle on it and it will serve you well.