Before you run away, so I can stare at this when I finish my work, is it row-major or column major? Do you intend it to go down and then across, or across and then down?
The list starts at the top left dark corner (square 2 color) and goes right 4, then down 1, then right 4, etc. I figured I'd have it follow the list, which would make it easier to deal with. Like I said, I still have to get the checkers lined up to the board squares yet, it's way off. :/ That code will at least generate some of the checkers to get a base.


tifreak8x wrote:
So, I was thinking about being able to move the cursor. Should I use the number pad to make it go diagonal, or should I just use the main arrows so it only goes 4 directions?

Years ago, I purchased two handheld electronic checkers games: "Excalibur LCD Chess & Checkers" and "Radica Pocket Checkers". (Okay, so I like checkers. Smile )

The interface on the Excalibur device had diaganols, but you used all 8 arrows to select the piece, then pressed the "move" button, then used the diagonal arrows again to indicate the direction of the move. On the Radica game, you used the left/right/up/down arrows to select the piece and the diagonal arrows to indicate the move.

The Excalibur interface made sense for chess where pieces can move in any direction, but for checkers it was kind of clunky. I found that having to switch between "select mode" and "move mode" was cumbersome (kind of like the mode switching in the unix vi text editor).

The Radica interface was more natural for checkers since the pieces can only move in diagonal directions. The Radica game played lousy, but the interface sure was nice.

So I'd say use the number pad using 2,4,6,8 to move from piece to piece and 1,3,7,9 to indicate direction of move.

(Then again, you might not want to trust me---I thought the light grey checker board on the right was the best. The one in the middle made my eyes hurt.)

-wes
Well, the cursor isn't going to be able to move onto squares you can't put a piece on anyways. I think I'll probably be going with the numpad because it will make more sense. With just the arrows, you'd have to move over to the column, and it could take you either up or down, before you could go towards the spot you want. I dunno, I'm going to keep thinking on it. Need to make it so I can put the checkers on the board, before anything..
So, I've come to 2 conclusions for populating the checkers.

1. I have the For( loops backwards, since I want it to generate across the top first and go down by rows, and it's going down by columns.

2. I need to wrap the loop that draws the checkers themselves in a conditional, or add +U(L1(G)=0) to the color part of the Line( commands.

Edit:

After giving some thought, I'm just going to wrap it in the conditional for speed reasons. No sense in having it redraw the color of the squares when it can just ignore drawing all together, right? I hope to have these changes in place later this afternoon.


So, after thinking a lot about it, I decided to start over with this. I generated a single checker in the top left, and bottom left, to get myself some values to base things on. THEN I wrote out the For( loops.

Should have done this from the beginning, was dumb to think I could simply modify code from Connect4 to immediately work in this.

But, it now drops them checkers on the board exactly where they should be. Thoughts?

Edit:

I've also added the ability to change cursor colors. It displays the cursor box over the Square 2 item, so you can more easily compare how things are going to look Smile

I'll post some more screenshots once I get it to where it shows up on the board and is movable.
tifreak8x wrote:
But, it now drops them checkers on the board exactly where they should be. Thoughts?
I think that's exactly as it should be. I wouldn't really expect any sort of piece-placement animation, if that's what you mean. At any rate, good work. I still think you're making life harder for yourself by not using a matrix, especially for this game, but you seem to have the list manipulation well in hand.
Yeah, usage of the lists aren't hard for this.

My next bit is to figure out how I want the cursor to move. Debating if I should have it be able to move around on the red squares as well, or just the dark ones. Will try to make it just the dark ones for now, see how well that works.


So, here I show on the left, you can change the color of the cursor. I haven't taken the time yet to fix it so the background of the cursor also updates when you update the other. I might mess with that later.

The right side shows the cursor moving around on the board. Smile

What do you think?

I'm going to have to figure out how to check to see what square it is on, and make sure it only moves to the dark (square 2) squares. I haven't yet started working on those equations, so I'll get started on that shortly Smile
As I told you over SMS, looks great! I like the ability to change the cursor color to something that suits your fancy (and looks good against the squares chosen).
By the way shouldn't the TI-Freakware text always be black and green like the site? Razz
@Kerm: Thanks! I'm trying to make it as attractive to gamers as possible :) And of course, trying my best to really use them colors to the best of my abilities.

@DJ: To be honest, I did consider that, but I figured it would clash horridly with what checker colors are supposed to be, so I went with this. I've thought about making it bounce between the square colors that a user chooses. Something I might look into later.

So, I need some help.



Take the above screenshot. The dark areas are the playable ones, and this is where the list is used. The top-left grey box is L1(1), and goes right to L1(4). It then returns left and goes to the next one down, and goes from L1(5)-L1(8), etc.

I'm currently running into an issue on determining the position of the cursor to correlate with the list element. This wasn't a problem before, because there were no non-playable spots in connect 4.

The top row is A=148, and the lowest is 8, and it moves in increments of 20. The most left column is 5, and the far right is 138, moving in increments of 19. Any time the cursor is on a grey square, I=1.

I can easily adjust the list to be mirrored, and have L1(1) be the far right, bottom dark square.

I can easily get the row/column with the following:

((A-8)/20)+1 = row#

(B+14)/19 = column #

I just can't see any pattern or correlation that would allow me to use this set up.. Unless I use the fact that they are either on odd or even columns.. That might allow me to make that work..

Anyways, here is what my code looks like so far:


Code:
ClrDraw:AxesOff
GridOff
SetUpEditor L3
SetUpEditor L1
32->dim(L1
{1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,2,2,2,2,2,2,2,2,2,2,2,2->L1
{2,4,5,6,6,7,7,7->L3
BackgroundOff
0->Xmin:0->Ymin:1->I
264->Xmax:164->Ymax
11->S:23->T:11->U:12->V:20->R
1->W:7->A:1->C
TextColor(Red
Text(7,15,"Square 1:  "
Text(27,15,"Square 2:  "
Text(47,15,"Player 1:  "
Text(67,15,"Player 2:  "
Text(87,15,"Cursor      :  "
Text(150,1,"2nd to proceed
While W=1
For(G,2,18,2
Line(88,140+G,106,140+G,1,S,2
End
For(G,2,18,2
Line(88,120+G,106,120+G,1,T,2
End
For(F,1,8
L3(F
Line(97-Ans,102+F,97+Ans,102+F,1,U,2
Line(97-Ans,16-F+102,97+Ans,16-F+102,1,U,2
End
For(F,1,8
L3(F
Line(97-Ans,82+F,97+Ans,82+F,1,V,2
Line(97-Ans,16-F+82,97+Ans,16-F+82,1,V,2
End
For(G,2,18,2
Line(88,62+G,106,62+G,1,T,2
End
Line(90,65,104,65,1,R,1
Line(90,65,90,78,1,R,1
Line(104,65,104,78,1,R,1
Line(90,78,104,78,1,R,1
2->W:While W=2
getKey->K
Text(A,1,"|>
If K:Text(A,1,"   
A-20((A>7 and K=25)-(A<87 and K=34->A
If K=24 or K=26:Then
If A=7:Then
S-1((S>10 and K=24)-(S<24 and K=26->S
For(G,2,18,2
Line(88,140+G,88+18,140+G,1,S,2
End:End
If A=27:Then
T-1((T>10 and K=24)-(T<24 and K=26->T
For(G,2,18,2
Line(88,120+G,88+18,120+G,1,T,2
End:End
If A=47:Then
U-1((U>10 and K=24)-(U<24 and K=26->U
For(F,1,8
L3(F
Line(97-Ans,102+F,97+Ans,102+F,1,U,2
Line(97-Ans,16-F+102,97+Ans,16-F+102,1,U,2
End:End
If A=67:Then
V-1((V>10 and K=24)-(V<24 and K=26->V
For(F,1,8
L3(F
Line(97-Ans,82+F,97+Ans,82+F,1,V,2
Line(97-Ans,16-F+82,97+Ans,16-F+82,1,V,2
End:End
If A=87:Then
R-1((R>10 and K=24)-(R<24 and K=26->R
For(G,2,18,2
Line(88,62+G,106,62+G,1,T,2
End
Line(90,65,104,65,1,R,1
Line(90,65,90,78,1,R,1
Line(104,65,104,78,1,R,1
Line(90,78,104,78,1,R,1
End
End
If K=21:Then
If U!=T and V!=T and U!=V and R!=T:3->W
If U=T or V=T or U=V or R=T:Then
TextColor(randInt(10,24
Text(110,1,"CHECKERS/CURSOR CANNOT BE THE SAME
Text(123,1,"AS SQUARE 2 OR EACHOTHER!
TextColor(11
End:End
End:End
ClrDraw
For(F,4,156,19
Line(7,F,167,F,1,12,1
End
For(F,7,167,20
Line(F,4,F,156,1,12,1
End
For(H,8,166,20
not(I->I
For(F,4,138,19
not(I->I
For(G,2,18,2
Line(H,F+G,H+18,F+G,1,S(I=0)+TI,2
End:End:End
5->theta
For(F,1,8
not(I->I
TextColor(11+I
Text(~1,theta,175,sub("CHECKERS",F,1
theta+20->theta
End
2->theta
Text(~1,75,205,"BY:
For(F,1,12
not(I->I
TextColor(11+I
Text(theta,254,sub("TI-FREAKWARE",F,1
theta+13->theta
End
1->I:1->G
For(H,13,146,19
not(I->I
For(J,17,157,40
If L1(G)>0:Then
For(F,1,8
L3(F
Line(J-Ans+20I,(H-7)+F,J+Ans+20I,(H-7)+F,1,U(L1(G)=1)+V(L1(G)=2),2
Line(J-Ans+20I,16-F+(H-7),J+Ans+20I,16-F+(H-7),1,U(L1(G)=1)+V(L1(G)=2),2
End:End
G+1->G
End:End

48->A:43->B:1->I
While W=3
Line(A,B,A+18,B,1,R,1
Line(A,B,A,B+17,1,R,1
Line(A+18,B,A+18,B+17,1,R,1
Line(A,B+17,A+18,B+17,1,R,1
getKey->K
If K:Then
Line(A,B,A+18,B,1,T(I=1)+S(I=0),1
Line(A,B,A,B+17,1,T(I=1)+S(I=0),1
Line(A+18,B,A+18,B+17,1,T(I=1)+S(I=0),1
Line(A,B+17,A+18,B+17,1,T(I=1)+S(I=0),1
End
B-19((K=34 and B>5)-(K=25 and B<138->B
A-20((K=24 and A>8)-(K=26 and A<148->A

If max(K={24,25,26,34:not(I->I
If K=22:Return

If K=21:Then
If I=1:Then
Line(A+1,B+3,A+3,B+1,1,R,1
Line(A+1,B+14,A+3,B+16,1,R,1
Line(A+17,B+3,A+15,B+1,1,R,1
Line(A+17,B+14,A+15,B+16,1,R,1
End:End


End


The code there with the K=21 bit is going to set a 'marker' on the selected checker. Nothing else has been done with selection and moving, as of yet.


Edit:

I had some inspiration on fixing this, going to give it a try once I'm home this evening.

Edit 2:

Updated the code, now L1(1) is the bottom left square, moving right and up progressively. Still working on a solution for getting the proper list element.

And huh, I just figured out how to partially do it.

(((B+14)/19)+1)/2

This gives me the proper rows when dealing with the odd # squares. Now to do some form of checking to make sure it's already on an even #'ed square and ignore the +1.. hrm..


Edit 3:

(((((A-8)/20)+1)*4)-4)+(((B+14)/19)+1(fPart(((B+14)/19)/2)=.5))/2

That's what I've come up with to give me a proper list element. Holy crap. lol Glad I got that figured out.


This is just something I worked up to show how you will know when a checker is selected. I haven't implemented anything beyond that point, hence why you can select multiple. And you'll see me stop over a red square and the cursor flicker a couple of times. That's me hitting 2nd to try to put the marker there, and it refuses, like it should. Smile


I'll probably use a variable to determine what player has their turn, a variable to tell whether a checker has been selected already, and I'll use a list to hold the coordinates of the stored checker, and after the checker is moved, it will be used to remember the last move made by that player. Then I also need to make it so you can cancel the selection.

After I get that implemented, I have to make it work moving rules and such. Smile

Thoughts?
That all sounds reasonable enough: selecting a checker (only of your color) then moving to a legal square and instructing the game to move the checker there. And then moving it, and flipping all of the checkers along the way. Do you still need help with the code in the preceding post?
Nope! I did manage to get that. That's what that super long line of equation is at the end of the post.

Also, thoughts on the indicator that a checker is selected? Is it noticeable enough?
tifreak8x wrote:
Nope! I did manage to get that. That's what that super long line of equation is at the end of the post.

Also, thoughts on the indicator that a checker is selected? Is it noticeable enough?
At least from the screenshot, it doesn't look bold enough at all. Perhaps a thicker square around the piece? Also, are you going to let users cancel the selection and switch their decision, necessitating erasing that selection?
Yes I will. I think I'm going to use Alpha for that, so you don't have to scroll back over to the checker and press 2nd again.

And I had it set for having 2 lines drawn, but it looked bad and bulky, and it wasn't drawing them uniformly. :<
tifreak8x wrote:
Yes I will. I think I'm going to use Alpha for that, so you don't have to scroll back over to the checker and press 2nd again.

It seems like you don't really need select/unselect keys at all. If you use 2,4,6,8 keys to select a piece and 1,3,7,9 to move, then whatever checker you're on is the one to move. In other words, a diagonal key could select and move.

Also, instead having the selector move from square to square (legal/illegal, occupied/unoccupied), you could have it move from legal checker to legal checker. Then you wouldn't have to worry about an illegal selection.

-wes
I'm using the directional keys to move the cursor, which means I need to utilize the upper left hand keys for selection and otherwise. Using the number keys would have seriously bloated the game engine with all the additional checks and conditionals.

Once you select a checker, you use the same button to place it on an empty square, that's all the real checking I have to do for that.


Hooray! I figured out my issue! Now I have new issues! Hooray!

Also, in the interest of testing, I inserted a StorePic command after the board was drawn, and recalled that, dumped the movement code into a separate program to develop that. Now to figure out why it dumps the checker and the selection box where it does.
  
Register to Join the Conversation
Have your own thoughts to add to this or any other topic? Want to ask a question, offer a suggestion, share your own programs and projects, upload a file to the file archives, get help with calculator and computer programming, or simply chat with like-minded coders and tech and calculator enthusiasts via the site-wide AJAX SAX widget? Registration for a free Cemetech account only takes a minute.

» Go to Registration page
Page 3 of 5
» All times are UTC - 5 Hours
 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum

 

Advertisement