Hi all! - Various questions on Love2d

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.
User avatar
Lacotemale
Citizen
Posts: 75
Joined: Sat Mar 08, 2014 9:01 pm

Hi all! - Various questions on Love2d

Post by Lacotemale »

Hey everyone,

I have made a few games which got to partial completion in a piece of software called Game Editor. Lots of stuff was done through the GUI but the rest was C programming. Although I made some great progress the development of the Game Editor tool has run pretty dry and im looking for an alternative, something more programming orientated. Seems like Love2d might be the solution. However, this will involve lots of learning if I am to port over my games.

I am a developer and know many languages but unfortunately Lua is not one of them. Already I started working on something and loading graphics was quite easy, same for mouse clicks but I kinda hit a wall after that. Im not sure where to go from here. The API docs are really great but don't describe how to do certain things.

1. In GameEditor you can create an Actor/Object. Is this done with creating a lua class?

2. I used to setup collisions through the GameEditor GUI. How does Love2d manage collisions? For example I used to add these through a GUI and add a physicalresponse of value 0 on the ground when the player collides.

3. I can register a mouse click but how do I register a mouse click on a particular object/actor? (then do an action)

4. In GameEditor I could have run1.png, run2.png, run3.png and it would load it as an image sequence. Is this possible with Love2d?

5. Android and IOS support? Does Love2d support these platforms?

This may be difficult for me to move across as I realize how easy the GUI in GameEditor made certain things for me. x)
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Hi all! - Various questions on Love2d

Post by micha »

Hi and welcome to the forum.

1. In Lua there is not the one class. Actually there are several possible ways to get a class-like behavior. Neither LÖVE nor Lua prescribe any specific usage. So I suggest, you read a little bit about Lua and then implement objects the way you like most. Sometimes it is enough to just have a table with object coordinates, sometimes you need class-methods, then you have to dig a little deeper into Lua.

2. For a built-in collision detection you can use the love.physics-module. But if you need very simple physics only, then better implement one by yourself.

3. You have to keep track of all clickable objects yourself. Then, when a click occurs, you have to check of the clickable areas one after another.

4. You can implement this easiest using a spriteBatch.

5. It does not support these platforms officially yet. Check out the "Ports"-Forum. Some people made inofficial ports to these platforms. Maybe they become official some day.
User avatar
Lacotemale
Citizen
Posts: 75
Joined: Sat Mar 08, 2014 9:01 pm

Re: Hi all! - Various questions on Love2d

Post by Lacotemale »

Thanks Micha! Much appreciated!

Yeah I will need to do some reading on Lua I think. So far it just looks completely alien to me, very different to other languages.

I guess I will start from the beginning. Trying to port one of my smallest projects:

My progress thus far: http://www.photofiltre-lx.org/blog/2014/71.html

Graphics loading is nice and easy. I guess the next thing is setting clickable areas, how do I do this? :?
davisdude
Party member
Posts: 1154
Joined: Sun Apr 28, 2013 3:29 am
Location: North Carolina

Re: Hi all! - Various questions on Love2d

Post by davisdude »

Lua is a very simple language to learn, but can also be very powerful, and just has some getting used to. This may help find some of the major discrepancies between most languages.

As for your questions, Micha pretty much nailed it on the head:
1. Class support is not official in Lua, but can be implemented. I have an example here if you would like to take a look. Lua is more of a "do it yourself" kind of language, if you know what I mean. It gives you the tools, and you make it however you like.

2. love.physics works, or you can use one of many libraries. But with all of these libraries (aside from love.physics) you need to handle your own collision resolution.

3. Through collision detection and keeping track of the dimensions of all of the items registered you can check if it is clicked.

The rest of the answers are rather verbatim, so I wont go over those. Welcome! :D
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
Lacotemale
Citizen
Posts: 75
Joined: Sat Mar 08, 2014 9:01 pm

Re: Hi all! - Various questions on Love2d

Post by Lacotemale »

Starting loops from 1 instead of 0, what is this lua madness?! xD

Anyway I actually got some coding done using classes today and I was surprised at how easy it was. :awesome:

I will checkout physics and collision stuff later. My current game will not involve any of that. Although I am now reporting mouse clicked coords, so it shouldn't be too difficult from there I reckon. Maybe will just do lots of if else statements.
User avatar
Lacotemale
Citizen
Posts: 75
Joined: Sat Mar 08, 2014 9:01 pm

Re: Hi all! - Various questions on Love2d

Post by Lacotemale »

Hi guys,

Although I was busy working on my card game and made decent progress with it I want to start porting some of my other projects to Love2D to continue my learning experience.

I've started with the RPG game. I have a basic implementation of STI working and now its coming to the character movement. While I have the spritesheet moving on the STI map, this isn't all that great. I have a few questions.

1. Should I also be using Spritebatch for the map as well as the player spritesheet?

2. Should I still use STI for the map and use Spritebatch for the player spritesheet?

3. How do collision maps work in STI?

Lastly, how do I use Spritebatch if it is required? Just a basic press a button and have the required walking animation run is all I need.
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Hi all! - Various questions on Love2d

Post by micha »

I think the answer I gave you in this thread above is a bit misleading (or even wrong). You were asking how to implement animation. Basically you have a number of images and want to show them one after the other. Spritebatch is not the answer here. Sorry for confusion. Instead have a look at animation libraries. The two I know are anim8 and AnAL.

I suggest you use one of these libraries for drawing animations. For drawing the map, you can stick to STI. I think internally it uses a spritebatch, but you don't have to care for this. Just use it.

And STI does not handle collision for you. You can either use a collision library for that or you can implement your own collision detection. That depends on what you want to achieve.
User avatar
Lacotemale
Citizen
Posts: 75
Joined: Sat Mar 08, 2014 9:01 pm

Re: Hi all! - Various questions on Love2d

Post by Lacotemale »

Apologies for creating confusion. For my RPG I used spritesheets but for my 3rd person shooter I used multiple images.

STI has collision maps or something does it not? Is this just for setting the places blocked via collision or what?
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Hi all! - Various questions on Love2d

Post by micha »

A collision map is an array that tells you for every block if it is a wall or empty space. That means it contains the bare information that you need to do collision detection. But it does not contain the functionality to detect or resolve collisions.
User avatar
Lacotemale
Citizen
Posts: 75
Joined: Sat Mar 08, 2014 9:01 pm

Re: Hi all! - Various questions on Love2d

Post by Lacotemale »

A collision map is an array that tells you for every block if it is a wall or empty space.
Ah right, like 1 or 0 I suppose.

So between those two Libs, which should I use?

or a better question which is easier for a beginner? :ultrahappy:
Post Reply

Who is online

Users browsing this forum: Bing [Bot], dusoft and 44 guests