[Solved] Tiled QT and Basic Mapping

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
Ekamu
Party member
Posts: 178
Joined: Fri Sep 20, 2013 11:06 am

[Solved] Tiled QT and Basic Mapping

Post by Ekamu »

I want to make a very basic map engine in Love 2d so I can have a player character move around in a 2d map (in 4 directions: north, east, west, south) with basic collision detection.
Love 2d has a physics engine, and I think this should not be hard, so how do I get started? Any tutorials I could look up? I'm used to using an IDE so I have no idea how to make this work plus I have no experience with tiled qt.

I'm making a simple arcade game but I need some basic orthogonal 2d maps with collision detection.
Last edited by Ekamu on Mon Sep 30, 2013 9:17 pm, edited 1 time in total.
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: Tiled QT and Basic Mapping

Post by Plu »

If you're going to use a tile based map, the physics engine is not the way to go. You should roll your own collision detection system

(which is quite simple to build really, as long as you know what tile something is in and what tile something wants to move to, resolving the collision should be a piece of cake.)
Ekamu
Party member
Posts: 178
Joined: Fri Sep 20, 2013 11:06 am

Re: Tiled QT and Basic Mapping

Post by Ekamu »

O.K
Lets break this down first...

I would need to display the character sprite on the screen.
I would also need to display the map on the screen at the same time.
I need the character to be above the map, but some things are over the character to create the othogonal illusion.

Therefore I need layers and some kind of buffer to load the character sprite and animation.

I would need the player-character to move
I would also need the camera to follow the player-character while moving and fix itself over the player at all times
I need the player-character to move strictly within a fixed grid-base (tile)

Therefore I need a grid-system that will tell me where the player is and if they are at the next grid.

I would need the player to stop moving if there is an obstruction in their way
I would need this obstruction to have a fixed position on the map at all times
I need this collision to occur immediately and NOT so the player moves to that tile but stops immediately.

Therefore I need some basic trig-formula (pythagorus) to check the position of the player and the obstruction as well as the distance to avoid the player moving first then getting stuck.

I think that covers it...

But where do I start, what love functions do I use, how do I load tiled qt maps into the love2d engine, how can I use an animated sprite. There is so much detail that I have absolutely no idea on how to start. I just have it all in mind and know some basic Lua.
User avatar
Plu
Inner party member
Posts: 722
Joined: Fri Mar 15, 2013 9:36 pm

Re: Tiled QT and Basic Mapping

Post by Plu »

You have the right approach :) Keep breaking it down into smaller steps until you reach the point where you understand how to program them.

If you're still very inexperienced, I would suggest ignoring the camera stuff for now and starting with making a grid with some objects on it.

Making it orthogonal is actually easier than you think. In order to make an ortho-map, draw the tiles from the top of the screen towards the bottom. Make sure each tile (you'll need a table for them) has a draw function. Call them all, starting at the top left, working to top, right, then the next line. Each tile will draw over whatever the previous tile has drawn, which means that tiles in the front automatically draw over tiles in the back.

You would have to handle movement by using keypress, determining whether the player can move in that direction, and then resolving a loop where they move in that direction. They cannot control the character while it moves, because then they'd be able to leave the grid.

Ideally, store a lot of relevant information in the tile. If a tile knows whether or not the player can stand on it, calculating whether or not the player can move is a breeze; take the current tile, grab from your list of tiles the next tile (which is easy to calculate; it's the one at either x+1, x-1, y+1 or y-1 depending on the button pressed) and then ask that tile if it is passable. Then you can start the movement loop, and once the player arrives, you allow user input again and start using the same proces to see whether his next move is valid.
User avatar
micha
Inner party member
Posts: 1083
Joined: Wed Sep 26, 2012 5:13 pm

Re: Tiled QT and Basic Mapping

Post by micha »

From a pedagogic standpoint I agree with plu. It is a good exercise to code all these things.

But there also exist libraries, that can do the job for you. For drawing maps, have a look at Advanced tiled loader. This library offers you the functionality to load maps that you made with the Tiled map editor.

For the camera stuff, I found this tutorial helpful: Cameras in LÖVE.

You are definitely on the right track. I suggest you take all the steps you wrote down here and put them into a lua-file as comments. Then start filling the gaps one by one.
Ekamu
Party member
Posts: 178
Joined: Fri Sep 20, 2013 11:06 am

Re: Tiled QT and Basic Mapping

Post by Ekamu »

thanks guys, I'll keep breaking it down until I know exactly what to code.
For now I'm going to use the library until later when I have a bit more experience.
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], keharriso and 63 guests