Darmowe Forum
Maj 04, 2024, 14:40:11 *
Witamy, Gość. Zaloguj się lub zarejestruj.
Czy dotarł do Ciebie email aktywacyjny?

Zaloguj się podając nazwę użytkownika, hasło i długość sesji
Aktualności: Forum zostało uruchomione!
 
   Strona główna   Pomoc Zaloguj się Rejestracja  
Strony: [1]
  Drukuj  
Autor Wątek: Dodatki i inne bajery  (Przeczytany 2399 razy)
admin
Administrator
Ekspert
*****
Wiadomości: 821


Email
« : 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;
« Ostatnia zmiana: Listopad 22, 2010, 11:13:07 wysłane przez admin » Zapisane
admin
Administrator
Ekspert
*****
Wiadomości: 821


Email
« Odpowiedz #1 : 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.
« Ostatnia zmiana: Listopad 22, 2010, 12:19:28 wysłane przez admin » Zapisane
admin
Administrator
Ekspert
*****
Wiadomości: 821


Email
« Odpowiedz #2 : 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.
« Ostatnia zmiana: Listopad 22, 2010, 12:34:26 wysłane przez admin » Zapisane
Strony: [1]
  Drukuj  
 
Skocz do:  

Powered by SMF 1.1.11 | SMF © 2006-2008, Simple Machines LLC | Sitemap

Polityka cookies
Darmowe Fora | Darmowe Forum

basicrpg forumszkoly luksburg watahaloup watahacemnejstrony