Forum for users of JoomlaWatch / ExtraWatch for Joomla, Wordpress, Drupal, Magento, Prestashop

JoomlaWatch / ExtraWatch has following features: live real-time visitor statistics, location of your visitors on a map, blocking of users based on bad word list, front-end counters, click heat map, definition of goals and rules, graphs, directory size monitoring, monitoring of increase of database data in time, nightly email reports, interactive HTML5 chart of traffic flow within your website, SEO report with keyword statistics and keyword position trends

Welcome, Guest
Please Login or Register.    Lost Password?

bitsnip2
(1 viewing) (1) Guest
Go to bottomPage: 1
TOPIC: bitsnip2
#3384
bitsnip2 4 Years, 8 Months ago Karma: 0
a little bit of my game code im working on ========================================================================================================================================================================================================================================================== ========================================================================================================================================================================================================================================================== ========================================================================================================================================================================================================================================================== ========================================================================================================================================================================================================================================================== =========================================================================================================================================================================================================================================================/ / ===============================================================
// | Main Method |
// ===============================================================
static void Main(string[] args)
{
// local data
bool quit = false;
string yesNo;
int previousScore, turnScore, dartScore;
bool validNumber;
bool win = false;

DisplayInstructions();
do // main loop
{
// get player names
for (int player = 0; player < NUM_PLAYER; player++)
{
Console.WriteLine("Enter name for player " + player);
playerNames[player] = Console.ReadLine(); // read name
playerScores[0, player] = STARTING_SCORE; // initialize score
}
// read scores for turns
for (int turn = 0; turn < NUM_TURNS; turn++) // 10 turns
{
Console.WriteLine("\nTurn {0}:\n======\n", turn);
for (int player = 0; player < NUM_PLAYER; player++) // 2 players
{
Console.WriteLine("Player {0} ({1}):", player, playerNames[player]);
previousScore = playerScores[turn, player]; // remember previous score
turnScore = 0; // reset turn score
for (int dart = 0; dart < NUM_DARTS; dart++) // 3 darts
{
Console.Write("dart {0}>", dart);
do // validate number
{
validNumber = int.TryParse(Console.ReadLine(), out dartScore); // valid number
if (dartScore < 0 || dartScore > 20) // is between 0-20
{
validNumber = false;
}
} while (validNumber == false);
turnScore += dartScore; // compute dart score for current throw
if ((previousScore - turnScore) < WIN_SCORE)
{
turnScore = 0; // no score for this turn
DisplayBUST(player);
break;
}
}
playerScores[turn, player] -= turnScore; // compute turn score
Console.WriteLine("Turn score = {0}\n", playerScores[turn, player]); // display current score
if (playerScores[turn, player] == WIN_SCORE) // winner
{
DisplayWIN(player); // display winner
win = true; // to quit another loop ('turn)
break; // quit 'player' loop
}
if (turn < (NUM_TURNS - 1)) // until the last but one (don't go past the bound of array!)
{
// copy score for the next turn for the player
playerScores[turn + 1, player] = playerScores[turn, player];
}
}
if (win == true) break;
}
if (win == false)
{
// no winner???
}
// play again?
Console.WriteLine("Do you want to quit? (Y/N)");
yesNo = Console.ReadLine().ToUpper();
if (yesNo == "Y")
{
quit = true;
}
} while (quit == false);

Console.ReadLine();
}

// ===============================================================
// | Display Instructions |
// ===============================================================
static void DisplayInstructions()
{
// array containing instructions
string[] instructions = new string[]
{
"Welcome to Blackpoool Beach Darts score database",
"Two players are playing in alternating 'turns'",
"During each 'turns' 3 darts are thrown",
"Each 'leg' last for maximum 10 'turns'",
""
};
// clear the console and display instructions
Console.Clear();
foreach (string text in instructions)
{
Console.WriteLine(text);
}
}
blackbox1 (User)
Fresh Boarder
Posts: 1
graphgraph
User Offline Click here to see the profile of this user
The administrator has disabled public write access.
 
Go to topPage: 1

Latest News

Get the latest freelance project announcements
Follow CodeGravity.com

Download ExtraWatch™

ExtraWatch™ FREE is Joomla, Wordpress, Prestashop, Magento plugin with following features: Live Stats, Nightly Email Reports, Goals, Graphs, Anti-spam, History and more