http://blog.sina.com.cn/ufownl[订阅]
字体大小: 正文
文字版大富翁(2007-12-19 18:18:08)
     由于新浪发表文章的长度有限制,下面只有一部分,完整版在网易BLOG。下面是链接:http://ufownl.blog.163.com/blog/static/12501222007111961522786/
 

    前段时间无聊,编了个游戏。不过由于新浪发不了这么长的文章,所以发到这里来了。

 

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <string.h>
#include <windows.h>
#include <time.h>

//地图尺寸
#define SIZE 42
//总玩家数目
#define COUNT 5
//幸运卡片数目
#define CARD 5
//起始现金数
#define StartCash 10000
//起始存款数
#define StartDeposit 10000
//银行位置
#define BANK 0
//抽取幸运卡片的位置
#define LUCK 20

struct PlayerType
{
 char Name[10];
 int Pos,State;
 long Cash,Deposit;
} ;

struct MapType
{
 char Name[10];
 int Holder,Price,Count;
} ;

struct CardType
{
 char Action[256];
 int Prize;
} ;

void Init(struct MapType Map[], struct PlayerType Player[], struct CardType Card[])  //初始化地图、玩家、卡片信息
{
 FILE *Input;
 int i;

 Input=fopen("Map.Info","r");
 for (i=0;i<=SIZE-1;i++)
 {
  fscanf(Input,"%s%d",Map[i].Name,&Map[i].Price);
  Map[i].Holder=0;
  Map[i].Count=0;
 }
 fclose(Input);
 Input=fopen("Player.Info","r");
 for (i=0;i<=COUNT-1;i++)
 {
  fscanf(Input,"%s",Player[i].Name);
  Player[i].Cash=StartCash;
  Player[i].Deposit=StartDeposit;
  Player[i].Pos=rand()%SIZE;
  Player[i].State=0;
 }
 fclose(Input);
 Input=fopen("Card.Info","r");
 for (i=0;i<=CARD-1;i++) fscanf(Input,"%s%d",Card[i].Action,&Card[i].Prize);
 fclose(Input);
}

void ClearScreen()  //清屏
{
 system("cls");
}

void InputPlayerName(struct PlayerType Player[], int PlayerCount)  //输入玩家姓名
{
 int i;

 for (i=1;i<=PlayerCount;i++)
 {
  printf("请输入%d号玩家的昵称:>",i);
  scanf("%s",Player[i].Name);
 }
}

int Over(struct PlayerType Player[])  //判断是否游戏结束
{
 int i,Count=0;

 for (i=1;i<=COUNT-1;i++)
  if (Player[i].State==0) Count++;
 if (Count<=1) return 1;
 else return 0;
}

void Copy(char Str[], char

加载中,请稍候...
  • 评论加载中,请稍候...

验证码:请点击后输入验证码  收听验证码

发评论

以上网友发言只代表其个人观点,不代表新浪网的观点或立场。

相关博文
读取中...
推荐博文
读取中...