Page 1 of 1

Menu Screens, Animation and Platforming

Posted: Tue Jul 10, 2012 9:22 pm
by GungnirDev
This is my "game." I constructed it mostly through the guidance of munkeebacon's YouTube channel and browsing older posts here for extra coding tips. It's pretty basic, and by "basic" I mean "what, you call that a game?!" But hey, I can jump!

I pretty much have three separate sections I need help on, so feel free to comment on any of them, all of them, or none of them.

1. Menu Screen. I would like to turn the menu buttons into a character-select wheel so you can select a particular character or quit the game. Most of them will be unused for now, but I'll be able to add more characters and game modes as the project goes on.

2. Animations. How do I animate sprites? Because at the moment my protagonist just looks like a big ominously floating statue. He can't seem to turn around either.

3. Platforming. How do I make collision and platforming? I need tiles/platforms that neither enemies nor the player can move through.

Re: Menu Screens, Animation and Platforming

Posted: Tue Jul 10, 2012 10:15 pm
by Bannana97
I made a class for #3, though it only works with polygons (rectangles) and circles.

You can easily set properties of a "Part" or "Circle" by doing stuff like:

Code: Select all

part = Instance.new("Part")
part.Name = "Part 01"
part.CanCollide = true -- force other cancollide-true bodies to collide
part.Anchored = true -- don't allow physics to move the part
It also has a Touched event handler:

Code: Select all

hookEvent(p, "Touched", (function(part) 
     print(part.Name.." touched me. I don't like being touched. Nooo!") 
end))
If this will work for you, let me know. :)

Re: Menu Screens, Animation and Platforming

Posted: Wed Jul 11, 2012 1:03 am
by coffee
thesmeagle wrote:It's pretty basic, and by "basic" I mean "what, you call that a game?!" But hey, I can jump!
Yes you can! But you can start correcting two small bad practices even that don't do for now much problems. You have two "main.draw" (so first one is ignored and you avoid error of "text" var not defined). Also you have your "love.keypressed(key)" inside "love.load" (controls still work but not intended to be there). Don't worry, keep working. :)

Re: Menu Screens, Animation and Platforming

Posted: Wed Jul 11, 2012 2:24 am
by kexisse
thesmeagle wrote:2. Animations. How do I animate sprites? Because at the moment my protagonist just looks like a big ominously floating statue. He can't seem to turn around either.
For animation, I highly recommend Kikito's anim8 library: http://github.com/kikito/anim8

For finding libraries in general, use the Category:Libraries page from the wiki: https://love2d.org/wiki/Category:Libraries

Re: Menu Screens, Animation and Platforming

Posted: Wed Jul 11, 2012 2:39 am
by MunkeeBacon
I'm honored. I have been planning to do a tutorial on animations for a while, but the other things are to specific for a tutorial. But really, It's awesome to know that people have been using my videos!

Re: Menu Screens, Animation and Platforming

Posted: Thu Jul 12, 2012 7:02 am
by GungnirDev
@ Bannana: That looks useful, it's just that how do I position the collision blocks? Do I need x-y coordinates?

@ kexisse: Where do I put that? Do I copy the code into a lua file, or is that an example, or what?

@ coffee: I will fix the duplicates, thx, it's always nice to kill code you don't need.

@ munkeebacon: yeah they're definitely the best love tutorials on YouTube. Of course, to be fair love is painfully underrepresented on YouTube so there's not much to compare them to, but they were still really helpful. So if anything you're a trailblazer ^^

Re: Menu Screens, Animation and Platforming

Posted: Thu Jul 12, 2012 7:16 am
by kexisse
thesmeagle wrote:@ kexisse: Where do I put that? Do I copy the code into a lua file, or is that an example, or what?
It's an external library. You download the file and require() it.
If you had scrolled down on that page, you would have seen an example of how to use the anim8.lua file:

Code: Select all

local anim8 = require 'anim8'

local image, animation

function love.load()
  image = love.graphics.newImage('path/to/image.png')
  local g = anim8.newGrid(32, 32, image:getWidth(), image:getHeight())
  animation = anim8.newAnimation('loop', g('1-8,1'), 0.1)
end

function love.update(dt)
  animation:update(dt)
end

function love.draw()
  animation:draw(image, 100, 200)
end

Re: Menu Screens, Animation and Platforming

Posted: Sat Jul 14, 2012 4:03 am
by Bannana97
thesmeagle wrote:@ Bannana: That looks useful, it's just that how do I position the collision blocks? Do I need x-y coordinates?
Yeah, you'd use variableName.Position = Vector2.new(10, 10) -- (x,y)