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

Author Topic: SFML implementing grid  (Read 1170 times)

0 Members and 1 Guest are viewing this topic.

woozie

  • Newbie
  • *
  • Posts: 2
    • View Profile
SFML implementing grid
« on: July 05, 2019, 09:16:31 pm »
Hello,

I'm trying to make a replica of a classic board game. I have created a background image and I'm trying to find specific points of that background image(the black dots). I know how to do that in Unity but I'm trying to make it work here. I'm thinking that probably isn't the best approach though. In other words if anyone has any other suggestions, feel free to correct me. I need to find the black dots and I need to create a mouse input where on release the yellow sprite would snap onto the black dots of the background image. I'm not sure if having a background image is the best way to do it (I'm thinking that drawing the entire background in SFML would probably be easier?). I don't need a full solution, just some help on the logic and what I should use.

TLDR; How would I accomplish that the yellow dot snaps onto different black dots with mouse release

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: SFML implementing grid
« Reply #1 on: July 05, 2019, 10:13:59 pm »
Have a list with all the coordinates of the black dots, and compute the length between the mouse and all black dots coordinates to find the closest one.
Whether you have it displayed as a single background image or draw it with SFML functions is not relevant, you need the coordinates either way.  :)

woozie

  • Newbie
  • *
  • Posts: 2
    • View Profile
Re: SFML implementing grid
« Reply #2 on: July 05, 2019, 11:37:00 pm »
Oh, thank you! One more question. How would i find the coordinates of the black dots if it's an image? What do I need to implement a coordinate system, which functions and module? Thanks, sorry for so much questions.

G.

  • Hero Member
  • *****
  • Posts: 1592
    • View Profile
Re: SFML implementing grid
« Reply #3 on: July 06, 2019, 01:46:04 am »
Oh, since it's your board I was thinking more of inputting the coordinates yourself. :p

 

anything