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

Author Topic: Puzzle Game Grid  (Read 839 times)

0 Members and 1 Guest are viewing this topic.

RaabiTheReaper

  • Newbie
  • *
  • Posts: 1
    • View Profile
Puzzle Game Grid
« on: October 01, 2022, 05:52:34 pm »
Hello,
I am new to SFML and i want to make a normal grid for example like in chess. And i also want to move a player with WASD so he can only move on the rectangles from the grid. I made a top-down game, but he could move in every direction, i want to keep the movement on the single rectangel.
I hope someone can help me with the grid an movement.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10819
    • View Profile
    • development blog
    • Email
Re: Puzzle Game Grid
« Reply #1 on: October 06, 2022, 10:41:54 pm »
Depends a lot on how you wrote the input handling and since you didn't provide any code, I can't really point out how to improve it.

You don't want to apply the input directly to movement, but you want to track the key change and only move a piece, if it's not already moving and the input is actually valid for moving.
Depending on how you want to move between the grid cells, you may need to write some code that moves a piece over some time from cell X to cell Y. This would be a purely mathematical movement and the input wouldn't be calculated into it, once it's moving.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/