Skip to main content
Associate II
March 19, 2024
Solved

Drawing a circle in a chess board

  • March 19, 2024
  • 2 replies
  • 1417 views

Hi!

I want to ask a question about designing a chess game such as Gomoku using TouchGFX. As far as I know, I need to put two chesses in every single spot and set them as invisible. When user clicks, then set them to visible. However, this is a very tedious implmentation when board size is really large.

I am wondering if there's another way to directly draw a new circle in the ClickHandler callback function? 

Thanks so much for your support!

This topic has been closed for replies.
Best answer by LouisB

Hello @ZZY ,

This implementation with setting visible and invisibles chess pieces is the simplest one, you can use a single pawn per spot and change it to black or white :

 

imageName.setBitmap(Bitmap(BITMAP_MYIMAGE_ID));

 

 

If you don't want to put a pawn per position, you can use a ClickHandler, with only one widget and a snapshot widget.

The snapshot widget is use for taking a snapshot of the frame buffer, so your old pawn is not a widget anymore but a part of the background image


Here is what you can do :

  1. Get the position from your chess board image
  2. move the widget to the new position
  3. take a snapshot
  4. put the snapshot in the background image
  5. reiterate

I hope it helps you,

Regards

2 replies

LouisBBest answer
ST Employee
March 21, 2024

Hello @ZZY ,

This implementation with setting visible and invisibles chess pieces is the simplest one, you can use a single pawn per spot and change it to black or white :

 

imageName.setBitmap(Bitmap(BITMAP_MYIMAGE_ID));

 

 

If you don't want to put a pawn per position, you can use a ClickHandler, with only one widget and a snapshot widget.

The snapshot widget is use for taking a snapshot of the frame buffer, so your old pawn is not a widget anymore but a part of the background image


Here is what you can do :

  1. Get the position from your chess board image
  2. move the widget to the new position
  3. take a snapshot
  4. put the snapshot in the background image
  5. reiterate

I hope it helps you,

Regards

Osman SOYKURT
Technical Moderator
April 26, 2024

Hello @ZZY,

Have you tried the suggestions of @LouisB? Did you solve your issue?

Osman SOYKURTST Software Developer | TouchGFX
ZZYAuthor
Associate II
April 27, 2024

Yes I used that approach and solved it! Thank u

Osman SOYKURT
Technical Moderator
April 29, 2024

Awesome, great to hear!

Osman SOYKURTST Software Developer | TouchGFX