Page 1 of 2

Quack! A game about a duck

Posted: Fri Jun 07, 2013 2:43 am
by Mermersk
Hello,

So this is the first game I have ever made, I barely knew how to code before this, so I realize that the code may be a bit messy. It would be nice if someone could go over it and point out flaws. I tried to put it in order and document what I was doing.

The only thing I was not able to do was to get the duck to rotate constantly towards where the mouse clicks, the furthest I got was this:

--snuningur = mx / 203.82 and my / 131.68

You can activate it but it barely works, especially not when going flying to the left.
The way to color the text/font was also somewhat time confusing, I hope there is an easier/cleaner way to do it :awesome:
How can you put the name of the game in the header? instead of it just being "untitled"

You use the left mouse button to fly!

Re: Quack! A game about a duck

Posted: Fri Jun 07, 2013 4:39 am
by LuaWeaver
About the rotation towards mouse thing, you can use a bit of trig. First, get the X and Y position of the mouse and the duck. Move the mouse into the object space of the duck (mouse pos-duck pos). Then, because you know the lengths, you can get the angle. The angle you want is the topmost angle of the triangle, so you can use tangent^-1 to get this number. You know the opposite is the X of the object space and the adjacent the Y of it, so you can do math.atan(objX/objY) to find the angle! This will be in radians, by the way.

This may or may not be right, I'm tired, but you now know you can use trig. To wrap it up, assume "duckX" and "duckY" are the duck's pos and "mX" and "mY" are the mouse pos.

local ang=math.atan((mX-duckX)/(mY-duckY))

Re: Quack! A game about a duck

Posted: Fri Jun 07, 2013 7:21 pm
by qaisjp
i dont really understand this game. i went to the switch, had a little big of lag, the dead picture of my duck and a light appeared instead. and i couldn't do anything but quack in my sleep.

for title: http://www.love2d.org/wiki/Config_Files

Re: Quack! A game about a duck

Posted: Sat Jun 08, 2013 12:52 am
by Mermersk
Thank you for the post LuaWeaver, I will try that.

Hehe (: ,qaisjp That light thing was supposed to be the "soul" leaving the body, or something like that :huh: .

The game developed strangely, I had already drawn the lamp before I decided to experiment with Löve, so I had to think of some way to incorporate some gameplay with it. I wanted also to have a bird and flying. So that's why the bird turns the lamp on the way he does. That lag is the lamp turning on, it takes some time, as the sound that plays with it shows.

Re: Quack! A game about a duck

Posted: Sun Jun 09, 2013 5:41 am
by T-Bone
This is one of the strangest and most surreal games I have ever played. I find it very amusing :neko:

Re: Quack! A game about a duck

Posted: Tue Jun 11, 2013 6:12 pm
by veethree
Are you icelandic/danish or something like that?

Re: Quack! A game about a duck

Posted: Tue Jun 11, 2013 6:41 pm
by davisdude
So, when you're drawing the duck you need:

Code: Select all

 love.graphics.draw( pic_name, x, y, DIR, ... )
Ignore the ellipsis, that means nothing. Then, in love.update do this:

Code: Select all

DIR = math.atan2( player.y - mouseY, player.x - mouseX )
Depending on your picture you may have to add or subtract to get it to look right.

Re: Quack! A game about a duck

Posted: Wed Jun 12, 2013 1:54 am
by Mermersk
davisdude wrote:So, when you're drawing the duck you need:

Code: Select all

 love.graphics.draw( pic_name, x, y, DIR, ... )
Ignore the ellipsis, that means nothing. Then, in love.update do this:

Code: Select all

DIR = math.atan2( player.y - mouseY, player.x - mouseX )
Depending on your picture you may have to add or subtract to get it to look right.
Thanks, I will try that!
veethree wrote:Are you icelandic/danish or something like that?
Yes I am from Iceland, þú lika?
T-Bone wrote:This is one of the strangest and most surreal games I have ever played. I find it very amusing :neko:
Thank you T-Bone! :awesome:

I realised a few days ago that I could hand draw the duck and animate, and it looks fantastic! Only problem is that I have the duck moving and a white box in the background with it, is there any way to make everything transparent except the are of drawing? in Asesprite or paint ?

There is also a conf.lua file, so now there is a name in the title of the window.

Re: Quack! A game about a duck

Posted: Wed Jun 12, 2013 3:21 am
by davisdude
I realised a few days ago that I could hand draw the duck and animate, and it looks fantastic! Only problem is that I have the duck moving and a white box in the background with it, is there any way to make everything transparent except the are of drawing? in Asesprite or paint ?
Yes. I prefer a free open source editing software called Gimp. You can download it here: http://www.gimp.org/
Just note that if the resolution of your image is not good, it may take a very long time.
Anyway, to get the background transparent do these 3 things:
1) Open gimp and then open your picture.
2) Move your mouse over layer, then transparency, then add Alpha Channel and click on it.
3) Click the 'fuzzy selector tool' (the one that looks like a magic wand). Then, click on the area you want to delete. Assuming it's all the same color it lined border will appear around everything. Click delete to remove it. If you ever make a mistake you can press 'cntrl' and 'z' or find the undo button.
Note that if you edit it again in another form (say MS Paint) that you will have to do this over again, so keep edits to a minimum/ have your picture ready before this stage.

Re: Quack! A game about a duck

Posted: Wed Jun 12, 2013 6:30 am
by Plu
You can also use paint.NET. It's also free, but it kinda looks and works like Paint except it has a whole bunch of added cool and usable features, including background transparancy.