Меню сайта

Задача №16

Управление точкой на экране.

uses graph,crt-

vargd,gm,x,y,x1,y1:integer-

— — — c:char-

label 0,1,2,3,4-

begin

initgraph(gd,gm,’c:&#92-bp&#92-bgi’)-

y:= 50-

x:= 50-

outtext(‘Press up,down, left ,right aroow keys for moving the point’)-

outtextxy(10,10,’PressEsc to Exit’)-

0:

c:=readkey-

if c=chr(27) thenhalt-

if ord(c)=72 thengoto 1-

if ord(c)=80 thengoto 2-

if ord(c)=75 thengoto 3-

if ord(c)=77 thengoto 4-

GOTO 0-

1:

y := y — 1-

IF y &lt- 1 THENy:= 2-

putpixel(x1, y1,0)-

putpixel(x, y, 15)-

x1 := x- y1 := y-

goto 0-

2:

putpixel(x, y, 0)-

y := y + 1-

IF y &gt- 479 THENy := 478-

putpixel (x1, y1,0)-

putpixel (x, y,15)-

x1 := x- y1 := y-

goto 0-

3:

x := x — 1-

IF x &lt- 1 THEN x:= 2-

putpixel(x1, y1,0)-

putpixel (x, y,15)-

x1 := x- y1 := y-

goto 0-

4:

x := x + 1-

IF x &gt- 639 THENx := 638-

putpixel (x1, y1,0)-

putpixel (x, y,15)-

x1:= x- y1 := y-

goto 0-

end.

Категория: Графика в Паскале | Дата: 24.11.12

Меню раздела
Блок