Tin học Game viết bằng pascal

dangxuanchuon

Học sinh
Thành viên
31 Tháng bảy 2022
72
39
36
Phú Yên
[TẶNG BẠN] TRỌN BỘ Bí kíp học tốt 08 môn
Chắc suất Đại học top - Giữ chỗ ngay!!

ĐĂNG BÀI NGAY để cùng trao đổi với các thành viên siêu nhiệt tình & dễ thương trên diễn đàn.

code:
Mã:
program game;
uses crt;
var a, b, c, d, e, f: array [-1..12] of byte;
g, taocgvat1, taocgv2, i, kq, luot, scfd: byte;
soluot: integer;
maxi: longword;
phim: string;
begin;
clrscr;
maxi:=32768;
f[12]:=2;
        while ((a[1]=2) or (a[2]=2) or (a[3]=2) or (a[4]=2) or (a[5]=2) or (a[6]=2) or (a[7]=2) or (a[8]=2) or (a[9]=2) or (a[10]=2) or (a[11]=2) or (a[12]=2) or
        (b[1]=2) or (b[2]=2) or (b[3]=2) or (b[4]=2) or (b[5]=2) or (b[6]=2) or (b[7]=2) or (b[8]=2) or (b[9]=2) or (b[10]=2) or (b[11]=2) or (b[12]=2) or
        (c[1]=2) or (c[2]=2) or (c[3]=2) or (c[4]=2) or (c[5]=2) or (c[6]=2) or (c[7]=2) or (c[8]=2) or (c[9]=2) or (c[10]=2) or (c[11]=2) or (c[12]=2) or
        (d[1]=2) or (d[2]=2) or (d[3]=2) or (d[4]=2) or (d[5]=2) or (d[6]=2) or (d[7]=2) or (d[8]=2) or (d[9]=2) or (d[10]=2) or (d[11]=2) or (d[12]=2) or
        (e[1]=2) or (e[2]=2) or (e[3]=2) or (e[4]=2) or (e[5]=2) or (e[6]=2) or (e[7]=2) or (e[8]=2) or (e[9]=2) or (e[10]=2) or (e[11]=2) or (e[12]=2) or
        (f[1]=2) or (f[2]=2) or (f[3]=2) or (f[4]=2) or (f[5]=2) or (f[6]=2) or (f[7]=2) or (f[8]=2) or (f[9]=2) or (f[10]=2) or (f[11]=2) or (f[12]=2)) and (kq<>1) and (phim<>'e') and (soluot<maxi) do
                begin
                soluot:=soluot+1;
                if soluot mod 6 = 1 then
                for taocgv2 := 1 to 3 do
                        begin
                        taocgvat1:=random(6)+1;
                        if taocgvat1=1 then a[1]:=1;
                        if taocgvat1=2 then b[1]:=1;
                        if taocgvat1=3 then c[1]:=1;
                        if taocgvat1=4 then d[1]:=1;
                        if taocgvat1=5 then e[1]:=1;
                        if taocgvat1=6 then f[1]:=1;
                        end;
                writeln(' ', a[1], ' ', a[2], ' ', a[3], ' ', a[4], ' ', a[5], ' ', a[6], ' ', a[7], ' ', a[8], ' ', a[9], ' ', a[10], ' ', a[11], ' ', a[12]);
                writeln(' ', b[1], ' ', b[2], ' ', b[3], ' ', b[4], ' ', b[5], ' ', b[6], ' ', b[7], ' ', b[8], ' ', b[9], ' ', b[10], ' ', b[11], ' ', b[12]);
                writeln(' ', c[1], ' ', c[2], ' ', c[3], ' ', c[4], ' ', c[5], ' ', c[6], ' ', c[7], ' ', c[8], ' ', c[9], ' ', c[10], ' ', c[11], ' ', c[12]);
                writeln(' ', d[1], ' ', d[2], ' ', d[3], ' ', d[4], ' ', d[5], ' ', d[6], ' ', d[7], ' ', d[8], ' ', d[9], ' ', d[10], ' ', d[11], ' ', d[12]);
                writeln(' ', e[1], ' ', e[2], ' ', e[3], ' ', e[4], ' ', e[5], ' ', e[6], ' ', e[7], ' ', e[8], ' ', e[9], ' ', e[10], ' ', e[11], ' ', e[12]);
                writeln(' ', f[1], ' ', f[2], ' ', f[3], ' ', f[4], ' ', f[5], ' ', f[6], ' ', f[7], ' ', f[8], ' ', f[9], ' ', f[10], ' ', f[11], ' ', f[12], '   luot(diem): ', soluot);
                readln(phim);
                while (phim<>'w') and (phim<>'s') and (phim<>'a') and (phim<>'d') and (phim<>'e') and (phim<>'g') do
                        begin
                        if phim='h' then
                                begin
                                writeln('w: di len, s: di xuong, a: qua trai, d: qua phai, g: dung yen, e: thoat, h: tro giup (hien cai nay); enter de tiep tuc');
                                write('dieu kien so 2, neu duong so 1 thi thua');
                                readln;
                                end;
                        writeln('chon lai:');
                        readln(phim);
                        end;
                if phim='w' then
                        begin
                        for i:= 1 to 12 do
                                begin
                                if b[i]=2 then if a[i]=1 then kq:=1 else
                                        begin
                                        g:=b[i];
                                        b[i]:=a[i];
                                        a[i]:=g;
                                        end;
                                if c[i]=2 then if b[i]=1 then kq:=1 else
                                        begin
                                        g:=c[i];
                                        c[i]:=b[i];
                                        b[i]:=g;
                                        end;
                                if d[i]=2 then if c[i]=1 then kq:=1 else
                                        begin
                                        g:=d[i];
                                        d[i]:=c[i];
                                        c[i]:=g;
                                        end;
                                if e[i]=2 then if d[i]=1 then kq:=1 else
                                        begin
                                        g:=e[i];
                                        e[i]:=d[i];
                                        d[i]:=g;
                                        end;
                                if f[i]=2 then if e[i]=1 then kq:=1 else
                                        begin
                                        g:=f[i];
                                        f[i]:=e[i];
                                        e[i]:=g;
                                        end;
                                end;
                        end;
                if phim='s' then
                        begin
                        for i:= 1 to 12 do
                                begin
                                if e[i]=2 then if f[i]=1 then kq:=1 else
                                        begin
                                        g:=e[i];
                                        e[i]:=f[i];
                                        f[i]:=g;
                                        end;
                                if d[i]=2 then if e[i]=1 then kq:=1 else
                                        begin
                                        g:=d[i];
                                        d[i]:=e[i];
                                        e[i]:=g;
                                        end;
                                if c[i]=2 then if d[i]=1 then kq:=1 else
                                        begin
                                        g:=c[i];
                                        c[i]:=d[i];
                                        d[i]:=g;
                                        end;
                                if b[i]=2 then if c[i]=1 then kq:=1 else
                                        begin
                                        g:=b[i];
                                        b[i]:=c[i];
                                        c[i]:=g;
                                        end;
                                if a[i]=2 then if b[i]=1 then kq:=1 else
                                        begin
                                        g:=a[i];
                                        a[i]:=b[i];
                                        b[i]:=g;
                                        end;
                                end;
                        end;
                if phim='a' then
                        begin
                        for i:=2 to 12 do
                                begin
                                if a[i]=2 then if a[i-1]=1 then kq:=1 else
                                        begin
                                        a[i]:=0;
                                        a[i-1]:=2;
                                        end;
                                if b[i]=2 then if b[i-1]=1 then kq:=1 else
                                        begin
                                        b[i]:=0;
                                        b[i-1]:=2;
                                        end;
                                if c[i]=2 then if c[i-1]=1 then kq:=1 else
                                        begin
                                        c[i]:=0;
                                        c[i-1]:=2;
                                        end;
                                if d[i]=2 then if d[i-1]=1 then kq:=1 else
                                        begin
                                        d[i]:=0;
                                        d[i-1]:=2;
                                        end;
                                if e[i]=2 then if e[i-1]=1 then kq:=1 else
                                        begin
                                        begin
                                        e[i]:=0;
                                        e[i-1]:=2;
                                        end;
                                        end;
                                if f[i]=2 then if f[i-1]=1 then kq:=1 else
                                        begin
                                        f[i]:=0;
                                        f[i-1]:=2;
                                        end;
                                end;
                        end;
                if phim='d' then
                        begin
                        for i:=1 to 11 do
                                begin
                                if (a[i]=2) and (scfd=0) then if a[i+1]=1 then kq:=1 else
                                        begin
                                        a[i]:=0;
                                        a[i+1]:=2;
                                        scfd:=1;
                                        end;
                                if (b[i]=2) and (scfd=0) then if b[i+1]=1 then kq:=1 else
                                        begin
                                        b[i]:=0;
                                        b[i+1]:=2;
                                        scfd:=1;
                                        end;
                                if (c[i]=2) and (scfd=0) then if c[i+1]=1 then kq:=1 else
                                        begin
                                        c[i]:=0;
                                        c[i+1]:=2;
                                        scfd:=1;
                                        end;
                                if (d[i]=2) and (scfd=0) then if d[i+1]=1 then kq:=1 else
                                        begin
                                        d[i]:=0;
                                        d[i+1]:=2;
                                        scfd:=1;
                                        end;
                                if (e[i]=2) and (scfd=0) then if e[i+1]=1 then kq:=1 else
                                        begin
                                        e[i]:=0;
                                        e[i+1]:=2;
                                        scfd:=1;
                                        end;
                                if (f[i]=2) and (scfd=0) then if f[i+1]=1 then kq:=1 else
                                        begin
                                        f[i]:=0;
                                        f[i+1]:=2;
                                        scfd:=1;
                                        end;
                                end;
                        scfd:=0;
                        end;
                if a[12]<>2 then a[12]:=0;
                if b[12]<>2 then b[12]:=0;
                if c[12]<>2 then c[12]:=0;
                if d[12]<>2 then d[12]:=0;
                if e[12]<>2 then e[12]:=0;
                if f[12]<>2 then f[12]:=0;
                for i:= 1 to 12 do
                        begin
                        if a[12-i]=1 then begin a[13-i]:=a[12-i]; a[12-i]:=0; end;
                        if b[12-i]=1 then begin b[13-i]:=b[12-i]; b[12-i]:=0; end;
                        if c[12-i]=1 then begin c[13-i]:=c[12-i]; c[12-i]:=0; end;
                        if d[12-i]=1 then begin d[13-i]:=d[12-i]; d[12-i]:=0; end;
                        if e[12-i]=1 then begin e[13-i]:=e[12-i]; e[12-i]:=0; end;
                        if f[12-i]=1 then begin f[13-i]:=f[12-i]; f[12-i]:=0; end;
                        end;
                clrscr;
                end;
if phim='e' then
        begin
        textcolor(1);
        writeln('ban da dau hang!');
        end;
if (kq=1) and (soluot=32767) then
        begin
        textcolor(red);
        writeln('ban da duoc 32767 va la so diem toi da! nhung ban da thua ngay luot cuoi!');
        end;
if (kq=0) and (soluot=32767) then
        begin
        textcolor(yellow);
        writeln('ban da qua het tat ca 32767 so man!!!!!!!');
        end;
if soluot<32767 then writeln('ban da duoc ', soluot, ' diem!');
readln;
end.
cách chơi game:
điêu khiên số 2 bằng các nhấn nút a(trái), w(lên), d(phải), s(xuống), g(đứng yên), h(trợ giúp), e(thoát game) rồi enter
nếu trúng số 1 thì sẽ thua
cứ 6 màn (số màn chia 6 dư 1) sẽ cho thếm 1-3 số 1
các số 1 sẽ đi qua trái mỗi lượt (vận tốc bằng số 2)
(giao diện không đẹp nhưng sẽ làm chính thức đẹp hơn, để đây để báo cáo lỗi)
 
Top Bottom