Hey, I’ve been messing with pascal lately and I’m stuck at one point, thought that you guys could help me.
So the thing, that I want to do is, while a person is pressing a desired key the circle would move, when he stops doing that, it will stop. I don’t know why, but I can’t get it right, could you guys look at my little project ant tell me what’s wrong? Thanks.
program programa;
uses graph, crt;
label pradžia;
var
x, y, z: integer;
key: char;
procedure grafika;
var gt, gb: integer;
begin
gt := Detect;
InitGraph (gt, gb, ‘C:\TP\BGI\’)
end;
begin
grafika;
x := 980;
y := 500;
z := 30;
pradžia:
SetColor (yellow);
Circle (x, y, z);
SetFillStyle (SolidFill, yellow);
FloodFill (x, y, yellow);
key := ReadKey;
if (key = #97) then
begin
inc(x);
GoTo pradžia;
end;
readln; readln;
First NEVER code labels in Pascal since the language was developed to enable structured programming theory also known as “GOTOless Programming”.
Second your circle’s center is out of graphic window since the origin is at the left upper corner (0,0) and y is downward.
Here the working code ;