Darmowe Forum

Turbo Pascal => Podstawy Turbo Pascal => Wątek zaczęty przez: admin Listopad 22, 2010, 10:41:08



Tytuł: Dodatki i inne bajery
Wiadomość wysłana przez: admin Listopad 22, 2010, 10:41:08
Polecenie readkey;
Polecenie odczytuje z klawiatury kod wciśniętego klawisza bez konieczności zatwierdzania poleceniem ENTER. Należy pamiętać, że polecenie readkey odczytuje tylko jeden znak. Nie jest w stanie odczytać ciągu znaków.

Przykład składni:
var a:char;
begin
a:=readkey;
end.
Program reagujący na klawisze

program lizak;
uses crt,dos;
var z:char;
x,y:integer;
begin
x:=10;y:=10; clrscr;
repeat
gotoxy(x,y); write('A');
z:=readkey;
if z='p' then y:=y-1;
if z='l' then y:=y+1;
if z='a' then x:=x-1;
if z='s' then x:=x+1;
 clrscr;
until z='q';
readkey;


Tytuł: Odp: Dodatki i inne bajery
Wiadomość wysłana przez: admin Listopad 22, 2010, 11:39:15
Zadanie1. Program przemieszczający literę 'A' po ekranie (p-góra, l-dół, a-lewo, s-prawo). Program nie pozwala na przesunięcie litery poza ekran.

program rebacz;
uses crt,dos;
var z:char;
x,y:integer;
begin
x:=10;y:=10; clrscr;
repeat
gotoxy(x,y); write('A'); gotoxy(60,1);write('x=',x,'y= ',y);
z:=readkey;
if z='p' then begin if (y>1) then y:=y-1 else y:=y; end;
if z='l' then begin if (y<25) then y:=y+1 else y:=y; end;
if z='a' then begin if (x>1) then x:=x-1 else x:=x; end;
if z='s' then begin if (x<60) then x:=x+1 else x:=x; end;
 clrscr;
until z='q';

end.


Tytuł: Odp: Dodatki i inne bajery
Wiadomość wysłana przez: admin Listopad 22, 2010, 12:28:35
Zadanie1b - wersja half full wypas

program rebacz;
uses crt,dos;
var z:char;
x,y:integer;
begin
x:=10;y:=10; clrscr;
repeat
gotoxy(x,y); write('A'); gotoxy(60,1);write('x=',x,'y= ',y);
 gotoxy(20,20);write('B'); textbackground(green);
z:=readkey;

if z='p' then begin if (y>1) then y:=y-1 else y:=y; end;
if z='l' then begin if (y<25) then y:=y+1 else y:=y; end;
if z='a' then begin if (x>1) then x:=x-1 else x:=x; end;
if z='s' then begin if (x<60) then x:=x+1 else x:=x; end;
if(x=20) then begin if y=20 then textbackground(red)end ;
 clrscr;
until z='q';

end.


Polityka cookies
Darmowe Fora | Darmowe Forum

bezludna-wyspa realbestplaymta watahafernflower unihokej maxplaying