Lame hack of "lovalanche"

Showcase your libraries, tools and other projects that help your fellow love users.
User avatar
Xkeeper
Prole
Posts: 40
Joined: Wed Aug 04, 2010 2:49 am
Location: Henderson, Nevada, US
Contact:

Lame hack of "lovalanche"

Post by Xkeeper »

Here it is.

Image

It's basically a zero-player "game" -- really, a demo that pretends to be a game.

It just drops balls through a basic pachinko-style board (with all of three square pegs) and uses some obtuse mathematics to play with scores, combos, that sort of thing. While it's completely uninteractive, it can be kind of fun to watch, and was my first delve into LOVE.


For those that delve into the source, some explanations:

This makes no sense!

Code: Select all

function love.update(dt)
end;

function update2(dt) -- Called from love.draw, always as update2(1/60).
    world:update(dt)
    ....
I mean, love.draw isn't for updating, and you're completely ignoring dt!

You would think so, but the "game" runs at 60 FPS. Linking it to the draw function makes it so that it doesn't choke if you decide to move the window, which if you happen to move when you have physics active, well... hope you don't mind a crash (or some severely goofy physics, like everything compressing on top of other stuff.) It takes the "slowdown is better than dropping frames" approach, so that in the event some complex stuff happens that happens to take too long, the game won't penalize the player (and will give an advantage, instead -- which wouldn't leave the player feeling ripped off). Granted, this is simple enough that the FPS rarely drops below 60, so it's smooth as butter with no random physics jibbling.


You load the same audio source 5 times.

Yes, to implement channels. This way, multiple sound effects can stack without hearing it suddenly rewind to the start each time. Having 5 helps make it so that, even in the even that it does catch up to itself, it's really hard to notice.


This is just a copy of LOVEalanche!

That would kind of be the point, yes.


The images aren't in powers of two!

I am well aware. I don't have the editing software to increase padding without ruining the alpha channel. MS Paint is not a good graphics tool.


Why is the sound effect so quiet?

I often ran this in the background with music, and having 5 copies of the same effect at once can be kind of loud. It's turned down just as convenience, since it's not exactly critical or anything.



Other than that, it is what it is -- a simple, goofy demo I did in my spare time with no interactivity. If there's a better way to do anything (especially audio channels! I don't want to have to resort to having 4 copies of every sound effect just in case action gets complex), feel free to let me know.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Lame hack of "lovalanche"

Post by Robin »

It makes no sense!

love.run() (the main loop) is basically this:

Code: Select all

while true do
   love.update(love.timer.getTimeDelta())
   love.draw()
end
(Well, not really, but it's the basic way things happen.)

Putting update things in love.draw() won't change that.

You could get the same effect as you want with:

Code: Select all

local dt = 1/60
function love.update()
    -- same stuff
end --and don't call it from love.draw then
Also, for a quick PO2 fix, see http://love2d.org/wiki/PO2_Syndrome or http://love2d.org/wiki/ImageData#Examples

It looks nice.

At a certain moment it got stuck, and the only way to get them moving again was to shake the window. :P
Help us help you: attach a .love.
User avatar
thelinx
The Strongest
Posts: 857
Joined: Fri Sep 26, 2008 3:56 pm
Location: Sweden

Re: Lame hack of "lovalanche"

Post by thelinx »

I just wasted 30 minutes on this. :x

Disclaimer: I'm not really mad.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Lame hack of "lovalanche"

Post by Robin »

thelinx wrote:I just wasted 30 minutes on this. :x

Disclaimer: I'm not really mad.
Yes you are. But more this kind of mad: :crazy:
Help us help you: attach a .love.
User avatar
vrld
Party member
Posts: 917
Joined: Sun Apr 04, 2010 9:14 pm
Location: Germany
Contact:

Re: Lame hack of "lovalanche"

Post by vrld »

Always ends up like this: :(
damn.jpg
damn.jpg (152.42 KiB) Viewed 3118 times
I have come here to chew bubblegum and kick ass... and I'm all out of bubblegum.

hump | HC | SUIT | moonshine
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Lame hack of "lovalanche"

Post by Robin »

I'm not completely right: it does crazy jumpy things when I leave it alone for a while too. It seems the balls can't take the stress. ;)

Using a constant dt really slows things down when the frame rate is low (also it kind of defeats the purpose of dt anyway, but yeah).

Also:
Attachments
Look at the high score! Look how many balls passed!
Look at the high score! Look how many balls passed!
so-epic.png (484.89 KiB) Viewed 3110 times
Help us help you: attach a .love.
User avatar
Felipe Budinich
Citizen
Posts: 67
Joined: Thu Jul 29, 2010 1:36 pm

Re: Lame hack of "lovalanche"

Post by Felipe Budinich »

vrld wrote:Always ends up like this: :(
If you wait long enough, a emoticon will decide to jump.

This only needs an animation of hypnotoad on the background and you've got a cult hit (i spent so many time just looking at it...)
User avatar
Xkeeper
Prole
Posts: 40
Joined: Wed Aug 04, 2010 2:49 am
Location: Henderson, Nevada, US
Contact:

Re: Lame hack of "lovalanche"

Post by Xkeeper »

Yep, after 10 seconds (600 frames) of no balls being counted, it will start nudging balls to get it going again (starting from the bottom and moving progressively higher, looping around and getting faster as it goes). It usually only takes 1-10 to start it up again... Note that the smallest balls aren't counted for the purposes of detecting if it started up again.

The scoring would be rather pointless if it continued non-stop, after all. ;)

Using a constant dt really slows things down when the frame rate is low (also it kind of defeats the purpose of dt anyway, but yeah).
The problem is pretty easy to show; for example, try removing the call to update2() and moving it back into love.update, using dt as the argument instead of 1/60. It will work as expected... until you try to drag the window. If you're fast, it'll just kind of lag for a bit, but if you take more than a second or two to let go of it again, it might even crash (!) ... on Windows, at least, where it pauses while being dragged. Not sure about other OS versions.

It could probably be fixed a bit to use, say, "dt = math.min(dt, 10/60)" (to allow for some speedup, but not enough to break physics). I've never personally encountered a slow enough system to make it lag that badly, though.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Lame hack of "lovalanche"

Post by Robin »

Xkeeper wrote:I've never personally encountered a slow enough system to make it lag that badly, though.
Mine. At a certain moment. In those 10 seconds, it was ~5 FPS, while I did nothing fancy. (Like moving the window.)
Help us help you: attach a .love.
User avatar
Xkeeper
Prole
Posts: 40
Joined: Wed Aug 04, 2010 2:49 am
Location: Henderson, Nevada, US
Contact:

Re: Lame hack of "lovalanche"

Post by Xkeeper »

Robin wrote:
Xkeeper wrote:I've never personally encountered a slow enough system to make it lag that badly, though.
Mine. At a certain moment. In those 10 seconds, it was ~5 FPS, while I did nothing fancy. (Like moving the window.)
Hm, your computer might be ancient. I'm not terribly sure it would be much smoother with frameskipping, either, though you are welcome to edit it and see.
Post Reply

Who is online

Users browsing this forum: No registered users and 25 guests