AlienInvaders - my first game
AlienInvaders - my first game
Hey everyone,
I'm new in this community and in programming with lua/Löve2D.
I work on a 'small' first game called AlienInvaders .
(and btw sorry for my bad english )
I would like to know, what you are thinking about my code and hoped you can give me some tips how I could do things better.
The game is still anfinished at the moment, but it's core features are in. The most complicated thing for me was to move the aliens correctly.
some ideas whats I could do better ?
Greets from germany. !
I'm new in this community and in programming with lua/Löve2D.
I work on a 'small' first game called AlienInvaders .
(and btw sorry for my bad english )
I would like to know, what you are thinking about my code and hoped you can give me some tips how I could do things better.
The game is still anfinished at the moment, but it's core features are in. The most complicated thing for me was to move the aliens correctly.
some ideas whats I could do better ?
Greets from germany. !
- Attachments
-
- AlienInvader.love
- Version 0.0.2
- (534.94 KiB) Downloaded 344 times
Re: AlienInvaders - my first game
Hi!
I quite like the graphics, the aliens are really funny.
The first thing that i saw in your code is abusive new line and no indentation: (it's not a technical problem but it's for readability of your code)
Your code (for example):
Your code should better be like that:
if a line begins with “function”, “repeat”, “while” or ends with “then”, “do” or “{“, it’s the start of a block. If the line is equal to “end” or “}” or starts with “until”, it’s the end of a block. Each block should be put to the right.. You can achieve it with a lot of editors pressing the tab touch.
I liked the concept folder wich contains the changelog and the aim of the game, it's a good initiative even if i didn't understood everything due to german
Another thing is that:
Don't put a space between function name and the opening bracket.
And last thing:
equals:
For the rest, I didn't see ugly things, and I have to go to work... Java and android will kill me!
Good luck and continue working!
I quite like the graphics, the aliens are really funny.
The first thing that i saw in your code is abusive new line and no indentation: (it's not a technical problem but it's for readability of your code)
Your code (for example):
Code: Select all
function love.load ()
img.load()
end
Code: Select all
function love.load()
img.load()
end
I liked the concept folder wich contains the changelog and the aim of the game, it's a good initiative even if i didn't understood everything due to german
Another thing is that:
Code: Select all
TEsound.play ("sfx/gun.wav")
And last thing:
Code: Select all
if test == true then
print("lol")
end
Code: Select all
if test then
print("lol")
end
Good luck and continue working!
Last edited by 4ROS4 on Tue Sep 20, 2011 9:19 am, edited 1 time in total.
Re: AlienInvaders - my first game
why shouldnt you put a space between the function name and opening bracket?
You don't need the .lua extension in require, and the game won't run in newer versions of love with it .
Other than that, its a great first game!
You don't need the .lua extension in require, and the game won't run in newer versions of love with it .
Other than that, its a great first game!
Re: AlienInvaders - my first game
Just for better understanding. It's not an obligation like indentation...
Most of the people do that..
Most of the people do that..
- kikito
- Inner party member
- Posts: 3153
- Joined: Sat Oct 03, 2009 5:22 pm
- Location: Madrid, Spain
- Contact:
Re: AlienInvaders - my first game
I recently heard one saying the other day:
So, please think of your fellow programmers, and remove that space. Also, if you remove that habit, it'll make your life easier, too; you will work more easily with code written by others, since that is the standard. In the last place, your code will look more professional - just like it does when it has proper indentation.
In all languages, putting the function name next to the parenthesis it refers to is pretty much a standard convention. At least one language (ruby) gives you a warning when you put a space in between (In my opinion, this is proof enough that it's worse than a bad indentation)When, don't write that code the compiler understands; write it so that other people understand it
So, please think of your fellow programmers, and remove that space. Also, if you remove that habit, it'll make your life easier, too; you will work more easily with code written by others, since that is the standard. In the last place, your code will look more professional - just like it does when it has proper indentation.
When I write def I mean function.
Re: AlienInvaders - my first game
HAhahahahaah!!
Re: AlienInvaders - my first game
woah . First, thank you guys.
Thanks.kraftman wrote:
You don't need the .lua extension in require,...
Oh, okay. I'll keep it in mind.4ROS4 wrote:Hi!
I quite like the graphics, the aliens are really funny.
The first thing that i saw in your code is abusive new line and no indentation: (it's not a technical problem but it's for readability of your code)
Your code (for example):
Your code should better be like that:Code: Select all
function love.load () img.load() end
Code: Select all
function love.load() img.load() end
This concept folder is reaally important for me. On the one hand its helpful to check what I've done and to think about what I could do next. On the other hand it encourages me to see yey, I had a concept and I solved this and this problem with the game. Great to learn things.4ROS4 wrote:
I liked the concept folder wich contains the changelog and the aim of the game, it's a good initiative even if i didn't understood everything due to german
oh. o.o Thats... much easier! Thanks. I'm here to learn.4ROS4 wrote: Another thing is that:
Don't put a space between function name and the opening bracket.Code: Select all
TEsound.play ("sfx/gun.wav")
[/quote"]
Hm, I'll try it out.
4ROS4 wrote: And last thing:equals:Code: Select all
if test == true then print("lol") end
Code: Select all
if test then print("lol") end
Re: AlienInvaders - my first game
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. Greets.
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. Greets.
- tentus
- Inner party member
- Posts: 1060
- Joined: Sun Oct 31, 2010 7:56 pm
- Location: Appalachia
- Contact:
Re: AlienInvaders - my first game
Hm. On my machine, the aliens move only occasionally. Is that by design?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. Greets.
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
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.
Kurosuke needs beta testers
Who is online
Users browsing this forum: Amazon [Bot] and 7 guests