Feeding Seppe (first game + some questions)
Feeding Seppe (first game + some questions)
Hi everyone,
I'm mostly new here. Over the summer, I played around with LÖVE for a bit, but it was never more than a few lines of code before I lost interest. So, I decided to lurk the forums and hang out on the IRC, until maybe, I felt inspired.
Now I'm not really a programmer. I've dealt with some programming languages before, but the only one that I'm probably above average at is Prolog. Which is not really an accomplishment - the average is that almost no one knows Prolog. Not knowing things never holds me back, if I'm enjoying myself, I'm totally fine with putting out mediocre things.
Last week, I found an old notebook, with a cartoonish drawing I made a few years ago of my brother pulling up my parents' bulldog with a rope. For some reason - probably sleep deprevation - I found this funny and made a few really, really bad comics about my family, that dog and their cat. I was enjoying myself so much, I decided I should make it into a Facebook page. Which needed a profile picture.
(https://www.facebook.com/The-Seppe-Tale ... 839679577/)
Making that profile picture was the inspiration I needed. I decided I could make a small game out of this stupid fun idea that my friends and family seem to enjoy. So I did.
There are a few small things I want to take care of on before I will consider it actually finished. That's one of my reasons for sharing, to ask questions!
- I can't make music. Is there a place I can get something for free to use as background music?
- For some reason, math.random() doesn't always seem to work. I'd like to randomize the speed of the items dropping. What's the best way to do this?
Feel free to tear my code down! I'd love some advice on how to do things better.
I'm mostly new here. Over the summer, I played around with LÖVE for a bit, but it was never more than a few lines of code before I lost interest. So, I decided to lurk the forums and hang out on the IRC, until maybe, I felt inspired.
Now I'm not really a programmer. I've dealt with some programming languages before, but the only one that I'm probably above average at is Prolog. Which is not really an accomplishment - the average is that almost no one knows Prolog. Not knowing things never holds me back, if I'm enjoying myself, I'm totally fine with putting out mediocre things.
Last week, I found an old notebook, with a cartoonish drawing I made a few years ago of my brother pulling up my parents' bulldog with a rope. For some reason - probably sleep deprevation - I found this funny and made a few really, really bad comics about my family, that dog and their cat. I was enjoying myself so much, I decided I should make it into a Facebook page. Which needed a profile picture.
(https://www.facebook.com/The-Seppe-Tale ... 839679577/)
Making that profile picture was the inspiration I needed. I decided I could make a small game out of this stupid fun idea that my friends and family seem to enjoy. So I did.
There are a few small things I want to take care of on before I will consider it actually finished. That's one of my reasons for sharing, to ask questions!
- I can't make music. Is there a place I can get something for free to use as background music?
- For some reason, math.random() doesn't always seem to work. I'd like to randomize the speed of the items dropping. What's the best way to do this?
Feel free to tear my code down! I'd love some advice on how to do things better.
- Attachments
-
- FeedingSeppe.love
- (72.7 KiB) Downloaded 142 times
Re: Feeding Seppe (first game + some questions)
1) Here there's a lot of free music!
2) Use [wiki]love.math.random[/wiki], it should work better; being in school, I can't run or see the game now though, so the issue might be somewhere else
2) Use [wiki]love.math.random[/wiki], it should work better; being in school, I can't run or see the game now though, so the issue might be somewhere else
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: Feeding Seppe (first game + some questions)
Congratulations on your first game!
Keep it going!
One thing I noticed is that some food goes off screen, keep in mind that the rightmost position you want to spawn your food at is the screen width minus the width of the image.
Doing Prolog is pretty badass.
One thing I found in your code:
If you don't know what you're doing, don't do it, or play around with it untily you know.
If you start putting code into your games that you don't understand you end up having errors that you won't be able to find, let alone fix.
This makes sure your random numbers are always different, every time you start the game:
This doesn't do anything useful. don't do this:
Anyway, keep it up!
Edit:
Sorry, forgot to tell you about your falling speed problem.
You're always just doing v.y = v.y + 150 * dt, that's why the speed is constant.
You will probably want to store the speed of each falling object in the table and then do v.y = v.y + v.speed * dt.
For that you will have to make sure to initalize the speed when creating the object with speed = math.random( min, max ).
Keep it going!
One thing I noticed is that some food goes off screen, keep in mind that the rightmost position you want to spawn your food at is the screen width minus the width of the image.
Are you kidding me?!Megaera wrote:Now I'm not really a programmer. I've dealt with some programming languages before, but the only one that I'm probably above average at is Prolog. Which is not really an accomplishment - the average is that almost no one knows Prolog.
Doing Prolog is pretty badass.
One thing I found in your code:
Code: Select all
-- Something the internet said would help
-- no idea what I am doing here
math.randomseed( os.time() )
math.random(); math.random(); math.random()
If you start putting code into your games that you don't understand you end up having errors that you won't be able to find, let alone fix.
This makes sure your random numbers are always different, every time you start the game:
Code: Select all
math.randomseed( os.time() ) -- useful
Code: Select all
math.random(); math.random(); math.random()
Edit:
Sorry, forgot to tell you about your falling speed problem.
You're always just doing v.y = v.y + 150 * dt, that's why the speed is constant.
You will probably want to store the speed of each falling object in the table and then do v.y = v.y + v.speed * dt.
For that you will have to make sure to initalize the speed when creating the object with speed = math.random( min, max ).
- zorg
- Party member
- Posts: 3470
- Joined: Thu Dec 13, 2012 2:55 pm
- Location: Absurdistan, Hungary
- Contact:
Re: Feeding Seppe (first game + some questions)
Correction, that was there in löve's love.run (before love.math) because (iirc) on some systems, the lua random generator's first few values weren't "random enough", but after, it got taken out since everyone should use love's function instead of lua's now.undef wrote:This doesn't do anything useful. don't do this:Anyway, keep it up!Code: Select all
math.random(); math.random(); math.random()
Me and my stuff True Neutral Aspirant. Why, yes, i do indeed enjoy sarcastically correcting others when they make the most blatant of spelling mistakes. No bullying or trolling the innocent tho.
Re: Feeding Seppe (first game + some questions)
Doesn't that just discard three random values?
Re: Feeding Seppe (first game + some questions)
Yes, it discards the first three random values as they may be not random enough.
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
Re: Feeding Seppe (first game + some questions)
Can I read up on that somewhere?
How is the fourth value any more random than the three previous ones?
Edit:
Weird, even lua-users contradicts itself on that one:
How is the fourth value any more random than the three previous ones?
Edit:
Weird, even lua-users contradicts itself on that one:
But beware! The first random number you get is not really 'randomized' (at least in Windows 2K and OS X). To get better pseudo-random number just pop some random number before using them for real:
-- Initialize the pseudo random number generator
math.randomseed( os.time() )
math.random(); math.random(); math.random()
-- done. :-)
-- This not exactly true. The first random number is as good (or bad) as the second one and the others. The goodness of the generator depends on other things. To improve somewhat the built-in generator we can use a table in the form:
...
- Jasoco
- Inner party member
- Posts: 3727
- Joined: Mon Jun 22, 2009 9:35 am
- Location: Pennsylvania, USA
- Contact:
Re: Feeding Seppe (first game + some questions)
Either way you should use love.math.random instead since it'll be the same values on all systems whereas math.random will be different on each system.
Better yet, look into creating RNGs to have separate random number generators for different parts of the game.
Better yet, look into creating RNGs to have separate random number generators for different parts of the game.
Re: Feeding Seppe (first game + some questions)
Thanks everyone! Had quite a busy day and didn't have time get much done, I'm going to try and finish the last touches tomorrow.
It's good to know I'm not the only one for who the math.random() part seemed confusing. Are there a lot of functions like that, that have a löve alterative?
It's good to know I'm not the only one for who the math.random() part seemed confusing. Are there a lot of functions like that, that have a löve alterative?
It took me a while to realize that math.random() was giving me a constant because it never got updated anywhere. I think this idea is exactly what I want to do.Undef wrote: Sorry, forgot to tell you about your falling speed problem.
You're always just doing v.y = v.y + 150 * dt, that's why the speed is constant.
You will probably want to store the speed of each falling object in the table and then do v.y = v.y + v.speed * dt.
For that you will have to make sure to initalize the speed when creating the object with speed = math.random( min, max ).
- CaptainMaelstrom
- Party member
- Posts: 163
- Joined: Sat Jan 05, 2013 10:38 pm
Re: Feeding Seppe (first game + some questions)
Code: Select all
if v.y < seppe.y then
v.y = v.y + 150 * dt
else
table.remove(frikandels,i)
end
end
Note however, the code below will make the food look jittery as it falls:
Code: Select all
if v.y < seppe.y then
v.y = v.y + math.random(100, 200)* dt
else
table.remove(frikandels,i)
end
end
To get the food to move at a constant but randomized speed, I recommend you choosing a random speed each piece of food will fall when you create the food.
I would do:
Code: Select all
frikandel = {x = math.random(10, love.window.getWidth() - 50), y = 35, speed = math.random(100, 200)}
Code: Select all
v.y = v.y + v.speed * dt
EDIT: Oops! I somehow missed Undef's post that explains the same thing. Regardless, I will leave this here because of the specificity and it may help somebody else some day.
Who is online
Users browsing this forum: No registered users and 2 guests