Page 1 of 1

HelloColor

Posted: Fri Mar 11, 2011 10:24 pm
by TylertheDesigner
Hello Color started as a tutorial for a friend, teaching him Lua + LOVE. However, after the tutorial session, I began tweaking the code, and came up with this simple prototype. The goal of the game is to find the circle matching the background color. The game ends when you have cleared all the circles. The total circles is based on the starting game resolution.

Enjoy!

Re: HelloColor

Posted: Sat Mar 12, 2011 12:48 am
by Robin
It's pretty late at night, so I don't have much time to try it out, but I have one piece of criticism that applies to your other games posted as well: please use love.keypressed rather than love.keyboard.isDown, because it is rather annoying when I tap a key once and it treats it like > 1.

Re: HelloColor

Posted: Sat Mar 12, 2011 8:28 am
by crow
Robin wrote:It's pretty late at night, so I don't have much time to try it out, but I have one piece of criticism that applies to your other games posted as well: please use love.keypressed rather than love.keyboard.isDown, because it is rather annoying when I tap a key once and it treats it like > 1.
I second that change in all of your games so far it is rather annoying.

Re: HelloColor

Posted: Sun Mar 13, 2011 10:24 pm
by TylertheDesigner
Robin wrote:It's pretty late at night, so I don't have much time to try it out, but I have one piece of criticism that applies to your other games posted as well: please use love.keypressed rather than love.keyboard.isDown, because it is rather annoying when I tap a key once and it treats it like > 1.
The problem I have with that (and I hope you guys can offer solutions) is that when its love.keypressed and you already have another key held, it stops detecting that key. In some of the games I have made, I set separate booleans for the keys (Player1.upKeyIsDown, etc).

Is there another way I can resolve this issue?

Thanks for the feedback!

Re: HelloColor

Posted: Sun Mar 13, 2011 10:34 pm
by crow
TylertheDesigner wrote:
Robin wrote:It's pretty late at night, so I don't have much time to try it out, but I have one piece of criticism that applies to your other games posted as well: please use love.keypressed rather than love.keyboard.isDown, because it is rather annoying when I tap a key once and it treats it like > 1.
The problem I have with that (and I hope you guys can offer solutions) is that when its love.keypressed and you already have another key held, it stops detecting that key. In some of the games I have made, I set separate booleans for the keys (Player1.upKeyIsDown, etc).

Is there another way I can resolve this issue?

Thanks for the feedback!
to a maybe do a double check like

Code: Select all

if Player1.upKeyIsDown and Player1.upKeyIsDown then
maybe not sure if love would let you do this?

Re: HelloColor

Posted: Sun Mar 13, 2011 10:44 pm
by tentus
crow wrote:
TylertheDesigner wrote:
Robin wrote:It's pretty late at night, so I don't have much time to try it out, but I have one piece of criticism that applies to your other games posted as well: please use love.keypressed rather than love.keyboard.isDown, because it is rather annoying when I tap a key once and it treats it like > 1.
The problem I have with that (and I hope you guys can offer solutions) is that when its love.keypressed and you already have another key held, it stops detecting that key. In some of the games I have made, I set separate booleans for the keys (Player1.upKeyIsDown, etc).

Is there another way I can resolve this issue?

Thanks for the feedback!
to a maybe do a double check like

Code: Select all

if Player1.upKeyIsDown and Player1.upKeyIsDown then
maybe not sure if love would let you do this?
That would work, yeah. This is what I currently use for the player in my game, Kurosuke:

Code: Select all

	local left = love.keyboard.isDown(self.key.left) or joystick.pressed[self.key.left]
	local right = love.keyboard.isDown(self.key.right) or joystick.pressed[self.key.right]
	if right and not left then
		ent.actor.avatar[self.id].direction = 1
		ent.actor.avatar[self.id]:run()
	elseif left and not right then
		ent.actor.avatar[self.id].direction = -1
		ent.actor.avatar[self.id]:run()
	end
There's some extra code in there that you wouldn't need (such as my joystick code), but you get the idea.

Re: HelloColor

Posted: Sun Mar 13, 2011 10:51 pm
by thelinx
I personally solve that problem by using vectors.

It looks something like this:

Code: Select all

moveBy = Vector(0, 0)
if isDown("right") then
  moveBy = moveBy + Vector(1, 0)
end
if isDown("down") then
  moveBy = moveBy + Vector(0, 1)
end
if isDown("left") then
  moveBy = moveBy - Vector(1, 0)
end
if isDown("up") then
  moveBy = moveBy - Vector(0, 1)
end
player:move(moveBy * player.speed * dt)
This also makes it super easy to implement joystick input. Just replace all those if statements with:

Code: Select all

moveBy = Vector(love.joystick.getAxis(0), love.joystick.getAxis(1)) -- or something similar

Re: HelloColor

Posted: Sun Mar 13, 2011 10:58 pm
by crow
Is vectors a love function ? or a lua module?

Re: HelloColor

Posted: Sun Mar 13, 2011 11:00 pm
by thelinx
There are several implementations, I can recommend the Vector "class" in vrld's HUMP library.