Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Dividing 2d map into units ?  (Read 1257 times)

0 Members and 1 Guest are viewing this topic.

Astamor

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Dividing 2d map into units ?
« 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.
« Last Edit: February 14, 2017, 01:46:06 am by Astamor »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11032
    • View Profile
    • development blog
    • Email
Re: Dividing 2d map into units ?
« Reply #1 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 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.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Astamor

  • Newbie
  • *
  • Posts: 4
    • View Profile
    • Email
Re: Dividing 2d map into units ?
« Reply #2 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.

 

anything