Hey, nice to meet you. Welcome to love2d and I'd just like to say that
nobody will steal your code over here. In fact, it's preferred if you actually released your code when learning so people who want to help you
can help you.
Some constructive criticsm:
Your game isn't very fun, it get's to a point it's just impossible to play. I know you worked hard on it, and since it is your first game I give you plenty of cookies for a
great first game.
Taking a look into the code (that's what we do), it's perfectly indented (I tend to rage at people who don't indent their code), but:
. This is just what.
Try replacing that code with this:
Code: Select all
if object.speed >= 250 then
local level = ((object.speed-250)/50)+1
if math.floor(level) == level then
player.level = level
end
end
(tested)
In this code, it checks if the speed is above 250. If it is, it does some maths calculations. First it takes away 250 from the level, divides it by 50 so that you get number of 50's in speed-250 for example which is 5 if speed is 500. Now we add one level to that, because 250-250/50 = 0 and it should be one level. Then we check if it's a decimal (you can remove the fourth line which checks it)
Math.floor ROUNDS DOWN the number (math.ceil [ceiling] rounds up), comparing the normal number to the rounded number. if the rounded number and normal number and the same that means it didn't have to be rounded because it was a whole number. So in this case we set the level.
I would go on about the extensive usage of if, elseif, else but since you're new I'll leave you alone about that.
Also, don't have this much music omg. People aren't going to stay at the menu for 4 minutes, cut it down and use a looping song. Also each menu or state doesn't need it's own song
Here is the modified .love (with music removed for all but the game because i cant upload this much):
http://cl.ly/PHZT
Otherwise, not too bad.