cancel
Showing results for 
Search instead for 
Did you mean: 

Drawing a circle in a chess board

ZZY
Associate II

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!

1 ACCEPTED SOLUTION

Accepted Solutions
LouisB
ST Employee

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

Louis BOUDO
ST Software Developer | TouchGFX

View solution in original post

4 REPLIES 4
LouisB
ST Employee

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

Louis BOUDO
ST Software Developer | TouchGFX
Osman SOYKURT
ST Employee

Hello @ZZY,

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

Osman SOYKURT
ST Software Developer | TouchGFX

Yes I used that approach and solved it! Thank u

Awesome, great to hear!

Osman SOYKURT
ST Software Developer | TouchGFX