Pascal小游戏 随机函数
一个被人写滥了的小程序,新手学习,Pascal By Chaobs
初学者可以用它来学习随机函数的运用,当然你完全可以自己写一个随机函数。
var
player1,player2:longint;
a,b,l,o,i,v:longint; w:boolean;
begin
randomize;
write('A=');readln(player1);
write('B=');readln(player2);
b:=1;
i:=1;
while(player1>0)and(player2>0)do
begin
if i=1 then
begin
a:=random(101)+1;
if a<=70 then
begin
writeln('A against B,B has ',a,' damage.');
player2:=player2-a;
end;
if (a>70)and(a<=80) then
begin
o:=random(30);
writeln('A thumping B,B has ',a*2+o,' damage.');
player2:=player2-a*2;
end;
if (a>80)and(a<=85) then
begin
o:=random(120);
writeln('A restored ',a*2+o-50,' points.');
player1:=player1+a*2+o-50;
end;
if (a>85)and(a<=90) then
begin
writeln('A launched combo. ');
l:=100;
w:=true;
while w do
begin
o:=random(71);
writeln('B has ',o,' damage.');
player2:=player2-o;
if l<random(80) then w:=false;
l:=l-random(15);
end;
end;
if (a>90)and(a<=95) then
begin
o:=random(300);
writeln('A launch from exploding!');
writeln('A has ',o div 2,' damage.');
writeln('B has ',o+10,' damage.');
player1:=player1-o div 2;
player2:=player2-(o+10);
end;
if (a>95)and(a<=97) then
begin
writeln('A midicine,restore ',400,' points!');
player1:=player1+400;
end;
if (a>97)and(a<=100) then
begin
o:=random(100)+100;
writeln('A vampire ',o,' points.');
player1:=player1+o;
player2:=player2-o;
end;
if (a=101) then
begin
writeln('A colossus heaven boxing! ');
l:=100;
o:=random(20)+1;
for v:=1 to 100 do
begin
writeln('B has ',v*o,' damage.');
player2:=player2-v*o;
if l<random(80) then break;
l:=l-random(15);
end;
end;
i:=2;
if player1<0 then player1:=0;
if player2<0 then player2:=0;
writeln(' A ',player1);
writeln(' B ',player2);
readln;
end;
if i=2 then
begin
a:=random(101)+1;
if a<=70 then
begin
writeln('B against A,A has ',a,' damage.');
player1:=player1-a;
end;
if (a>70)and(a<=80) then
begin
o:=random(30);
writeln('B thumping A,A has ',a*2+o,' damage.');
player1:=player1-a*2;
end;
if (a>80)and(a<=85) then
begin
o:=random(120);
writeln('B restored ',a*2+o-50,' points.');
player2:=player2+a*2+o-50;
end;
if (a>85)and(a<=90) then
begin
writeln('B launched combo. ');
l:=100;
w:=true;
while w do
begin
o:=random(71);
writeln('A has ',o,' damage.');
player1:=player1-o;
if l<random(80) then w:=false;
l:=l-random(15);
end;
end;
if (a>90)and(a<=95) then
begin
o:=random(300);
writeln('B launch from exploding!');
writeln('B has ',o div 2,' damage.');
writeln('A has ',o+10,' damage.');
player2:=player2-o div 2;
player1:=player1-(o+10);
end;
if (a>95)and(a<=97) then
begin
writeln('B midicine,restore ',400,' points!');
player2:=player2+400;
end;
if (a>97)and(a<=100) then
begin
o:=random(100)+100;
writeln('B vampire ',o,' points.');
player2:=player2+o;
player1:=player1-o;
end;
if (a=101) then
begin
writeln('B colossus heaven boxing! ');
l:=100;
o:=random(20)+1;
for v:=1 to 100 do
begin
writeln('A has ',v*o,' damage.');
player1:=player1-v*o;
if l<random(80) then break;
l:=l-random(15);
end;
end;
i:=1;
if player1<0 then player1:=0;
if player2<0 then player2:=0;
writeln(' A ',player1);
writeln(' B ',player2);
readln;
end;
end;
writeln;
if player1>player2 then writeln('A WIN!')
else if player2>player1 then writeln('B WIN!')
else writeln('DRAW');
readln;
end.
Pascal小游戏 随机函数的更多相关文章
- Pascal小游戏 不要消灭星星
不要消灭星星 Pascal小游戏 Chaobs改编自pascal吧 控制台小游戏嘛,就当是练习一下结构化的写法. program wxtw; uses crt; type zbdy=reco ...
- Pascal小游戏 文件的产生
一个整人的Pascal小程序 运行之后硬盘里面会有一大堆垃圾,当然更好的方法当然不是这样做! var a,b,c,d:char;beginfor a:='0' to '9' dofor b:='0' ...
- Pascal小游戏 双人射击
一个双人的游戏 Pascal源码附上 只要俩人不脑残,一下午玩不完...又是控制台游戏中的一朵奇葩. Free Pascal 射击游戏 Program shooting_game; uses crt; ...
- Pascal小游戏之奇葩的RPG
Pascal吧友作品 一个小RPG Chaobs转载 varplife,plifemax,patt,pre:integer;gr,ex,exmax:integer;alife,alife1,aatt, ...
- Pascal小游戏 俄罗斯方块怀旧版
俄罗斯方块怀旧版(注释版) {$APPTYPE GUI}{$MODE DELPHI}program WinPiece; usesWindows; constAppName = 'WinPiece';p ...
- Pascal小游戏 打飞机
一个经典的打飞机游戏(1)Pascal代码 十分经典,有一种街机的感觉 奇葩青年的又一控制台神作. uses crt; type list=record ty,ax:integer; ...
- Pascal小游戏 井字棋
一个很经典的井字棋游戏 Pascal源码Chaobs奉上 注意:1.有的FP版本不支持汉语,将会出现乱码.2.别想赢电脑了,平手不错了. 井字过三关: program TicTacToe; uses ...
- Pascal小游戏 贪吃蛇
一段未完成的Pascal贪吃蛇 说这段代码未完成其实是没有源代码格式化,FP中一行最多只有255字符宽. uses crt; const screenwidth=50; screenheight=24 ...
- Pascal小游戏 俄罗斯方块
俄罗斯方块已经成为了和“Hello World”一样的程序了吧? 不要直接复制,可能需要事先 Format. program cube;uses crt,graph,dos;var gd,gm:sma ...
随机推荐
- ubuntu 显示隐藏文件
原文链接 http://blog.csdn.net/happyjiahan/article/details/6023496 方法1.使用命令ls -a显示所有的文件,包括隐藏文件 方法2.在桌面化操作 ...
- C语言中头文件怎么写?(本文来源网络,由黑乌鸦进一步完善)
c语言头文件怎么写?我一直有这样的疑问,但是也一直没去问问到底咋回事:所以今天一定要把它弄明白! 其实学会写头文件之后可以为我们省去不少事情,可以避免书写大量的重复代码.有利于整理思路.使代码脉络 ...
- 利用Excel导入数据到SAP C4C
假设要导入一个Account数据到C4C系统. 工作中心Data Workbench,工作中心视图Import,点download metadata: 会下载一个压缩包到本地. 进入文件夹Templa ...
- Hash模板
;//一般为靠近总数的素数 struct Hashtable { int x;//hash存的值 Hashtable * next; Hashtable() { next = ; } }; Hasht ...
- P1036 选数
题目描述 已知 nn 个整数 x_1,x_2,…,x_nx1,x2,…,xn,以及11个整数kk(k<nk<n).从nn个整数中任选kk个整数相加,可分别得到一系列的和.例如当n=4 ...
- c#中的 MessageBox 弹出提示框的用法
MessageBox.Show(<字符串str> Text, <字符串str> Title, <整型int> nType,MessageBoxIcon); 例:Me ...
- python-类对象以列表切片模式操作
#类对象以列表切片模式操作 class Person: def __init__(self): self.cache=[] def __setitem__(self, key, value): #修改 ...
- MySQL 存储过程参数IN OUT INOUT区别
MySQL 存储过程参数IN OUT INOUT对比 一.IN -- 创建测试存储过程 delimiter // create procedure p_in ( IN num int ) begin ...
- cudaMallocPitch – 向GPU分配存储器
概要 cudaError_t cudaMallocPitch( void** devPtr,size_t* pitch,size_t widthInBytes,size_t height ) 说明 向 ...
- 前端JavaScript之ECMA
1.JavaScript基础 2.语法规则 3 常用内置对象 4 函数 5 伪数组 6.异常处理 1.1 web前端分为三层 HTML:从语义的角度,描述页面结构 CSS:从审美的角度,描述样式(美化 ...