Chess frustration.

This forum is currently in read-only mode.
From the Asset Store
Beautiful Black & White Chess Pieces for Chess Game.
  • I am working on a chess game. Since I still can't do much, I'm not even trying to incorperate an ai. But I would like the game to show you where you can move your pices and where you can't, otherwise it would just be a click and drag visualization of a chess board. To do this I need it to reconize a grid. So far the only grid feature I've been able to find is the one in the layout that helps you position things. As far as I can tell, there is no way to reference to it in the events.

    If you don't want to read my possible solutions skip down to "What I'm getting to..."

    My idea that I think will work is very tedios. It would consist of lableing each square a1, a2, a3, etc. And using a position -> possible moves statement for each. Like, if blackpawn1 is overlaping b1 -> highlight c1, d1 and allow movement to them (I know I'm not speaking in event speach) or here's a whoper if white queen is on h4 and g5 is open -> highlight g5, f6, e7, d8. This can be done, but each sqare would need an event for each character (64 x 32). And then each sqare would need a seperate event for an instance when one of the spaces a character can move to is blocked (x number of squares a piece may move at maximum from a givien square). This means that any given square will have at least 2305 events. (2304 + 1 [1 is the minimum variations for the pawn]) I'm not sure its worth hand writing all those events for each square.

    My second idea is to try and track the positions through private variables. This would include labling the board 11, 12, 13, etc (first digit being row, second digit columb) and then defining the character's position. Then telling the game that a pawn can only move in increments of 10 (up one row or down one row) But then for pices like the rook I don't know how to make it move side to side. Telling it it can move infanantly in increments of 1 would give it free roam of the board (and off the board) Even if I could figure out how to set a maximum number to a variable while keeping it locked in its increment. I know I can do Variable x = higher than max => lower by x. But x would be a different number for each piece, and for each edge sqare (32 x 32 = 1024 events just telling how to stay on board)

    What I'm getting to is how can I say x piece moves x spaces in x directions without going off?

    In less than 1000 events =P

  • Take a look at this

    For the chess board, I made a 8x8 grid of boxes, each with a private variable called "Position." Each one labeled a1 through h8 (I hope I did that right) So this way, if you want to move a piece to a certain position, just move it to the box with the private variable matching that position.

    Another thing that might be useful that I also used in that cap is the Grid Movement behavior. You set the size of a 'tile' and in an event you can tell it to move 1 tile up or down or whichever and it will move the same distance each time.

    Hopefully that will help answer some of your questions.

  • Thank you very much eviltoaster. I love the help I can get on this forum. I still have a few unsloved questions (knites for example) but I'm going to try my best at it.

  • Heya, I know its 2:30 in the morning, but I'm kinda exited about what I came up with.

    First off, I think chess is a bit too complicated as of now, but I am working on a checkers. I have spent quite a while on this, but its a long way from finished. Currently, only the far left, top checker moves, but when you click on it it shows you where it can go. You click where you want it to go, and it teleports there . I am going to fix this, posibly by:

    .On left click on PosibleRight (object)| =>> system: set global variable 'MoveRight' to 1


    .MoveRight (variable) =1|=>> Move bPawn -45

    .ActivePawn (variable) =1|

    .Every 200 miliseconds |


    .On Colision with StopBox|==> Set global variable 'MoveRight' to 0

    . | Destroy SelectBox

    . | Destroy PosibleLeft

    . | Destroy PosibleRight


    I'm not going to add all this tonight, because that would mean giving every piece thier own little collision dot and every PossibleLeft and PosibleRight thier own too. It would aso mean getting rid of some of what I have, and setting up a way to delete the collision dot when it's not on the board. It would also mean I'd have to aim everything just right, and have a correct overlap. By now its 2:45. I'm posting the cap so you can see my measily effort and going to bed. The Cap

  • Komdour,

    I wish you good luck! I like both chess and checkers, so waiting for your game release.

    P.S. - extremely small chess and checkers game in one shell. Will you beat that?

  • I can have a go at it. I'm developing one other game to (also in way early stages). I can't promise eather will be too good, but I would like to try and make use of what construct has to offer. Remember, I'm going throught that painstaking stage of not knowing enough and haveing to experement for 20 minutes to figure anything out. Times that for every proces and things could take a while.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • I'm sorry.

    Every time I read the title of this thread, I can't stop thinking of this -->

    About the board, my first idea would have been using the array object, with 0 meaning empty and using a number for each piece. Then you can represent their movements by displacements, with the rook requiring that dx=dy, knight dx=1,dy=2 or dy=1,dx=2..... you get the idea.

  • I know this is a very old thread, but I think I found a somewhat simpler solution to chess movement. Maybe it's not very programmer-like, but as a designer I was looking for a more practicable solution. So what I basically do is create a collider, that marks the fields where the figure can go. Each time the figure is selected, I make that collider visible and simply check the checker-fields that lay below if they overlap the collider. then I know where the figure can move and when a checker is clicked, I can position the figure on the center of that checker (which is a replacement of a grid-like movement basically)

    hope it helps

    atm that works well, maybe there's still a downside to come... maybe AI?

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)