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 ...
随机推荐
- 1923. Scary Politics (timus) (dfs) search
http://acm.timus.ru/problem.aspx?space=1&num=1923 -- timus This is s problem about thd dfs and s ...
- Cmake 01
1. sdsf(single direction single file) 1.1 The directory tree /* ./template | +--- build | +---main. ...
- vue中多个元素或多个组件之间的动画效果
多个元素的过渡 <style> .v-enter,.v-leave-to{ opacity: 0; } .v-enter-acitve,.v-leave-active{ opacity: ...
- centos6.5下编译安装FFmpeg
以下安装步骤基本来自官网,做个笔记以方便自己以后查看 http://trac.ffmpeg.org/wiki/CompilationGuide 1.安装依赖包 <span style=" ...
- 百度Ueditor 图片上传无反应,显示上传0张,不能点确定
解决办法: \Data\Ueditor\php\Uploader.class.php 190行左右 /** * 获取文件扩展名 * @return string */ private function ...
- python 3+djanjo 2.0.7简单学习(一)
1.安装django pip install django 我这里已经安装过了 整个目录结构如下: votes : migrations : __init__.py : admin.py : apps ...
- P2878 [USACO07JAN]保护花朵Protecting the Flowers
一个类似国王游戏的贪心 话说要是先做了这个题,国王游戏之余懵逼这么久吗? #include<iostream> #include<cstdio> #include<alg ...
- 离散外微积分(DEC:Discrete Exterior Calculus)基础
原文链接 “若人们不相信数学简单,只因为他们未意识到生命之复杂.”——Johnvon Neumann DEC主要讨论离散情况下的外积分,它在计算机领域有重要用途.我们知道,使用计算机来处理几何图形的时 ...
- Spring 框架配置web.xml 整合web struts
package cn.itcast.e_web; import java.io.IOException; import javax.servlet.ServletContext; import jav ...
- 写给iOS小白的MVVM教程(一): 从MVC到MVVM之一个典型的MVC应用场景
前言 本着实践为主的原则,此系列文章不做过多的概念性的阐述和讨论;更多的代码和篇幅用来展示MVC和MVVC下的基础代码结构与具体实现,来展示各自优劣.这篇文章,更多的在于发掘MVC与MVVC的共性,以 ...