-
Senior Member
[F8] Possible to advance letters similarly to numbers?
This is just a quick question, is it possible to advance letters similarly to numbers? Like if you have a variable holding a number you just need to type varName++ can you do the same thing with letters?
I ask because I'm thinking about making a flash chess game and am thinking about how to go about it. I'm thinking the best way would name all the tiles according to their position (a1-a8, b1-b8, etc) then when a piece is clicked on it would check each tile along that piece's range and if it is open it would highlight that tile.
Would it be practical to code it to pull the substring of whatever variable I am using to check the tiles and advance it accordingly. If that didn't make sence, something like this:
code:
tileToCheck = a2;
//here would be some code to check that tile
tileToCheck = tileToCheck.substring(1,1)++ + tileTocheck.substring(2,1);
I probably dont have the syntax right, but regardless, would that be the best way? Should I store each part of the name separately? Or should I just store the letters as their numeric counterpart (a=1, b=1, etc).
Thanks for any help/advice
-
Total Universe Mod
If I understand your question, each letter has a unicode equivalent but it's clunky and causes some extra drag on the processor. The best way is to just make an array of the alphabet and look up their member values.
abc = ['a','b','c',...'z'];
-
Senior Member
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|