i am trying to write a simple program that allows players to start a new game of draughts, store the status of the game and allow players to make moves...can anyone please give me tips on how to get started? I have found some info on the net but it is too complicated to understand.... any help is appreciated - #include <stdio.h>
-
#include <conio.h>
-
#include <math.h>
-
#include <ctype.h>
-
#include <graphics.h>
-
#include <stdlib.h>
-
-
/* INITIALIZE ARRAY */
-
int Status[8][8]={{1,5,1,5,1,5,1,5},{5,1,5,1,5,1,5,1},{1,5,1,5,1,5,1,5},{5,0,5,0,5,0,5,0},{0,5,0,5,0,5,0,5},{5,3,5,3,5,3,5,3},{3,5,3,5,3,5,3,5},{5,3,5,3,5,3,5,3}};
-
-
/* DRAW DAMA BOARD */
-
void DAMABOARD ()
-
{
-
cleardevice();
-
setcolor(14); settextstyle(SANS_SERIF_FONT,HORIZ_DIR,3);
-
outtextxy(335,70 ," LET'S PLAY CHECKERS!");
-
setcolor(10); settextstyle(DEFAULT_FONT,HORIZ_DIR,2);
-
outtextxy(320,100," ÉÍËÍËÍËÍËÍËÍËÍËÍ»");
-
outtextxy(320,115,"0º º º º º º º º º");
-
outtextxy(320,130," ÌÍÎÍÎÍÎÍÎÍÎÍÎÍÎ͹");
-
outtextxy(320,145,"1º º º º º º º º º");
-
outtextxy(320,160," ÌÍÎÍÎÍÎÍÎÍÎÍÎÍÎ͹");
-
outtextxy(320,175,"2º º º º º º º º º");
-
outtextxy(320,190," ÌÍÎÍÎÍÎÍÎÍÎÍÎÍÎ͹");
-
outtextxy(320,205,"3º º º º º º º º º");
-
outtextxy(320,220," ÌÍÎÍÎÍÎÍÎÍÎÍÎÍÎ͹");
-
outtextxy(320,235,"4º º º º º º º º º");
-
outtextxy(320,250," ÌÍÎÍÎÍÎÍÎÍÎÍÎÍÎ͹");
-
outtextxy(320,265,"5º º º º º º º º º");
-
outtextxy(320,280," ÌÍÎÍÎÍÎÍÎÍÎÍÎÍÎ͹");
-
outtextxy(320,295,"6º º º º º º º º º");
-
outtextxy(320,310," ÌÍÎÍÎÍÎÍÎÍÎÍÎÍÎ͹");
-
outtextxy(320,325,"7º º º º º º º º º");
-
outtextxy(320,340," ÈÍÊÍÊÍÊÍÊÍÊÍÊÍÊͼ");
-
outtextxy(320,355," 0 1 2 3 4 5 6 7 ");
-
-
setcolor(11); settextstyle(SMALL_FONT,HORIZ_DIR,5);
-
outtextxy(5,380," Direction:");
-
outtextxy(5,400," Press a number from 0 to 7, to get the row and column value.");
-
outtextxy(5,420," Press <ESC> to quit.");
3 3393
Try to simplify the game into simple steps,
refine these simpler steps into more manageable processes,
continue this until you have little tasks to implement.
One approach (Top-Down programming I think).....is to wrtte the steps as code.
Then you need to implement the steps to do what they're supposed to, but we can apply the same principle again/.
eg -
while(!gameFinished)
-
{
-
thisPlayer.makemove();
-
displayBoard();
-
thisPlayer = nextPlayer();
-
}
-
We have just decided that we need to implement a player class, that it needs to have at least the methid makeMove, that we need a routine for displayBoard and that we need some way to move ionto the nextplayer.,.....
you can first implement minimal functionality (ie so long as nextPlayer returns something (which can be null initially)the code would compile. (provided you have DEFINED these methods (they don't actually have to DO anything yet)).
Once you start working on a particular method, you can use the same idea of refining what it actually is that you want the method to do.
If you have time afterwards, you can go through and find redundant methods ->things that seemed a good idea at the time, but can be better done another way
Thanks for your help but I am still struggling with it
Can you help me with the code below
# include <stdio.h>
# include <math.h>
# include <ctype.h>
# include <graphics.h>
# include <stdlib.h>
/* initilize array E=Empty, WP= White Piece - uncrowned, BP = Black Piece - uncrowned */
int Status [8] [8] = {{ BP, E, BP, E, BP, E, BP, E }, { E, BP, E, BP, E, BP, E, BP}, { BP, E, BP, E, BP, E, BP, E }, { E, E, E, E, E, E, E, E }, { E, E, E, E, E, E, E, E },
{ E, WP, E, WP, E,WP, E,WP }, { WP, E, WP, E, WP, E, WP, E }, { E, WP, E, WP, E, WP, E, WP} } ;
/* allow user to start a new game of draughts */
printf( ''Select new to start a new games: ''\n ) ; /*prompt*/
while(!gameFinished)
{
thisPlayer.makemove();
displayBoard();
thisPlayer = nextPlayer();
}
I need to store the status of the game, can anyone help?
You can either pass a flag through the method(s) that make a turn, or you could set up a global flag that can tore the state of play
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Moosebumps |
last post by:
When I have time, I am planning to evaluate Python for console game
development (on Playstation 2, GameCube, and Xbox). Does anyone have any
experience with this?
Pretty much the only resource...
|
by: Bob |
last post by:
I just recently noticed that when I start my applicatoin in debug mode, the IDE
hangs (no disk or CPU activity) indefinitely (at least 20 minutes). Pausing the
application shows that it's hung up...
|
by: Rahtgaz |
last post by:
Hello everyone,
I'm wanting to start implementation of a pet project game IO mechanism.
The game is console based. A cross between MUD and Rogue types. For I/O
operations I'll be using ncurses...
|
by: mer000 |
last post by:
Can you guys help me out? I'm trying to create a very simple game of craps but having some trouble. Below are the rules and requirements. Much appreciated!
Given the following rules for the game...
|
by: Shawn Minisall |
last post by:
For my final project, I'm trying to do a GUI based game similar to are
you smarter then a 5th grader. I've been working on it and am stuck
with some code someone helped me with to randomize the...
|
by: Z E R O |
last post by:
I'm in a really fast pace training program and we are covering a lot of material in a relatively short period of time. I've really not had much trouble up until this problem. I had to do one other...
|
by: foolsmart2005 |
last post by:
I have written a snake game. There are 2 levels in the game(I
finished 1st level). It can run in VC++ without problem but, when I
run it on the dev C++ 4.9.9.2, it cannot run. I want to...
|
by: fairie |
last post by:
It seems my choices aren't working out as I'd like. So from the first area when I input choice number 3, it should send me to the fourth area, as per the {3, 3, 0} - but it stays at the first area.
...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |