Hello everyone, I have sort of a problem. I am student of technical school and for our finish exam in programming we got make a game. So games are not hard to make, but I got real confused. I need to make a person who is running and picking apples, but there are some type of ghosts or animals. When the character picks apples, the energy increases and when ghost catches him it loses energy. Here is the code since where I encountered error and then I will explain the problem:
repeat
outtextxy(150,10,'energy=100');
if (x=x1) and (y=y1) then
draw3
else
begin
draw2;
end;
k:=readkey;
cleardevice;
case k of
'a':begin
x:=x-10;
draw;
dec(energija);
end;
'd':begin
x:=x+10;
draw;
dec(energija);
end;
's':begin
y:=y+10;
draw;
dec(energy);
end;
'w':begin
y:=y-10;
draw;
dec(energy);
end;
end;
until (k='k');
closegraph;
end.
Energy is not yet functional, but the problem is with apples. Draw3 draws a black apple (not visible on the screen), draw2 draws a green apple. So when I move the character arround draw2 draws green apple. When I put my character over the draw3 (x and y are coordinates of character; x1 and y1 are coordinates of apple) apple should disappear, but it is not happening.
Can anyone help me? If you help me with this code, please, write your own or just give me some suggestion. Thanks!