切换到宽版
  • 19518阅读
  • 29回复

『原创』游戏程序(Free pascal) [复制链接]

上一主题 下一主题
离线sunlight
 
只看楼主 正序阅读 0 发表于: 2005-11-15
Game


文件夹“E:\game”

文件:
1.E:\game\discribe.pas
  内容:
        游戏说明
计算并输入结果,规则:
1.A+B=?则输入A+B的和;
2.A-B=?则输入A-B的差
(如果A-B<0,必须有负号);
3.A*B=?则输入A*B的积;
4.AdivB=?输入A/B的商
(不包括余数);
5.AsqrB=?输入A*(B的平方);
6.A!表示求A的阶乘
(A!=1*2*3*...*A)
祝你有好成绩!
积分:关数*10/道

2.E:\game\music0.pas
内容:
4 6 160 0 欢
4 6 160 0 乐
4 8 160 0 女
4 10 160 0 神
4 10 160 0 圣
4 8 160 0 洁
4 6 160 0 美
4 4 160 0 丽
4 2 160 0 灿
4 2 160 0 烂
4 4 160 0 光
4 6 160 0 芒
4 6 320 0 照
4 4 80 0 大
4 4 160 0 地
4 0 320 0
0 0 0 0

3.E:\game\music2.pas
  内容:
4 6 160 0 我
4 6 160 0 们
4 8 160 0 怀
4 10 160 0 着
4 10 160 0 火
4 8 160 0 样
4 6 160 0 热
4 4 160 0 情
4 2 160 0 来
4 2 160 0 到
4 4 160 0 你
4 6 160 0 的
4 4 320 0 圣
4 2 80 0 殿
4 2 160 0 里
4 0 320 0 .

4.E:\game\music3.pas
  内容:
4 4 160 0 你
4 4 160 0 的
4 6 160 0 威
4 2 160 0 力
4 4 160 0 能
4 6 80 1 把
4 8 80 0
4 6 160 0 人
4 2 160 0 类
4 4 160 0 重
4 6 80 1 新
4 8 80 0
4 6 160 0 团
4 4 160 0 结
4 2 160 0 在
4 4 160 0 一
2 10 160 0 起
4 6 160 1 在
4 6 160 0
4 6 160 6 你
4 8 160 0 光
4 10 160 0 辉
4 10 160 0 照
4 8 160 0 耀
4 6 160 0 之
4 8 80 1 下
4 4 80 0
4 2 160 0 人
4 2 160 0 类
4 4 160 0 团
4 6 160 0 结
4 4 320 0 成
4 2 80 0 兄
4 2 160 0 弟
4 0 320 0  

5.E:\game\highrecords.pas
内容:
1810     sunlight
6.(主程序)E:\game\game.pas
  内容:
program game(input,output,f);
uses crt;
label 1;
type
  sun=record
      name:string;
      score:longint
    end;
var mn,mm,mmm,a,b,c,e,an,level,i,j,k,k0,n,o:longint;score:integer;
    flag,flag2:boolean;
    f:text; d,z:longint;
    ch:array[0..6]of char;
    s:string;
    high:sun;
procedure play(k:integer);
  const base=32.625;
  var x:real;i,a,b,c,d:integer;s:string;ch:char;s2:string[5];
  begin
    ch:=chr(48+k);
    s:='E:\game\music'+ch;
    s:=s+'.pas';
    assign(f,s);reset(f);
    while not eof(f) do
    begin
    readln(f,a,b,c,d,s2);
    if b=0 then delay(c)
          else begin
              x:=base;
              for i:=1 to a do x:=x*2;
              for i:= 1 to b-1 do
                x:=x*1.059463994;
              if d=0 then begin
                        sound(round(x));
                        delay(c*2);
                        nosound
                      end
                  else begin
                        sound(round(x));
                        delay(c*2)
                      end;

      end
      end; writeln;
  close(f);
end;
function fi(i:longint):longint;
begin if i=0 then fi:=1 else fi:=fi(i-1)*i end;
procedure discribe;
var s:string;f:text;
begin
  assign(f,'E:\game\discribe.pas');
  reset(f);
  while not eof(f) do
    begin
    readln(f,s);
    gotoxy(wherex+3,wherey);
    writeln(s)
    end;
  close(f);gotoxy(wherex+3,wherey);
end;
FUNCTION make(x:longint;y:char;z:longint):longint;
    begin
      case y of
        '+' :exit(x+z);
        '-' :exit(x-z);
        '*' :exit(x*z);
        '/' :exit(x div z);
        'm' :exit(x mod z);
        's' :make:=x*sqr(z);

        end end;
begin
  textmode(3);
  window(10,1,50,15);
  textbackground(1);
  textcolor(14);
  clrscr;
  gotoxy(5,5);
  writeln('欢迎来到这个游戏!');
  gotoxy(wherex+5,wherey);
  readkey;
  clrscr;
  textcolor(14);
  gotoxy(4,5);
  writeln('你是初次玩这个游戏?');
  gotoxy(wherex+7,wherey);
  writeln('1-Yes');
  gotoxy(wherex+7,wherey);
  writeln('2-No');
  gotoxy(wherex+3,wherey);
  readln(o);
  if o=1 then begin clrscr;textcolor(3); discribe end;
  if o=1then readkey;
  clrscr;o:=1;
  repeat
  inc(o);
  if o=16 then o:=1;
  textcolor(o);clrscr;
  gotoxy(wherex+7,wherey);
  writeln('1-进入游戏');
  gotoxy(wherex+7,wherey);
  writeln('2-退出');
  gotoxy(wherex+7,wherey);
  delay(500)
  until keypressed;
  readln(k0);
  clrscr;
  textcolor(2);
  if k0=1 then
begin
  gotoxy(8,8);
  writeln('欢迎光临!');
  gotoxy(wherex+8,wherey);
  mm:=1;
  1:   randomize;
  ch[0]:='+';
  ch[1]:='-';ch[2]:='*';
  ch[3]:='/';ch[4]:='m';ch[5]:='s';
  ch[6]:='!';
  flag2:=false;
  level:=1;mn:=1;mmm:=1;readkey;
REPEAT
  if mm=1 then begin
    clrscr;
    textcolor(4);
    gotoxy(wherex+4,wherey);
    writeln('要音乐吗?');
    gotoxy(wherex+5,wherey);
    writeln('1—是');
    gotoxy(wherex+5,wherey);
    writeln('2—否');
    gotoxy(wherex+5,wherey);
    writeln('3—以后都不要');
    gotoxy(wherex+5,wherey);
    readln(mn);
    if mn=3 then mm:=0;
  end
  else mn:=0;
  if not flag2 then score:=0;
  flag:=true;
  n:=1;
  WHILE flag and(n<=10)DO
  BEGIN
    textcolor(3);
    gotoxy(wherex+7,wherey);
    a:=random(100)+1;
    b:=random(100)+1;
    if level=1 then c:=random(2)
    else if level=2 then c:=random(4)
    else if level<=4 then c:=random(6)
    else c:=random(7);
    if c=6 then
    a:=a div 10;
    write(a);
    case c of
    0 :write('+');
    1 :write('-');
    2 :write('*');
    3 :write('div');
    4 :write('mod');
    5 :write('sqr');
    6 :write('!');
    end;
    if c=6 then begin
    e:=random(4)+1;
    case e of
      0 :write('+');
      1 :write('-');
      2 :write('*');
      3 :write('div');
    end;
    end;
    writeln(b,'=?');
    if c<>6 then d:=make(a,ch[c],b)
    else begin d:=fi(a);d:=make(d,ch[e],b) end;
    gotoxy(wherex+7,wherey);
    readln(an);
    clrscr;
    if (an=d)or(abs(an-d)<=0.01) then begin
    inc(score,10*level);
    gotoxy(wherex+2,wherey);
    inc(n);textcolor(4);
    write('正确!你的分数','+');
    textcolor(13);
    writeln(score);
    textcolor(4);
      gotoxy(wherex+2,wherey);
      write('你的关数是 ');
      textcolor(random(13)+2);
      writeln(level);
    if mn=1 then play(0) end
      else begin
        flag:=false;textcolor(11);
        gotoxy(wherex+4,wherey);
        writeln('很抱歉,你错了.');
        gotoxy(wherex+4,wherey);
        write('应该是:');textcolor(14);writeln(d);
        gotoxy(wherex+4,wherey);
        if mn=1 then play(2);Readkey end
    end;
    clrscr;
    if n>=10 then begin
    inc(level);textcolor(12);
    flag2:=true;
    gotoxy(wherex+4,wherey+5);
    writeln('恭喜你');
      gotoxy(wherex+4,wherey);
      writeln('你闯过了第',level-1,'关!!');
    if mn=1 then play(3);readkey
    end
    else flag2:=false;
  UNTIL not flag2;
  if score>=100 then begin
  clrscr;
  textcolor(4);
  gotoxy(wherex+4,wherey);
  writeln('你分数很高,留下名吧!!');
    gotoxy(wherex+4,wherey);
    readln(s);
    assign(f,'E:\game\highrecords.pas');
    append(f);
    clrscr;
    textcolor(10);
    writeln(f,score,'     ',s);
    close(f);
    gotoxy(wherex+3,wherey);
    writeln('分数','名字':12);
    reset(f);textcolor(12);
    while not eof(f)do
    begin
      readln(f,high.score,high.name);
      gotoxy(wherex+3,wherey);
      writeln(high.score,high.name)
    end;
    close(f);
    gotoxy(wherex+7,wherey);
    readkey;
  end;
  clrscr;
  textcolor(15);
  gotoxy(wherex+4,wherey);
  writeln('谢谢光临!欢迎再来!');
  if mn=1 then play(0);
  gotoxy(wherex+4,wherey);
  readkey;
  clrscr;textcolor(10);
  gotoxy(wherex+3,wherey);
  writeln('要再来吗?');
  gotoxy(wherex+4,wherey);
  writeln('是—1');
  gotoxy(wherex+4,wherey);
  writeln('否—2');
  gotoxy(wherex+5,wherey);
  readln(mmm);
    if mmm=1 then goto 1;
  end;
clrscr;
textcolor(14);
gotoxy(wherex+4,1);
writeln('谢谢使用Sunlight软件!');
gotoxy(wherex+4,wherey+1);
writeln('QQ:282974362');
gotoxy(wherex+2,wherey+1);
writeln('E-mail:sunlight12345@eyou.com');
readkey
END.

望多提意见与建议!!

汉字显示
进入Free pascal后,按“Alt”+“Tab”退出,在屏幕下方找到它的最小化形式,
单击右键,选择“属性”,再选择“屏幕”,在“用法”栏中选择“窗口”。至此,
原Free Pascal会变为一个窗口,它是可以显示汉字的,如果不想显现汉字,可点击
标有“汉”的按钮切换为英文状态。
[ 此贴被sunlight在2005-12-11 16:17重新编辑 ]
离线fchqq
只看该作者 29 发表于: 2007-11-13
..老大。。能不能把程序打包上来。。。??
离线yuzhou
只看该作者 28 发表于: 2007-11-13
Free pascal 很不错
离线ddddddd
只看该作者 27 发表于: 2007-11-04
晕……
离线ddddddd
只看该作者 26 发表于: 2007-11-04
 
离线forever
只看该作者 25 发表于: 2007-10-19
好晕……
离线tzwangzy
只看该作者 24 发表于: 2007-09-22
晕~~~~~~~~
离线johnson
只看该作者 23 发表于: 2007-01-26
我为啥还不行?
离线雨化石
只看该作者 22 发表于: 2007-01-17
来,大家试一试嘛!!!!!!
离线雨化石
只看该作者 21 发表于: 2007-01-17
版主辛苦了
快速回复
限100 字节
 
上一个 下一个