Gluttony (formerly The Five Second Game)

Show off your games, demos and other (playable) creations.
User avatar
Ryne
Party member
Posts: 444
Joined: Fri Jan 29, 2010 11:10 am

Re: The Five Second Game

Post by Ryne »

MarekkPie wrote:That's awesome, Ryne. Thanks a bunch.

no problem, I didn't really stick to your games resolution or anything so if you want I can resize whatever you need.

the graphics are also meant to scale, so they are pretty tiny and should be scaled using "love.graphics.scale(4, 4)"

you can use this piece of code to make sure they scale properly as well.

Code: Select all

local oldNewImage = love.graphics.newImage

function love.graphics.newImage(...) -- basic code to filter image scaling to nearest

	local img = oldNewImage(...)
	img:setFilter("nearest", "nearest")
	return img
	
end
@rynesaur
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: The Five Second Game

Post by Robin »

MarekkPie wrote: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:
It doesn't work, because it's not a namespace at all, in Lua {} is just the notation for table literals.

Inside a table literal, the only thing you can have is [key] = value, where key and value are both expressions.

Example:

Code: Select all

a = {5, 6, 7} -- short for a = {[1] = 5, [2] = 6, [3] = 7}
b = {q = 10} -- short for b = {['q'] = 10}
c = {f = function () end} -- short for c = {['f'] = function () end}
The way namespaces are usually used in Lua is the following way:

Code: Select all

namespace = {}

function namespace.a ()
end

function namespace.b ()
end
Help us help you: attach a .love.
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Gluttony (formerly The Five Second Game)

Post by MarekkPie »

Uploaded new version in the original post!

Thanks Robin.

I found online a nice way to do namespaces without having to constantly retype namespace. It'll also allow for some private functions within the namespace/package.

Code: Select all

-- In file "namespace.lua"
do -- <== Important if you want to be able to give the namespace a new alias
	local varA
	local varB

	local function funcA()
      print("hidden")
	end
	
	local function funcB()
		funcA()
	end
	
	namespace = {
		varB = varB,
		funcB = funcB,
	}
	
	return namespace -- <== Allows for new alias
end -- <== Allows for new alias
Anything you want to be private, simply don't give it an alias within your namespace. When you need access to the namespace, in another file, do this:

Code: Select all

local N = require "--[[PATHTO: namespace.lua]]"

B = N.varB
A = N.varA -- nil (since there is not an alias for varA)

N.funcA() -- error (since there is not an alias for funcA)
N.funcB() -- prints "hidden"
User avatar
kikito
Inner party member
Posts: 3153
Joined: Sat Oct 03, 2009 5:22 pm
Location: Madrid, Spain
Contact:

Re: Gluttony (formerly The Five Second Game)

Post by kikito »

There is an implicit "do ... end" on each file (they have their own scope already built in). You don't need to add do .. end when you create a new file. Just make whatever you don't want to share local, and don't attach it to the returned table.
When I write def I mean function.
User avatar
Robin
The Omniscient
Posts: 6506
Joined: Fri Feb 20, 2009 4:29 pm
Location: The Netherlands
Contact:

Re: Gluttony (formerly The Five Second Game)

Post by Robin »

Also, N.varB is nil as well, since there is no varB = 6 or something in namespace.lua.
Help us help you: attach a .love.
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Gluttony (formerly The Five Second Game)

Post by MarekkPie »

Robin wrote:Also, N.varB is nil as well, since there is no varB = 6 or something in namespace.lua.
My bad. Meant to put in an assignment for those but forgot.
kikito wrote:There is an implicit "do ... end" on each file (they have their own scope already built in). You don't need to add do .. end when you create a new file. Just make whatever you don't want to share local, and don't attach it to the returned table.
Hrmm, I was getting a lot of weird errors whenever I didn't put the do...end block around my file. It was on several files, so it wasn't a localized problem. But I just tested it and it worked out...hrmm...(/goinginsane)
spirulence
Prole
Posts: 8
Joined: Tue Sep 21, 2010 8:27 pm

Re: Gluttony (formerly The Five Second Game)

Post by spirulence »

This is a fun little game! I don't have a mouse handy, so my scores sat in the low 200s. Yikes!

I could almost hear the cheesy frantic chiptune that would go along with this.
User avatar
MarekkPie
Inner party member
Posts: 587
Joined: Wed Dec 28, 2011 4:48 pm
Contact:

Re: Gluttony (formerly The Five Second Game)

Post by MarekkPie »

Thanks a lot, spirulence.

Even with a mouse, the best I've gotten is 290. There definitely is an upper limit, just based on the available space, and for me, a good game is 260-290.

Have you figured out how to cheat yet? I didn't put it in intentionally, but I decided to leave it in even after I figured it out.
Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest