The ball (asterisk) wont move =/
{*** Made by Code4fun ***}
Program DamnBall;
Uses crt;
const
ANP = 79;
ALP = 24;
MIN=1;
ALT=3;
ANC=4;
Time=100;
Var
PosX,PosY,Dx,Dy:integer;
Procedure DP(pX,pY:integer); {this draws the ball (asterisk)}
BEGIN
Gotoxy (pX,pY); write('*');
Delay (kk);
Gotoxy (pX,pY); write(' ');
END;
Procedure VP(pX,pY,dirx,diry:integer); {this makes the ball move}
BEGIN
px:=px+dirx;
py:=py+diry;
DP(pX,pY);
END;
Begin {From Here is the code that makes the ball bounce with the walls/top/floor
and call the procedures to draw and make it move}
ClrScr;
cursoroff;
PosX := MIN;
PosY := MIN;
Dx:=1;
Dy:=1;
Begin
IF (PosX <> ANP) AND (PosY <> ALP) AND (PosX <> MIN) AND (PosY <> MIN) THEN
VP(PosX,PosY,Dx,Dy)
ELSE IF (PosX = ANP) AND (PosY <> ALP) AND (PosY <> MIN) THEN
BEGIN
Dx:= Dx*(-1);
VP(PosX,PosY,Dx,Dy);
END
ELSE IF (PosX <> ANP) AND (PosY = ALP) AND (PosX <> MIN) THEN
BEGIN
Dy:= Dy*(-1);
VP(PosX,PosY,Dx,Dy);
END
ELSE IF (PosX = ANP) AND (PosY = ALP) THEN
BEGIN
Dx:= Dx*(-1);
Dy:= Dy*(-1);
VP(PosX,PosY,Dx,Dy);
END
ELSE IF (PosX = MIN) AND (PosY <> ALP) AND (PosY <> MIN) THEN
BEGIN
Dx:= Dx*(-1);
VP(PosX,PosY,Dx,Dy);
END
ELSE IF (PosX <> MIN) AND (PosY = MIN) AND (PosX <> MIN) THEN
BEGIN
Dy:= Dy*(-1);
VP(PosX,PosY,Dx,Dy);
END
ELSE IF (PosX = MIN) AND (PosY = MIN) THEN
BEGIN
Dy:= Dy*(-1);
Dx:= Dx*(-1);
VP(PosX,PosY,Dx,Dy);
END;
END
END.