Building an XNA Game Studio XBox360 Indie Game.

[page 0046] ~ For the Sequester:

Updates – . . .

Adobe Reader X (10.1.8).


This months theme is HEXAGONS.  But, per usual, I’ll be versioning my way through this game because I still have some ideas left over from last months game, ChessPionage.  There were things that I thought might be interesting to incorporate into yet another version of a chess like game such as masking.  Masking is taking one image and using it to make a portion of another image invisible, see through, masked.  With that thought, and with the other images of chess pieces that I had already built, I came up with another way that a chess game could vary in its game play nature.  And so I have set off getting the mechanics for those features ready for use in this months game, Ghost Chess.  As I’ll be using what I have already built for last months game, I’ll need to reference the backups of that game while I move through this months game, mostly for formatting positions of screen objects but also to be able to take into account the logic flow from what it was then to how I would like it to behave now.  In this current game I’ll, OR . . .

Eternity is Fleeting.

I’ll need a timer, of sorts, in this game.  So, of course I’ll start a new project called CountDown.  First off I’ll get a starter project named second() from the Processing.js web site and begin to manipulate that.  Seeing that only the seconds are needed, I’ll comment out the minutes and hours keeping only the seconds.  The seconds come from the system clock and as such provide what the current seconds are that are on the clock of the computer.  This gives me a value between 0 and 59.  But this project is focused on giving me a count down of seconds and to keep it within a mental reach so I can build, test and evaluate the results in real time.  I’ll have it count down or up from 0 to 5 and then restart to do it again.  Simple, but not.  Zero is not always zero unless it is set to zero at the start of the count.  Zero could start at any number from 0 to 59.  When the game/project is initialized it gets the current system clock second() value and it is given to a variable to remain constant, for the time being.  This starting value needs to be converted to zero so a count up increment may ensue.  But, this does become a puzzle because when the count reaches 5, in this case, the starting value which was constant in concern to the count up operation now needs to be updated.  The reasoning behind this is that along with the operational constant, another value of type second() needs to be evaluated against it.  Picking any random number in-between 0 and 59, and then having another number subtracted from it, being of type int second(), does not always yield the intended result.  This thusly produces the second by second fleeting eternity in-between the observable test of each value while the seconds are manipulated by the functions meant to evaluate the processes and return the proper results.  As time moves along, the calculation, because of the difference of the start time and the increment cut off time produce inaccuracies that are not conducive to a testing process that is instantaneously apparent or calculable in real time.  One would think that it would be as simple as subtracting start time from finish time but one would be deluded to believe in such a hope.  If the first value were to be 56 and after counting out 5 increments of type second() the end value would be, I think, 1, if 56 were to be 0, in this case.  And this is where the observable value testing, while this short program is running.  It has proven to be, hmm, somewhat entertaining, I could say, maybe not, but maybe.  More hammer and tongs, printing the values to the screen as they change and capturing what I can, in real time, to get this count up timer to work, properly.

And Yet More Shredding.

I pealed the guts out of that last function I was working on, in its entirety.  It was a bunch of if(sometime > OR < sometime) and + OR – some other time then == to the value of the counter and stuff like that, just a bunch of, this? maybe not, or how about, but if I … and so forth.  Now to start it all over again.  Ok, that was a tidy bit of work and suffering but I’ve got it to count an increment once a second with one boolean, two ints of type second and one int as the counter, simple.  And to top it off I added some graphics to show a line that moves with each increment, kinda like what the original sample had except that for any second the counter will increment one second so any interval can be captured.  Now, the question is, “What is it good for and how will it lend itself to game play?”

The Timer.

Back in Ghost Chess I built a timer that fits on the top edge of the chess board.  It is set so about three minutes and twenty-five seconds from the midpoint to either side will tick off in either direction.  An approximate total of six minutes and fifty seconds is what the full length of the timer allows.  When a piece is selected, the current player will find a small red line moving towards the direction where the captured pieces for that player are located.  I still don’t know what repercussions might occur when an interval of or the edge of the timer is reached.  But its up and running and for now, when the edge of the timer is reached it simply resets itself back to the middle position and continues to tick away.  This game is starting to get thick with code and will soon need to borrow from past builds to get the game play to work correctly and quickly.  As it stands anything goes, the rules are breakable, if you’re looking to follow the rules, that is if you even have the slightest inkling of what the rules might be.  Hmm, once again, stealing from Peter to pay Paul, what can ya’ say.

Moving along.

Grabbing some old code from Trail Blazer, I’ll add DrawSwitchPlayer = false; to the mouse move function so a box will be drawn around the text Black or White at the top of the screen so the player will know that that portion of screen is to be clicked on to move the game along.  Currently I have the code to draw the rectangle in void mouseMoved() but the rectangle flickers because it only calls that function when the mouse is moved, not when it’s stationary in that portion of the screen, ergo the boolean flag which will hold open a draw call and alleviate that problematic flickering.  In simplicity it does the trick.  But life should be so simple.  That takes care of when the mouse is moved over the text Black rectangle portion, so the player knows that clicking there will start the timer for the Black House.  And now for the White House.  Fool that I am.  I thought that if(HouseColor == 0), which is a flag to denote that the Black pieces are to now be in play could be of use, but using that flag does no good because, . . . or . . . nope, I was right.  Its not quite a circular reference but something more like setting a flag inside a flagged block that needs to be set to set itself.  But because the flag is in its own boolean if() block it can’t be referenced, ha, something else will need to be done, stupid logic.  Maybe adding WhiteGoes = true; and BlackGoes = true; might work.  I love this large stack of global variables, no classes with pure linear logic.  It’s not modular, nor built to be reworked easily, just built to work.  All right, I’ve got that to work properly with those booleans and have the rectangles appear and disappear when the area inside those rectangles are hovered over with the mouse pointer.  The next piece will be to activate the player and the accompanying timer mode when that area is highlighted and left clicked in.  HouseColor == 0 OR 1 does work now but it works even when the player hasn’t moved a piece yet.  It works exactly the same as if a player clicked on a piece in the previous game.  That also was the procedure to switch the other players timer and would start the movement of the red line in the other direction.  It has produced some change, but it still has no lockout.  So how or what will need to be set to acknowledge that that player has moved and is now ready to relinquish the turn to the other player whereby the selection buttons for the next players turn will reappear.  HouseColor = 3; might lend itself to do something of this sort, but how and where?  I need the position of the selected piece so that when the board is right clicked on, the previous position can be checked against the position of the piece prior to that which is current.  If they are the same no action is taken, if they are different then HouseColor = 3? and the next players text will come up along with the rectangles and accompanying code to be processed.  Oh yea, Fox in Socks and clocks and blocks.  Looking at all this code makes me want to just start a different game, but this is doable, I think.

Your Turn.

But first a backup save #02, and now back to it.  I’ve dimmed the timer a bit and reworked the interface so it isn’t as obtrusive.  The next bit will have to do with how the timer relates to the current player and how that player switches the turn back to the other player.  As it stands the game starts with an empty board with no tiles showing.  The white and black chess pieces, made from the masked images, are set in place with the black pieces on top and the white on the bottom.  The timer is just above the top of the chess board and above that the text Black <== Start With ==> White is displayed so that either the White House or the Black House can start the game.  I added some flag logic so that at the beginning of the game, when the mouse is moved over either the text Black or White, a rectangle appears around the text denoting a left click will select that House as the starting player.  Clicking on one of either of the buttons will start the red line of the timer moving in the direction of the selected players, for lack of a better word, dungeon.  I’ll call it a dungeon because when a pawn gets to the end row on the other side of the board that piece can be traded in for one of the pieces that had previously been taken, if the Queen has not been taken you can’t get another Queen.  So they’re not dead, they’re in the dungeon.  Once the side is selected another rectangle appears above the dungeon.  This box has the color of the current player and in that box, when a piece is selected to move, the name of that piece is shown therein.  If a piece from the other players side is taken to the dungeon that piece is also shown in the box along with having that piece visible in the dungeon.  I have also added some flags so that only the House whose turn it is is able to select the pieces of that House.  And that is how far this games build has progressed.

Nitpicky, for Good Cause.

I’ve just been running with it for a short time.  There has been a lot of trial and error tests with logic and object formatting on the screen.  And the name of the game has also changed.  What used to be Ghost Chess is now ChesSequester, two words mashed into one title.  With that, I might as well explain just what the desired result will become because of the mechanisms being formulated in the game.  To start, chess is chess, it uses the base template of the named game, the pieces, the board, the movement, the tactics.  Sequester is the additive operation to make the game different it its essence.  But as for the formatting, void mouseMoved() and void mousePressed() take care of the logic that to aligns the rectangles that are being drawn to the mouse hover and click operations that the system reveals to the program.  Those rectangles are designed and drawn from calls at the top of the code page, and yes you guessed it more scrolling to get there and back again.  I miss GOTO function/variable name.  Those are nice speedy jumps from the API dropdown menu item.  So anyway, sequester means Sequester, when found in a Wiktionary link.

More Crash, Boom, Bam.

I’ve been just coding for a bit and I’m up to save #09.  A couple things I have found is that when an argument is passed in a function call where that function data type is an integer and the its source is from a random() function generator it needs to be passed to that variable as an explicitly boxed integer type.  It seems that the random generator, even though given two integers as arguments for the low and high limits, still does not make that returned value an integer.  And so, int RND = (int)random(-1, 8); to get the a random value of [0, 1, 2, 3, 4, 5, 6, 7] is needed or the void function will not pass that value as an argument from the calling function into the function that receives it to be used within that function.  This came to be because an array ARY[RND][0] would hang the program and leave me no idea as to what might be causing the error.  The problem here was that RND, a randomly generated integer, when not explicitly declared and converted became an unacceptable value to denote the position of an element within the array.  But all is well and it works now.  This came to be because of the timeline in Chess Sequester.  As the red tick mark circle combo moves away from the zero mark in the middle of the timeline, either away from zero into the white or black timeline, the perilous nature of sequestration in concern to the chess game is found.

Messy Writing.

The save is up to #14.  I have also read through the above paragraphs and from my point of view can almost barely understand it.  But seeing that I had written it, it kind of makes sense as it presents itself as a huge block comment.  It is more of a convoluted mental pathway of bread crumbs so I’m not completely clueless went I need to reference some reasoning of change within the game.  It’s definitely not Hamlet,  more like Green Eggs and Ham, a tome from me to me in the future as forgetfulness begins to reign supreme.

Almost Done with the Testing.

The last thing to get done is set a red hexagon where the last chess piece was taken.  The tile will have a red hexagon until the next piece is taken because of the sequester timeline.  And that wraps it up.  Now to get it into a web page and then on to One Game A Month.  Psst, next months theme is “CANDY!”


Play the Game Here.

Chess Sequester.

Until then, G’day.


September 30, 2013 - Posted by | 2013 [0019] to [00??], The Process

No comments yet.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s