Join Date: May 2005
Location: Aurora, United States
Posts: 606
|
<div class='quotetop'>QUOTE(Reup @ Jun 13 2006, 06:56 AM) [snapback]236324[/snapback]</div>
Quote:
Okay. Now do 'joust' 
Btw, where you say logarithm, don't you mean algorithm? 
[/b]
|
Ah, yes. I have a bit of a problem doing that, even in my conversation. For some reason those two words get confused in my mind. Okay, hopefully I won't do that again.
So, Joust you say, eh?
This game was another taken from a BASIC game of the same name (from the second book of BASIC programs). It's kind of a choose your own story with a weighted random. On some of the BASIC programs I converted my attempt was to duplicate the algorithm of the original game exactly, so as to experience the game as it was meant to be played. On this one, however, I couldn't resist making a few small improvements. First of all, the original game had a bug that would allow you to choose defense options that were not shown if you knew their number. Fixed. Also in this one, if you mightaly unseat your opponent your next opponent (unless it's the fearless black night) will bow out.
Buy why am I just talking about the game, I should show it to you:
Code:
/* Joust
* Based on a BASIC game of the same name by Alan Yarbrough
* as found in 'More BASIC Computer Games' edited by David H. Ahl (c) 1979
* by Joseph Larson
*/
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
#define WAIT puts ("\nPress ENTER to continue..."); getchar(); getchar()
char *roundintro[5] = {
**"This is your first joust. You are up aginst the Red Knight."
**,"This is your second joust. Your opponent is the Silver Knight."
**,"You are doing well! Your third joust is against the Gold Knight."
**,"This is your final test! If you win this one the princess is yours!\n"
**"This fight is against the fierce Black Knight!"
**,"Huzzah! You are the winner!\n"
**"Your prowis on the field of tournament has proven you worthy of the hand\n"
**"of the princess. With the concent of her father you marry the fair maden\n"
**"and live happily ever after.\n The End."},
*aimd[8] = {"1 - Helm", "2 - Shield, Upper Left", "3 - Shield, Upper Middle"
**,"4 - Shield, Upper Right", "5 - Shield, Lower Left"
**,"6 - Shield, Lower Middle", "7 - Shield, Lower Right", "8 - Base of Shield"},
*defd[6] = {"1 - Lower Helm", "2 - Right Lean", "3 - Left Lean"
**,"4 - Steady Seat", "5 - Shield High", "6 - Shield Low"},
*defmsg[8] = {"He missed you.", "He glanced off your shield."
**,"He knocked off your helm.", "He broke his lance."
**,"He has unseated you. (Thud!)"
**,"He has broken his lance, injured and unseated you."
**,"He hs injured and useated you. (crash)"
**,"He has broken his lance and unseated you. (Clang!)"},
*aimmsg[8] = {"You missed him. (Hiss!)", "You hit his shield but glanced off."
**,"You knocked off his helm! (Cheers!)", "You broke your lance. (Crack...)"
**,"You unseated him. (Loud cheers and huzzahs!)"
**,"You broke your lance, unseated and injured your foe. (The croud goes wild!)"
**,"You injured and unseated your opponenet."
**,"You broke your lance but unseated your opponent."};
int defok[8] = {7, 15, 63, 23, 7, 63, 7, 39},
defx[6][8] = {{0, 4, 5, 1, 3, 7, 1, 3},**{0, 3, 4, 0, 6, 1, 0, 1},
**{0, 0, 1, 3, 0, 3, 7, 5}, {2, 3, 3, 1, 3, 7, 1, 3}, {4, 3, 7, 1, 0, 5, 1, 5},
**{0, 0, 6, 4, 3, 3, 1, 3}},
aimx[8][6] = {{0, 0, 0, 2, 4, 0}, {4, 3, 0, 3, 3, 0}, {5, 4, 1, 3, 7, 6},
**{1, 0, 3, 1, 1, 4}, {3, 7, 1, 3, 0, 3}, {7, 1, 3, 7, 5, 3},
**{1, 0, 7, 1, 1, 1}, {3, 1, 4, 3, 5, 3}};
void intro (void) {
**printf ("Joust\n-----\n"
**"Hear ye, hear ye. Let all the noble knights of the kingdom come to joust\n"
**"at the King's tournament for the favor of the his daughter, the beautiful\n"
**"princess.\n\n");
}
int main (void) {
**int c, aim, def, r, droll, aroll;
**intro ();
**srand (time (NULL));
**r = 0;
**puts (roundintro[r]);
**do {
****puts ("\nChoose your aiming point :");
****for (c = 0; c < 8; c++) puts (aimd[c]);
****printf ("? "); scanf ("%d",**&aim);
****aim--;
****while (aim < 0 || aim > 7) {
******printf ("Invalid. Choose a number between 1 and 8.\n? ");
******scanf ("%d", &aim); aim--;
****}
****puts ("\nYou may use one of these defenses:");
****for (c = 0; c < 6; c++) if (defok[aim] & 1 << c) puts (defd[c]);
****printf ("? "); scanf ("%d", &def); def--;
****while (!(defok[aim] & 1 << def)) {
******printf ("Invalid. Choose an option from the menu above.\n? ");
******scanf ("%d", &def); def--;
****}
****putchar('\n');
****droll = rand () % 8;
****puts (defmsg[defx[def][droll]]);
****do {
******aroll = rand () % 6;
******switch (droll) {
********case 0:
********case 4:
********case 6: if (aroll < 3) aroll = -1; break;
********case 1: if (aroll < 2) aroll = -1; break;
********case 3: if (aroll == 0 || aroll == 2) aroll = -1; break;
********case 7: if (aroll == 1 || aroll == 2) aroll = -1;
******}
****} while (aroll < 0);
****puts (aimmsg[aimx[aim][aroll]]);
****if (defx[def][droll] < 4)
******if (aimx[aim][aroll] > 3) {
********puts ("\nYou have won this joust.");
********r++;
********WAIT;
********puts (roundintro[r]);
********if (aimx[aim][aroll] == 5 && r < 3) {
**********puts ("\nDue to your mighty victory in the last round your next "
************"opponent has conceded \nto you the win in this round.");
**********r++;
**********WAIT;
**********puts (roundintro[r]);
********}
******}
**** else {
****** puts ("\nYou are both ready to try again.");
****** WAIT;
**** }
**} while (r < 4 && defx[def][droll] < 4);
**if (r < 4) if (aimx[aim][aroll] < 4)
****puts ("\nToo bad, you lost. You leave the field of tournament a disgrace.");
**else puts ("\nToo bad, you both lost. At least your honor is intact.");
**puts ("\nFarewell Sir Knight.");
**WAIT;
}
Sample output
Code:
Joust
-----
Hear ye, hear ye. Let all the noble knights of the kingdom come to joust
at the King's tournament for the favor of the his daughter, the beautiful
princess.
This is your first joust. You are up aginst the Red Knight.
Choose your aiming point :
1 - Helm
2 - Shield, Upper Left
3 - Shield, Upper Middle
4 - Shield, Upper Right
5 - Shield, Lower Left
6 - Shield, Lower Middle
7 - Shield, Lower Right
8 - Base of Shield
? 6
You may use one of these defenses:
1 - Lower Helm
2 - Right Lean
3 - Left Lean
4 - Steady Seat
5 - Shield High
6 - Shield Low
? 4
He broke his lance.
You broke your lance, unseated and injured your foe. (The croud goes wild!)
You have won this joust.
Press ENTER to continue...
This is your second joust. Your opponent is the Silver Knight.
Due to your mighty victory in the last round your next opponent has conceded
to you the win in this round.
Press ENTER to continue...
You are doing well! Your third joust is against the Gold Knight.
Choose your aiming point :
1 - Helm
2 - Shield, Upper Left
3 - Shield, Upper Middle
4 - Shield, Upper Right
5 - Shield, Lower Left
6 - Shield, Lower Middle
7 - Shield, Lower Right
8 - Base of Shield
? 1
You may use one of these defenses:
1 - Lower Helm
2 - Right Lean
3 - Left Lean
? 1
He glanced off your shield.
You missed him. (Hiss!)
You are both ready to try again.
Press ENTER to continue...
And so on. It is possible to win the lady, I've done it several times. But sometimes fate steps in. Try it a few times, you may like it.
Next? - Battleship (like the board game vs the computer)
- Cel Life (multi-player version of John Conway's game of Life)
- Awari (african counting game with a learning logrithm)
- 3DMaze (randomly generated mazes to navigate in first person perspective)
- Pickup Piles (1000 games in one, set the rules and play)
- Flash Cards (with pretty output, practice your math)
- Hammurabi (rule a country, build your kingdom)
- Black Box (find molecules in the inky depths)
- Hangman (guess the word before you dangle)
- Mugwump (find the creatures hiding on a grid with a distance detector)
- Acey Deucy (a card game of highs, lows, and middles)
- Reverse (order a list of number by turning them around)
- Stars/Trap/Letter Guess (3 games in 1 update, variations on a theme)
While at the moment this thread has Reup and Data apparently reading it, and U-Boat commander Dave offering his digits for programming skill, my hope is that this is a thread that over a long time will get noticed once in a while. But at the moment, how are you all liking it so far?
|