Trang chủ Tin Học Lớp 8 làm cho mình 1 dự án ngôn ngũ lập trình(tạo...

làm cho mình 1 dự án ngôn ngũ lập trình(tạo 1 game) rắn săn mồi nha giúp mình please câu hỏi 1525042 - hoctapsgk.com

Câu hỏi :

làm cho mình 1 dự án ngôn ngũ lập trình(tạo 1 game) rắn săn mồi nha giúp mình please

Lời giải 1 :

program ransanmoi;
uses crt,dos;
var ran:array[1..100] of record x,y:byte; end;
x,y,x1,y1,L,huong:byte;
tocdo,diem:integer;
kt:char;
die:boolean;

procedure setcusor(bot,top:byte);
var regs:registers;
begin
regs.ah:=1;
regs.ch:=bot;
regs.cl:=top;
end;

procedure ngaunhien;
begin
x1:=random(30)+5;
y1:=random(20)+2;
kt:=chr(random(25)+65);
gotoxy(x1,y1);
write(kt);
end;
{
procedure vekhung;
var j:byte;
begin
clrscr;
textcolor(white);
gotoxy(1,1);
for j:=1 to 40 do write(#177);
gotoxy(1,24);
for j:=1 to 40 do write(#177);
for j:=2 to 23 do
begin
gotoxy(1,j);
writeln(#177);
gotoxy(40,j);
write(#177);
end;
gotoxy(8,24);
textcolor(lightred);
writeln('Nhan ESC de thoat');
end;
}

procedure ranchay;
var rk:char;
begin
if keypressed then
begin
rk:=readkey;
if rk=#27 then halt(1);
if rk=#0 then rk:=readkey;
huong:=ord(rk);
end;
case huong of
80:inc(y); {di xuong}
72:dec(y); {di len}
77:inc(x); {qua phai}
75:dec(x); {qua trai}
end;
if (y=1)or(y=24)or(x=40)or(x=1) then die:=true;
end;

procedure init;
var j:byte;
begin
randomize;
textmode(co40);
tocdo:=150;
diem:=0;
{vekhung;    }
l:=3;
x:=10;
y:=10;
for j:=1 to l+1 do
begin
ran[j].x:=30+j;
ran[j].y:=10;
end;
ngaunhien;
setcusor(32,3);
die:=false;
end;

procedure thuchien;
var i:byte;
begin
init;
i:=4;
repeat
ranchay;
dec(i);
gotoxy(ran[i].x,ran[i].y);
write(' ');
ran[i].x:=x;
ran[i].y:=y;
textcolor(lightred);
gotoxy(4,1);
write(' DIEM ',diem);
if (diem>0) and (diem mod 200=0) then
begin
diem:=diem+50;
gotoxy(6,12);
textcolor(white);
textbackground(red);
writeln(' MOI BAN TIEP TUC ');
repeat until keypressed;
textbackground(0);
clrscr;
{vekhung;}
if tocdo>=100 then tocdo:=tocdo-50;
if diem>=400 then l:=3;
i:=l;
end;
if (x=x1)and(y=y1) then
begin
l:=l+1;
ngaunhien;
diem:=diem+10;
end;
gotoxy(x1,y1);
write(kt);
textcolor(lightcyan);
gotoxy(ran[i].x,ran[i].y);
write({#219}'*');
if i=1 then i:=l+1;
delay(tocdo);
until die;
gotoxy(15,11);
write(' BAN DA THUA ');
gotoxy(5,12);
write(' Nhan phim bat ki de choi tiep ');
end;

BEGIN

repeat    
clrscr;   
thuchien;    
kt:=readkey;   
until kt=#27;  
clrscr;         
END.          

Thảo luận

Bạn có biết?

Tin học, tiếng Anh: informatics, tiếng Pháp: informatique, là một ngành khoa học chuyên nghiên cứu quá trình tự động hóa việc tổ chức, lưu trữ, xử lý và truyền dẫn thông tin của một hệ thống máy tính cụ thể hoặc trừu tượng (ảo). Với cách hiểu hiện nay, tin học bao hàm tất cả các nghiên cứu và kỹ thuật có liên quan đến việc mô phỏng, biến đổi và tái tạo thông tin.

Nguồn : Wikipedia - Bách khoa toàn thư

Tâm sự 8

Lớp 8 - Năm thứ ba ở cấp trung học cơ sở, học tập bắt đầu nặng dần, sang năm lại là năm cuối cấp áp lực lớn dần nhưng các em vẫn phải chú ý sức khỏe nhé!

Nguồn : ADMIN :))

Liên hệ hợp tác hoặc quảng cáo: gmail

Điều khoản dịch vụ

Copyright © 2021 HOCTAPSGK