Feeding Seppe (first game + some questions)

Show off your games, demos and other (playable) creations.
User avatar
Megaera
Prole
Posts: 3
Joined: Wed Oct 14, 2015 5:46 am

Feeding Seppe (first game + some questions)

Post by Megaera »

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. :cool:
Attachments
FeedingSeppe.love
(72.7 KiB) Downloaded 142 times
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Feeding Seppe (first game + some questions)

Post by Nixola »

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
lf = love.filesystem
ls = love.sound
la = love.audio
lp = love.physics
lt = love.thread
li = love.image
lg = love.graphics
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: Feeding Seppe (first game + some questions)

Post by undef »

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.
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.
Are you kidding me?!
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 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:

Code: Select all

math.randomseed( os.time() ) -- useful
This doesn't do anything useful. don't do this:

Code: Select all

math.random(); math.random(); math.random()
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 ).
twitter | steam | indieDB

Check out quadrant on Steam!
User avatar
zorg
Party member
Posts: 3470
Joined: Thu Dec 13, 2012 2:55 pm
Location: Absurdistan, Hungary
Contact:

Re: Feeding Seppe (first game + some questions)

Post by zorg »

undef wrote:This doesn't do anything useful. don't do this:

Code: Select all

math.random(); math.random(); math.random()
Anyway, keep it up!
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.
Me and my stuff :3True 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.
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: Feeding Seppe (first game + some questions)

Post by undef »

Doesn't that just discard three random values?
twitter | steam | indieDB

Check out quadrant on Steam!
User avatar
Nixola
Inner party member
Posts: 1949
Joined: Tue Dec 06, 2011 7:11 pm
Location: Italy

Re: Feeding Seppe (first game + some questions)

Post by Nixola »

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
User avatar
undef
Party member
Posts: 438
Joined: Mon Jun 10, 2013 3:09 pm
Location: Berlin
Contact:

Re: Feeding Seppe (first game + some questions)

Post by undef »

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:
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:
...
twitter | steam | indieDB

Check out quadrant on Steam!
User avatar
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)

Post by Jasoco »

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.
User avatar
Megaera
Prole
Posts: 3
Joined: Wed Oct 14, 2015 5:46 am

Re: Feeding Seppe (first game + some questions)

Post by Megaera »

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?
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 ).
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.
User avatar
CaptainMaelstrom
Party member
Posts: 163
Joined: Sat Jan 05, 2013 10:38 pm

Re: Feeding Seppe (first game + some questions)

Post by CaptainMaelstrom »

Code: Select all

if v.y < seppe.y then
      v.y = v.y + 150 * dt 
    else
      table.remove(frikandels,i)
    end  
  end
The 150 number in the line above determines the speed that the food falls. In order to make the foods fall at random speeds, simply make that number random instead.

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
since math.random will choose a new random number between 100 and 200 each update cycle (basically each frame).

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)}     
and then

Code: Select all

v.y = v.y + v.speed * dt 
Repeat for each food item. Also, you can use math.random or love.math.random. They are both random enough. Just make sure that for whatever function you choose, you set the appropriate seed for it, either with math.randomseed(n) or love.math.setRandomSeed(n). Also, fun game! Keep it up. :)

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.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 3 guests