# Chess help

Get help using Construct 2

### » Mon Feb 18, 2013 12:10 am

So im programming a two player Chess game as my first Construct 2 game as practice, and im wondering this:

So if I select a Rook on, say, e4, I want the squares e5, e6, e7, e8, d4, c4, b4, a4, e3, e2, e1, f4, g4, and h4 to light up. I already have objects with selection animations on each of the squares for tiles, but how in the world would I program this for every piece's specific movements on every spot on the board? Is there some way to group the logic into a single algorithm applied to the given piece?
B
5
Posts: 29
Reputation: 383

Anyone?
B
5
Posts: 29
Reputation: 383

... No one?
B
5
Posts: 29
Reputation: 383

### » Mon Feb 18, 2013 6:05 pm

Yes, there is way. But to help you, it's important to know how you handle your game logic.
B
45
S
15
G
14
Posts: 825
Reputation: 11,528

### » Mon Feb 18, 2013 8:14 pm

What do you mean?
B
5
Posts: 29
Reputation: 383

### » Mon Feb 18, 2013 8:59 pm

How do you represent your game state for instance. Do you use an array ?

B
45
S
15
G
14
Posts: 825
Reputation: 11,528

### » Mon Feb 18, 2013 11:35 pm

Yeah I have an 8x8x2 Array for the board... It's all very confusing...

Half the array stores whether the square is blank, has white piece, or has black piece. The other half has a value 3-35, where 3 is an empty square and 4-35 are individual pieces.

I'm extremely inexperienced. Is this the correct way to do it? And if I use an array, how do I do my original question?
B
5
Posts: 29
Reputation: 383

### » Tue Feb 19, 2013 1:39 am

You could do the same with a 8x8 2D array, and a wider range of values for the different pieces. I wonder, why the 4-35 range for your pieces ? You could also store piece values as strings, like "BK" for "black king" or "WQ" for "white queen". Doesn't change anything but makes your events easier to read ! ;)

Basically, you'll have to create one set of event for each different kind of piece. You could do it with a function that receive 3 parameters : xPos, yPos and pieceType. Depending on the pieceType and the positions, you highlight the tiles that can be moved on.

How familiar are you with functions and array manipulation ?Magistross2013-02-19 01:39:43
B
45
S
15
G
14
Posts: 825
Reputation: 11,528

### » Tue Feb 19, 2013 2:02 am

I WANT to say I'm familiar... but... no haha...

If you don't want to explain what is necessary, is there something in the manual/a tutorial that explains it? I don't want to waste your time.
B
5
Posts: 29
Reputation: 383

### » Tue Feb 19, 2013 2:15 am

Look at the plugin's forum and look at @rexrainbow's plugin for doing Chess type logic: Plugin Board, Layout2Board Behavior Grid Move
B
49
S
11
G
10
Posts: 1,833
Reputation: 14,393

Next

### Who is online

Users browsing this forum: Colorfish, Yahoo [Bot] and 22 guests