Menu Screens, Animation and Platforming

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
GungnirDev
Party member
Posts: 119
Joined: Thu Jun 28, 2012 10:31 pm

Menu Screens, Animation and Platforming

Post 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.
Attachments
PSgame.love
(317.93 KiB) Downloaded 115 times
Bullets are the beauty of the blistering sky
Bullets are the beauty and I don't know why
Bannana97
Citizen
Posts: 77
Joined: Wed May 16, 2012 2:49 pm

Re: Menu Screens, Animation and Platforming

Post 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. :)
coffee
Party member
Posts: 1206
Joined: Wed Nov 02, 2011 9:07 pm

Re: Menu Screens, Animation and Platforming

Post 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. :)
User avatar
kexisse
Citizen
Posts: 56
Joined: Wed Jun 13, 2012 2:52 pm

Re: Menu Screens, Animation and Platforming

Post 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
MunkeeBacon
Prole
Posts: 15
Joined: Sun Jul 01, 2012 7:33 pm

Re: Menu Screens, Animation and Platforming

Post 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!
User avatar
GungnirDev
Party member
Posts: 119
Joined: Thu Jun 28, 2012 10:31 pm

Re: Menu Screens, Animation and Platforming

Post 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 ^^
Bullets are the beauty of the blistering sky
Bullets are the beauty and I don't know why
User avatar
kexisse
Citizen
Posts: 56
Joined: Wed Jun 13, 2012 2:52 pm

Re: Menu Screens, Animation and Platforming

Post 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
Bannana97
Citizen
Posts: 77
Joined: Wed May 16, 2012 2:49 pm

Re: Menu Screens, Animation and Platforming

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

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot] and 1 guest