its in a timer,
this is the code for all the timer, got some background movement bits in it as well:
procedure TFrmMainGame.Timer1Timer(Sender: TObject);
begin
begin {Right Background Loop}
if backgroundLeft.Top >0
then BackgroundLeft.Top:=-2015
else BackgroundLeft.Top:=BackgroundLeft.Top + 5;
end; {Right Background Loop}
Begin {Left Background Loop}
if backgroundRight.Top >0
then backgroundRight.Top:=-2015
else BackgroundRight.Top:=BackgroundRight.Top + 5;
end; {Left Background Loop}
RedDot1.Top:=RedDot1.Top + 5;
RedDot2.Top:=RedDot2.Top + 5;
Missile1.Top:=Missile1.top + 12;
Missile2.Top:=Missile2.top + 12;
{stops plane from going off left hand side of screen}
if planeimage.left<144 then planeimage.left:=144;
{stops plane from going off right hand side of screen}
if planeimage.left>520 then planeimage.Left:=520;
{stops plane from going off the top of thescreen}
if planeimage.top<1 then planeimage.Top:=1;
{stops plane from going off bottom of the screen}
if planeimage.top>562 then planeimage.top:= 562;
{GameOver Sequence}
If Gameover = True then
begin
TimerMovement.Enabled:=False;
Missile1Timer.Enabled:=False;
Missile2Timer.Enabled:=False;
RedDot1Timer.Enabled:=False;
RedDot2Timer.Enabled:=False;
LblGameOver.Visible:=True;
{HighScores}
AssignFile(ScoresFile, 'Scores.dat'); {assigns the variable 'Scores File' to the file 'Scores.dat' on the HDD}
reset(ScoresFile); {resets the file pointer to the begining of the file}
i := 1;
while not eof(ScoresFile)do
begin
read (ScoresFile, HighScoresData);
HighScore[i] := HighScoresData;
i := i + 1;
end;
if Score > HighScore[10].Score then {if player's score is greater than the 10th highscore than the player's score becomes the 10th highscore}
begin
HighScore[10].Score:=Score;
HighScore[10].Name:=InputBox('HighScores', 'Congradulations you got a high score!', 'Enter your name here'); {player's name is entered into the record}
HighScoresCont := true; {condition to start the sorting process is set to true}
while HighScoresCont do {while the highscorescont is true the program will sort the highscores from highest to lowest}
begin
HighScoresCont := false;
for HSSort:= 1 to 10 do
if HighScore[HSSort].Score < HighScore[HSSort+1].Score
then begin
HSTemp := HighScore[HSSort].Score;
HighScore[HSSort].Score := HighScore[HSSort+1].Score;
HighScore[HSSort+1].Score := HSTemp;
HighScoresCont := true;
end; {if}
end; {while}
Inputname:=True; {condition to allow option to view highscores}
Rewrite(ScoresFile); {resets the file pointer to the begining of the file}
write(ScoresFile, HighScoresData); {the highscores record is written to disk} {this line is highlighted in blue when the error message occurs}
end; {if get highscore greater than highscore[10]}
closefile(ScoresFile);
if InputName = True then {if name has been entered then option to view highscores is given to the player}
begin
InputName:=False;
ViewHS := MessageDLg('Do you want to view highscores?', mtConfirmation, [mbYes, mbNo], 0) = mrYes;
if ViewHS then
begin
FrmHighScores.show;
FrmMainGame.Visible:=False;
end;
end;
end;
end;