Page 1 of 2
Gluttony (formerly The Five Second Game)
Posted: Sun Jan 01, 2012 5:54 am
by MarekkPie
Gluttony
The object is to eat as many good pieces of food as you can before the timer expires. Here are the game rules:
Good food (green)
- Worth 10 points;
- Increases your countdown clock by one second;
- Increases your radius by 1.
Bad food (red)
- Subtracts 5 points;
- Decreases your countdown clock by 0.2 seconds;
It's simple, but I think it's pretty fun. Since you get fatter each time you eat a good food item, it becomes more and more difficult to avoid the bad food items the more good food you've eaten.
Changelist:
Version 0.2
- Added a simple, event based menu system;
- Added a simple tutorial that is played on initial launch;
[/i]
To do:
- Change art to something more appealing;
- Add local high score tracking;
- Add sound;
Re: The Five Second Game
Posted: Sun Jan 01, 2012 9:53 am
by Tesselode
I think the problem is that you're calling tween in the update loop. You only need to call it once.
Edit: also, you might want to add a way to restart the game. Also, you might want to increase the number of sides the circle has as its radius gets bigger so it doesn't look ugly.
Re: The Five Second Game
Posted: Sun Jan 01, 2012 3:19 pm
by MarekkPie
Tesselode wrote:I think the problem is that you're calling tween in the update loop. You only need to call it once.
Edit: also, you might want to add a way to restart the game. Also, you might want to increase the number of sides the circle has as its radius gets bigger so it doesn't look ugly.
Thanks. Just woke up, so I'll test that out.
I'm working on a menu and a simple tutorial screen, but right now just press F2 to restart. Forgot to mention that in the original post.
EDIT: Whoops, just noticed F2 doesn't reset the player size. I'll update the .love in a second.
Re: The Five Second Game
Posted: Sun Jan 01, 2012 8:17 pm
by MarekkPie
So, I'm working on giving the game a menu screen. The way I plan to do it is have separate love callbacks for the two game states: menu state, and play state. However, as I was not really thinking about this last night, I failed to initially define a namespace for the play state, as it was the only state at that point.
I know Lua doesn't natively support namespaces in the traditional sense, so my understanding is that people simply wrap a table around their code and call it a namespace. My only issue is that I'm not sure it will work with my current set up. Here is my dilemma:
Code: Select all
namespace = {
x = 0
y = 0
function A(n) return n end -- Is the key for this 'A' or '1'?
function B() return A(0) end
x = function B() -- Will I be able to call B() while still inside namespace?
}
namespace.x = namespace.B() -- Or will I have to be outside of the declaration before I can do any calls?
I would like to be able wrap the love callbacks in the namespace as well, so that from menu, when the player pushes "PLAY," I can just call the play state's love.load().
Any help would be appreciated. Even if it is a "you're doing it wrong, here is a better way."
Re: The Five Second Game
Posted: Sun Jan 01, 2012 8:51 pm
by Tesselode
You could just use hump.gamestate.
http://love2d.org/wiki/hump
Re: The Five Second Game
Posted: Sun Jan 01, 2012 9:08 pm
by MarekkPie
Thanks for the idea.
It seems that I'd still need to rewrite a ton of code in order to get that to work properly. Was hoping for a much simpler solution, but that might not be possible.
Re: The Five Second Game
Posted: Sun Jan 01, 2012 11:55 pm
by kikito
Hi,
Did you resolve your problem with tween, or do you still need help there?
Change the love.* functions from the
inside, not from the
outside. It's much easier this way:
Code: Select all
function love.update(dt)
gameState.update(dt)
end
function love.draw()
gameState.draw()
end
And then:
Code: Select all
Play = {
update = function(dt)
end,
draw = function()
end
}
function love.load()
gameState = Play
end
You can't do that with love.load since there must be only one call to love.load(). But you can add load() functions to the states and call them when you change the state:
Code: Select all
Menu = {
load = function()
-- load stuff here
end,
unload = function()
-- unload stuff here
end
}
function gotoState(newState)
if type(gameState.unload)=="function" then gameState.unload() end
gameState = newState
if type(gameState.load)=="function" then gameState.load() end
end
function love.load()
gotoState(Menu) -- always use gotoState to change gameState. Never change gameState directly
end
By the way, this might be a good moment to split the game in several files, if you haven't already.
Re: The Five Second Game
Posted: Mon Jan 02, 2012 1:08 am
by MarekkPie
Thanks kikito.
I am still having some trouble with tween, but I am rewriting from the ground up to accommodate for game states, so I am not at the point to start thinking about them again.
I ended up doing something very similar to what you suggested for game states. That also happens to be similar to how PiL talks about namespaces (or packages).
http://www.lua.org/pil/15.1.html
I am also taking the opportunity to try out all the random features within LOVE I can with the rewrite, so I am looking at the using the framebuffer. In the tutorial thread on the Framebuffer wiki page, they used love.graphics.draw() exclusively. Can I use other love.graphics functions to draw onto the framebuffer? I don't want to build any art at the moment, so I am using the primitives supplied by love.graphics (circle, rectangle, print). Can I draw those onto the framebuffer? I tried both implementations fb:renderTo(function()) and love.graphics.setRenderTarget(fb) and they both give me a black screen.
Here is the updated version of the five second game. I renamed it to Gluttony because I thought it fit better.
Re: The Five Second Game
Posted: Mon Jan 02, 2012 3:46 am
by Ryne
fun game, I was kinda bored earlier so I created some quick graphics.
hope you don't mind, you can feel free to use these if you like.
* that white circle is the selector
** resources, can be resized if need be.
http://d.pr/fi4R
Re: The Five Second Game
Posted: Mon Jan 02, 2012 3:50 am
by MarekkPie
That's awesome, Ryne. Thanks a bunch.