Quack! A game about a duck

Show off your games, demos and other (playable) creations.
User avatar
Mermersk
Party member
Posts: 108
Joined: Tue Dec 20, 2011 3:27 am

Quack! A game about a duck

Post 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!
Attachments
Light.love
(1.7 MiB) Downloaded 303 times
LuaWeaver
Party member
Posts: 183
Joined: Wed Mar 02, 2011 11:15 pm
Location: Ohio, USA

Re: Quack! A game about a duck

Post 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))
"your actions cause me to infer your ego is the size of three houses" -finley
User avatar
qaisjp
Party member
Posts: 490
Joined: Tue Sep 04, 2012 10:49 am
Location: United Kingdom
Contact:

Re: Quack! A game about a duck

Post 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
Lua is not an acronym.
User avatar
Mermersk
Party member
Posts: 108
Joined: Tue Dec 20, 2011 3:27 am

Re: Quack! A game about a duck

Post 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.
User avatar
T-Bone
Inner party member
Posts: 1492
Joined: Thu Jun 09, 2011 9:03 am

Re: Quack! A game about a duck

Post by T-Bone »

This is one of the strangest and most surreal games I have ever played. I find it very amusing :neko:
User avatar
veethree
Inner party member
Posts: 875
Joined: Sat Dec 10, 2011 7:18 pm

Re: Quack! A game about a duck

Post by veethree »

Are you icelandic/danish or something like that?
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Quack! A game about a duck

Post 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.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
Mermersk
Party member
Posts: 108
Joined: Tue Dec 20, 2011 3:27 am

Re: Quack! A game about a duck

Post 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.
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Quack! A game about a duck

Post 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.
GitHub | MLib - Math and shape intersections library | Walt - Animation library | Brady - Camera library with parallax scrolling | Vim-love-docs - Help files and syntax coloring for Vim
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: Quack! A game about a duck

Post 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.
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 2 guests