var
plife,plifemax,patt,pre:integer
gr,ex,exmax:integer
alife,alife1,aatt,are:integer
name,fname:string
na:text
code,co:string
dz:integer
money:longint
mp,mpmax:integer
red,blue,knife,clothes:integer
i:integer
god:array[1..100] of 1..7
godthing:integer
procedure bag
var
obj:integer
begin
writeln
writeln
writeln('百宝箱:')
writeln('1:红色药丸: ',red,'桐侍则 2:兰色药丸: ',blue,' 3:神剑:',knife,' 4:防身衣:',clothes,' 5离开')
writeln
writeln
writeln('请选择:')
repeat
readln( obj)
case obj of
1:begin
if red>0 then begin
red:=red-1
plife:=plife+40
if plife>plifemax then plife:=plifemax
end
end
2:begin
if blue>0 then begin
blue:=blue-1
mp:=mp+40
if mp>mpmax then mp:=mpmax
end
end
3:begin
if knife>0 then begin
knife:=knife-1
patt:=patt+15
end
end
4:begin
if clothes>0 then begin
clothes:=clothes-1
pre:=pre+15
end
end
end
writeln
writeln
writeln
until obj=5
exit
end
procedure bagplus(sh:integer)
begin
case sh of
1:red:=red+1
2:blue:=blue+1
3:knife:=knife+1
4:clothes:=clothes+1
end
end
procedure shop
var
ob:integer
begin
writeln
writeln
writeln('欢迎来到商店!')
writeln(' 1:红色局棚药丸 2:兰色药丸 3:神剑 4:防身衣 5:离开')
writeln(' $15 $15 $30 $30')
writeln
writeln('你想买什么?')
writeln
repeat
readln(ob)
case ob of
1:begin
if money>=15 then
begin
money:=money-15
bagplus(1)
writeln('OK!')
writeln(' 1:红色药丸 2:兰色药丸 3:神剑 4:防身衣 5:离开')
writeln(' $15 $15 $30 $30')
writeln
writeln('你想买什么?')
writeln
end
else writeln('钱不够啊,老大!')
end
2:begin
if money>=15 then
begin
money:=money-15
bagplus(2)
writeln('OK!')
writeln(' 1:红色药丸 2:兰色药丸 3:神剑 4:防身衣 5:离开')
writeln(' $15 $15 $30 $30')
writeln
writeln('你想买什么?')
writeln
end
else writeln('钱不够啊,老大!')
end
3:begin
if money>=30 then
begin
money:=money-30
bagplus(3)
writeln('OK!')
writeln(' 1:红色药丸 2:兰色药丸谈让 3:神剑 4:防身衣 5:离开')
writeln(' $15 $15 $30 $30')
writeln
writeln('你想买什么?')
writeln
end
else writeln('钱不够啊,老大!')
end
4:begin
if money>=30 then
begin
money:=money-30
bagplus(4)
writeln('OK!')
writeln(' 1:红色药丸 2:兰色药丸 3:神剑 4:防身衣 5:离开')
writeln(' $15 $15 $30 $30')
writeln
writeln('你想买什么?')
writeln
end
else writeln('钱不够啊,老大!')
end
end
until ob=5
exit
end
procedure storm
var
ka,kp:integer
begin
if mp>=30 then begin
writeln
writeln
writeln('破天一剑!!!!!!!!!!')
writeln(' 怪物生命:',alife1)
writeln('你的生命:',plife,'/',plifemax)
kp:=(random(patt)-random(are))*33
if kp>0 then begin
writeln('攻击!!怪物得到',kp,' 伤害!?!')
alife1:=alife1-kp
end
else begin
writeln('你无法攻击')
end
ka:=aatt-pre+random(aatt div 4)-aatt div 2
if ka>0 then begin
writeln('怪物攻击!!你得到',ka,' 伤害!?!')
plife:=plife-ka
end
else begin
writeln( ' 怪物无法攻击')
end
mp:=mp-30
end
else writeln('魔力不够!!')
end
procedure wall
var
ka,kp:integer
begin
if mp>=15 then begin
writeln
writeln
writeln('你用雷光!!!!')
writeln('怪物生命:',alife1)
writeln('你的生命:',plife,'/',plifemax)
kp:=(random(patt)-random(are))*26
if kp>0 then begin
writeln('攻击!!怪物得到',kp,' 伤害!?!')
alife1:=alife1-kp
end
else begin
writeln('你输了')
end
ka:=aatt-pre+random(aatt div 4)-aatt div 2
if ka>0 then begin
writeln('怪物攻击!!你得到',ka,' 伤害!?!')
plife:=plife-ka
end
else begin
writeln( ' 你赢了!!!!!')
end
mp:=mp-10
end
else writeln('生命不够!!')
end
procedure ball
var
ka,kp:integer
begin
if mp>=5 then begin
writeln
writeln
writeln('你用粉碎神拳!!!')
writeln('怪物生命:',alife1)
writeln('你的生命:',plife,'/',plifemax)
kp:=(random(patt)-random(are))*20
if kp>0 then begin
writeln('攻击!!怪物得到',kp,' 伤害!?!')
alife1:=alife1-kp
end
else begin
writeln('你输了')
end
ka:=aatt-pre+random(aatt div 4)-aatt div 2
if ka>0 then begin
writeln('怪物攻击!!你得到',ka,' 伤害!?!')
plife:=plife-ka
end
else begin
writeln( ' 你赢了!!!!!')
end
mp:=mp-10
end
else writeln('生命不够!!')
end
procedure magic
var
ma:integer
begin
writeln
writeln
writeln('1. 粉碎神拳 [5] 2. 雷光 [15] 3.破天一剑 [30]')
writeln('魔法值: ',mp,'/',mpmax)
read(ma)
case ma of
1:ball
2:wall
3:storm
end
end
procedure plusmoney
var
money1:longint
begin
money1:=random(alife)
writeln
writeln
writeln('你得到 $',money1)
money:=money1+money
end
procedure load
begin
close(na)
writeln
writeln
writeln('你的名字: ')
readln
readln(name)
fname:=concat(name,'.txt')
assign(na,fname)
reset(na)
readln(na,code)
writeln('输入密码:')
readln(co)
if co<>code then
begin
writeln('密码错误')
readln
halt
end
readln(na,plife)
readln(na,plifemax)
readln(na,patt)
readln(na,pre)
readln(na,ex)
readln(na,exmax)
readln(na,gr)
readln(na,money)
readln(na,mp)
readln(na,mpmax)
readln(na,red)
readln(na,blue)
readln(na,knife)
readln(na,clothes)
end
procedure save
var i:integer
begin
close(na)
assign(na,fname)
rewrite(na)
writeln(na,code)
writeln(na,plife)
writeln(na,plifemax)
writeln(na,patt)
writeln(na,pre)
writeln(na,ex)
writeln(na,exmax)
writeln(na,gr)
writeln(na,money)
writeln(na,mp)
writeln(na,mpmax)
writeln(na,red)
writeln(na,blue)
writeln(na,knife)
writeln(na,clothes)
writeln(na,godthing)
for i:=1 to godthing do writeln(god[i])
writeln
writeln
writeln('save successfully')
writeln
writeln
end
procedure seevar i:integer
begin
writeln('你的名字: ',name)
writeln('你的生命: ',plife,'/',plifemax)
writeln('攻击力: ',patt)
writeln('防御力: ',pre)
writeln('经验: ',ex)
writeln('升级经验',exmax)
writeln('级数: ',gr)
writeln('钞票:',money)
writeln('魔力: ',mp,'/',mpmax)
write('光之七神器:')for i:=1 to godthing do write(god[i],' ')
writeln
writeln('百宝箱:')
writeln('红色药丸:',red)
writeln('兰色药丸:',blue)
writeln('神剑:' ,knife)
writeln('防身衣:',clothes)
writeln
writeln
end
procedure people
begin
plife:=100
plifemax:=100
patt:=20
pre:=15
money:=100
gr:=1
ex:=0
exmax:=20
mp:=50
mpmax:=50
red:=5
blue:=5
knife:=0
clothes:=0
end
procedure old
var i:integer
begin
writeln('输入你的名字 :')
readln
readln(name)
fname:=concat(name,'.txt')
assign(na,fname)
reset(na)
readln(na,code)
writeln('输入密码:')
readln(co)
if co<>code then
begin
writeln('密码错误!')
readln
halt
end
readln(na,plife)
readln(na,plifemax)
readln(na,patt)
readln(na,pre)
readln(na,ex)
readln(na,exmax)
readln(na,gr)
readln(na,money)
readln(na,mp)
readln(na,mpmax)
readln(na,red)
readln(na,blue)
readln(na,knife)
readln(na,clothes)
readln(na,godthing)
for i:=1 to godthing do readln(god[i])
end
procedure new
var i:integer
begin
writeln( ' 输入你的名字: ')
readln
readln(name)
if name<>'0' then begin
fname:=concat(name,'.txt')
assign(na,fname)
rewrite(na)
writeln('输入密码')
readln(code)
writeln(na,code)
people
writeln(na,plife)
writeln(na,plifemax)
writeln(na,patt)
writeln(na,pre)
writeln(na,ex)
writeln(na,exmax)
writeln(na,gr)
writeln(na,money)
writeln(na,mp)
writeln(na,mpmax)
writeln(na,red)
writeln(na,blue)
writeln(na,knife)
writeln(na,clothes)
writeln(godthing)
for i:=1 to godthing do writeln(god[i])
end
else halt
end
procedure denlu
var
dl:byte
begin
writeln('-------------------自制的游戏不要笑----------------------')
writeln('-----------------------仅供娱乐----------------------')
writeln('1: 新游戏 2:老游戏 3:退出')
read(dl)
case dl of
1:new
2:old
3:halt
end
end
procedure godthing2
var
qi:integer
begin
randomize
qi:=random(50)
case qi of
0,8:begin
writeln('得到光之七神具----1:辟天宝剑')
writeln('攻击增加60点!!!')
patt:=patt+60
godthing:=godthing+1
god[godthing]:=1
end
3,16:begin
writeln('得到光之七神具----2:开地玄远剑')
writeln('攻击力*2')
patt:=patt*2
godthing:=godthing+1
god[godthing]:=2
end
end
end
procedure grow
begin
if ex>=exmax then begin
plife:=plifemax+50
plifemax:=plife
patt:=patt+15
pre:=pre+15
mpmax:=mpmax+30
mp:=mpmax
ex:=0
gr:=gr+1
exmax:=exmax+100
writeln('升级!!')
godthing2
writeln
writeln
end
end
procedure experience
begin
randomize
ex:=ex+random(alife)+30
grow
end
procedure attack
var
win,lost,run:boolean
ch,ff,kp,ka:integer
procedure winner
begin
win:=false
if alife1<1 then win :=true
end
procedure loster
begin
lost:=false
if plife<1 then lost:=true
end
begin
win:=false
lost:=false
run:=false
writeln('1:攻击2:逃跑')
writeln('你的生命:',plife,'/',plifemax)
writeln('你的魔法值: ',mp,'/',mpmax)
readln(ch)
if ch=1 then begin
alife1:=alife
repeat
writeln
writeln
writeln('1:物理¥攻击2:魔法¥攻击3:用百宝箱4.逃跑 ')
read(ff)
case ff of
1:begin
writeln
writeln
writeln
writeln
{}
kp:=random(patt)-random(are)
if kp>0 then begin
writeln('你攻击!!怪物受到',kp,' 伤害')
alife1:=alife1-kp
end
else begin
writeln('你输了')
end
ka:=random(aatt)-random(pre)
if ka>0 then begin
writeln('怪物攻击,你得到',ka,' 伤害')
plife:=plife-ka
end
else begin
writeln( '怪物输了')
end
writeln(' 怪物生命:',alife1)
writeln('你生命:',plife,'/',plifemax)
writeln('你的魔法值: ',mp,'/',mpmax)
end
2:begin
magic
end
3:begin
bag
end
4:begin
run:=true
writeln('逃跑失败')
end
end
winner
loster
until win or lost or run
if win then begin experienceplusmoneywriteln('你赢了!!!')writeln end
if lost then
begin
writeln('输了')
readln
halt
end
end
else exit
end
procedure animal
begin
alife:=plifemax+random(50)
if plifemax=100 then begin
aatt:=15
are:=10
end
else begin
aatt:=aatt+10
are:=are+7
end
attack
end
procedure meet
var
cc:integer
begin
randomize
cc:=random(100)
if cc<40 then begin
writeln
writeln('你遇见一个怪物')
animal
end
else writeln('没碰到.......')
end
procedure choose
begin
writeln('1:找怪物2:去商店3:读取4:保存5:退出 6:查看 7:用百宝箱')
read(dz)
case dz of
1:meet
2:shop
3:load
4:save
6:see
7:bag
end
end
begin
denlu
while dz<>5 do
choose
close(na)
end.
魔兽
当然可以了。编程序写到手腕酸到时候敲一个游戏进贺亏猜去是最好不过到啦。用空拿pascal有一点点麻烦,但是也是可以轻松实现的。不过用delphi更方便。
用pascal可以用面向禅型单元的程序,但是不怎么好看。给你一点样本代码吧。
俄罗斯方块:
USES Crt
CONST
Change:Array [0..6,0..3,0..7] Of Byte =(((0,1,1,1,2,1,3,1),(1,0,1,1,1,2,1,3),(0,1,1,1,2,1,3,1),(1,0,1,1,1,2,1,3)),
((1,0,0,1,1,1,2,1),(1,0,1,1,1,2,2,1),(0,1,1,1,2,1,1,2),(1,0,0,1,1,1,1,2)),
((1,0,2,0,1,1,2,1),(1,0,2,0,1,1,2,1),(1,0,2,0,1,1,2,1),(1,0,2,0,1,1,2,1)),
((1,0,2,0,0,1,1,1),(0,0,0,1,1,1,1,2),(1,0,2,0,0,1,1,1),(0,0,0,1,1,1,1,2)),
((0,0,1,0,1,1,2,1),(1,0,0,1,1,1,0,2),(0,0,1,0,1,1,2,1),(1,0,0,1,1,1,0,2)),
((1,0,2,0,1,1,1,2),(0,0,0,1,1,1,2,1),(1,0,0,2,1,1,1,2),(2,2,0,1,1,1,2,1)),
((0,0,1,0,1,1,1,2),(2,0,0,1,1,1,2,1),(2,2,1,0,1,1,1,2),(0,2,0,1,1,1,2,1)))
VAR
Board:Array [0..3,0..11,1..25] Of Byte
Players,N,Nowx,Nowy,Kind,Trans,Speed:Byte
Time,Score:Word
Now:Array [0..7] Of Byte
PROCEDURE Furbish
VAR B,C:Byte
Begin
For C:=24 Downto 2 Do Begin
Gotoxy(1,C)
For B:=1 To 10 Do
If Board[0,B,C]=0 Then Write(' ')
Else Write('圹')
End
End
PROCEDURE Clear
Var A,B,C:ByteD:Boolean
Begin
For A:=24 Downto 1 Do
Begin
D:=True
For B:=1 To 10 Do
If Board[0,B,A]=0 Then D:=False
If D=True Then
Begin
Score:=Score+10Gotoxy(1,1)Write(Score:5,'0')
For C:=A Downto 2 Do
For B:=1 To 10 Do
Board[0,B,C]:=Board[0,B,C-1]
A:=A+1
End
End
Furbish
End
FUNCTION Canmove(X,Y:Byte):Boolean
BEGIN
Canmove:=True
If Board[0,X+Now[0],Y+Now[1]]>0 Then Canmove:=False
If Board[0,X+Now[2],Y+Now[3]]>0 Then Canmove:=False
If Board[0,X+Now[4],Y+Now[5]]>0 Then Canmove:=False
If Board[0,X+Now[6],Y+Now[7]]>0 Then Canmove:=False
End
PROCEDURE Clean
Begin
Gotoxy((Nowx+Now[0])*2-1,Nowy+Now[1])Write(' ')
Gotoxy((Nowx+Now[2])*2-1,Nowy+Now[3])Write(' ')
Gotoxy((Nowx+Now[4])*2-1,Nowy+Now[5])Write(' ')
Gotoxy((Nowx+Now[6])*2-1,Nowy+Now[7])Write(' ')
End
PROCEDURE Show
Begin
Gotoxy((Nowx+Now[0])*2-1,Nowy+Now[1])Write('圹')
Gotoxy((Nowx+Now[2])*2-1,Nowy+Now[3])Write('圹')
Gotoxy((Nowx+Now[4])*2-1,Nowy+Now[5])Write('圹')
Gotoxy((Nowx+Now[6])*2-1,Nowy+Now[7])Write('圹')
End
BEGIN
Fillchar(Board,Sizeof(Board),0)
RandomizeScore:=0
For N:=1 To 24 Do
Board[0,0,N]:=1
For N:=1 To 24 Do
Board[0,11,N]:=1
For N:=1 To 10 Do
Board[0,N,25]:=1
Window(31,2,50,25)Textcolor(White)Textbackground(Blue)
ClrscrWindow(31,2,51,25)
Speed:=1
Kind:=Random(7)Trans:=Random(4)Nowx:=4Nowy:=1
For N:=0 To 7 Do
Now[N]:=Change[Kind,Trans,N]
While Canmove(Nowx,Nowy) Do
Begin
Repeat
CleanNowy:=Nowy+1Show
Repeat
If Keypressed Then
Case Upcase(Readkey) Of
#0:Case Readkey Of
#75:If Canmove(Nowx-1,Nowy) Then Begin CleanNowx:=Nowx-1ShowEnd
#77:If Canmove(Nowx+1,Nowy) Then Begin CleanNowx:=Nowx+1ShowEnd
#80:Begin CleanRepeat
If Canmove(Nowx,Nowy+1) Then Nowy:=Nowy+1
Until Not(Canmove(Nowx,Nowy+1))ShowEnd
#61:Begin Gotoxy(9,12)Write('Pause')Repeat Delay(1000)Until KeypressedFurbishEnd
End
#27:Exit
' ',#13:Begin
CleanTrans:=Trans+1
If Trans=4 Then Trans:=0
For N:=0 To 7 Do
Now[N]:=Change[Kind,Trans,N]
If Not(Canmove(Nowx,Nowy)) Then Begin Trans:=Trans-1For N:=0 To 7 Do
Now[N]:=Change[Kind,Trans,N]ShowEnd
Else Show
End
End
Until Not(Keypressed)
Delay((10-Speed)*50)
Until Not(Canmove(Nowx,Nowy+1))
Score:=Score+1Gotoxy(1,1)Write(Score:5,'0')Speed:=(Score Div 300)+1
Board[0,Nowx+Now[0],Nowy+Now[1]]:=1
Board[0,Nowx+Now[2],Nowy+Now[3]]:=1
Board[0,Nowx+Now[4],Nowy+Now[5]]:=1
Board[0,Nowx+Now[6],Nowy+Now[7]]:=1
Clear
Kind:=Random(7)Trans:=Random(4)Nowx:=4Nowy:=1
For N:=0 To 7 Do
Now[N]:=Change[Kind,Trans,N]
End
Gotoxy(7,12)Write('GAME OVER')Readln
END.
用于存放源代码,是记事本文件:第一个是,.exe文件这个不能叫软件,双击姿逗后可以运行,有用的有三个;第三个是仔册腊。其实这个编成的程序可以念滑用free pascal直接查看;第二个是,是备份的源代码.pas文件没有可以从.bak文件里找,也是记事本文件,是可执行文件,free pascal编写完后会自动在指定目录里生成几个文件.bak文件,也可以用上述的文件方法打开.pas文件欢迎分享,转载请注明来源:内存溢出
评论列表(0条)