View Single Post
Old 03-03-2005, 03:14 AM   #21
YMIHere
Newbie

 
Join Date: Oct 2004
Location: ,
Posts: 7
Default

Sweet! I should come here more often so I can learn C/C++ with some of you guys. =)

Anyway, my first game was a guessing game that let you pick the range, but I accidentally overwrote it when trying out someone elses guessing game. I gave someone the source, but when I asked for it back they were busy. Haven't seen him in months. =P

Since that one's out of the question, I also made a cheesy little eight-ball program. =)
Code:
#include <stdlib.h>
#include <stdio.h>
#include <time.h>

int main()
{
	char choice='y';
	printf("\n\nHello, I'm am the almighty eight-ball. You should know what to do \
 *with me by now so start with the questions.\n\n");
	while(choice=='y'||choice=='Y')
	{
 *int random_number;
 *while(getchar()!='\n');
 *srand((unsigned)time(NULL));
 *random_number=rand()%9; *//Limit the random number from 0 to 10.
 *switch(random_number)
 *{
 *	case 1:
 * *printf("All signs point to yes.\n");
 * *break;
 *	case 2:
 * *printf("Not very likely.\n");
 * *break;
 *	case 3:
 * *printf("Of course.\n");
 * *break;
 *	case 4:
 * *printf("It looks a bit murky, maybe money will help me see the answer.\n");
 * *break;
 *	case 5:
 * *printf("What the hell are you asking me for?\n");
 * *break; *	
 *	case 6:
 * *printf("Go away, fool!\n");
 * *break;
 *	case 7:
 * *printf("The answer is 42, it's always 42.\n");
 * *break;
 *	case 8:
 * *printf("Do I bother you while you're sleeping? Maybe I should.\n");
 * *break;
 *	case 9:
 * *printf("How the hell should I know? I'm a freaking ball.\n");
 * *break;
 *	default:
 * *printf("No.\n");
 *}
 *for(int i=0;i<300000000;i++);	//Pre-historic sleeping operation.
 *printf("\nWould you like to ask another question?(y/n)");
 *choice=getchar();
 *if(choice=='y'||choice=='Y')
 *{
 *	printf("Ask away.\n\n");
 *}
 *fflush(stdin);
	}
	return 0;
}
Now for anyone who wants to look at some really ugly stuff, I made a text Yahtzee game a while ago, but it's kind of big so I'll add it as an attachment. I don't understand much of it any more so I can't explain why I did certain things, but I do know that I was taking numbers from players as text because if they entered text when I wanted a number Yahtzee would freeze up. These were both compiled with Microsoft Visual Studio C++, so sorry if anyone has problems getting them to compile in their compilers.
YMIHere is offline                         Send a private message to YMIHere
Reply With Quote