SFML community forums

Help => General => Topic started by: Astamor on February 14, 2017, 01:44:18 am

Title: Dividing 2d map into units ?
Post by: Astamor on February 14, 2017, 01:44:18 am
Not sure if I can explain it clearly but let's try.

I would like to slice my map(image) into squares. Let's say entire map is 320x320px and one square is supposed to be 32x32. So it would be 10x10 units. Character can only move from one unit to another. It's exactly like in Tibia. Your character can't move freely. When "transfering" character from one square to another, walking animation is played .I'm not asking for code, I'd love to know how to approach this problem.
Title: Re: Dividing 2d map into units ?
Post by: eXpl0it3r on February 14, 2017, 10:45:51 am
Don't post in the C binding forum when you're not talking about the C binding. ;)

The most common approach is to use a tilemap like the one shown in the official tutorial (http://www.sfml-dev.org/tutorials/2.4/graphics-vertex-array.php#example-tile-map) and then you just calculate the grid position for the character.

And to approach the problem, you just have to start. Make your player move. Make the tilemap draw. Then combine the two.
Title: Re: Dividing 2d map into units ?
Post by: Astamor on February 14, 2017, 02:45:28 pm
I've already made my player move, I've animated it, the player class is ready :) But thanks.