Delphi GameDev: Fun Multi-Platform Mars Rocket Game For Android, iOS, macOS, And Windows

FireWind

Свой
Регистрация
2 Дек 2005
Сообщения
1,957
Реакции
1,203
Credits
4,034
GameDev: Fun Multi-Platform Mars Rocket Game For Android, iOS, macOS, And Windows
March 1, 2021 By Muminjon

FireMonkey offers you to build complex and advanced cross-platform applications. From business applications to games. On the GetIt portal, you can find dozens of sample applications. Today we will explore the Mars Rocket classic arcade game. In this game, the player must collect points and land the rocket without crashing. On each level, 3 stars are randomly placed throughout the game screen which you can collect for more points. Delphi 10.4 brought with it Для просмотра ссылки Войди или Зарегистрируйся and it is enabled in this game.
1614672678455.png
When you start discovering the building patterns in the game you can easily learn how to build similar games with Delphi FireMonkey. Moreover, you can learn more about mobile development and audio and animation tricks with FireMonkey.
Код:
procedure TGameForm.PlayerHit;
begin
  CreateExplosion(Ship.Position.X + (Ship.Width / 2),
    Ship.Position.Y + (Ship.Height / 2));
  Ship.Visible := False;
  PlayerData.Lives := PlayerData.Lives - 1;
  PlayerData.SpeedX := 0;
  PlayerData.SpeedY := 0;
  PlayerData.VerticalVelocity := 0;
  PlayerData.HorizontalVelocity := 10;
  Ship.RotationAngle := 45;
  DisplayLives(PlayerData.Lives);
  if PlayerData.Lives > 0 then
  begin
    CenterPlayer;
    PlaySound(FAIL_SFX);
  end;
end;
 
procedure TGameForm.DisplayScore;
begin
  ScoreLBL.Text := IntToStr(PlayerData.Score);
end;
 
procedure TGameForm.DelayedSettingsTimer(Sender: TObject);
begin
  if (FileExists(DataFilePath + MUSIC_FILENAME) AND (MusicPlayer.Filename='')) then
    begin
      try
        MusicPlayer.Filename := DataFilePath + MUSIC_FILENAME;
      except on E: Exception do
       begin
        ShowMsgBox('Music failed to load: ' + E.Message);
       end;
      end;
    end;
 
  if HostEnabled = True then
    begin
      if NetworkConnected=True then
       begin
        ToggleAppTethering(True);
       end;
    end
  else
    begin
     ToggleAppTethering(False);
    end;
  DelayedSettings.Enabled := False;
end;