Humphrey. Kim Hyun – Soo has a blog post up (in Korean) where he talks about the source code for a clone of the classic Snowcraft game that he found for Delphi XE5 Firemonkey. It looks like the source code originates from here. In any event Snowcraft is a game that originated in 1998 and became virally popular since then. In the game you have some green characters on one side of the screen and some red characters on the other side of the screen. They throw snowballs at each other and hide behind snow berms. Once all the characters on one side are out the game is over. This clone is most likely unauthorized and uses the original graphics so if you do anything with this source you should replace the graphics with your own. One interesting function that it uses is a PlaySound() function which takes a ResourceID and saves that sound file out to the temporary directory before playing it with the Delphi XE5 MediaPlayer component. The XE5 source code is built for Android but should also run on IOS without many if any changes. Running it in Delphi XE6 and AppMethod should also not be a problem The original blog is in Korean so you should use Google Chrome with it’s translate function to check it out if you don’t read Korean. Here is a sample of the PlaySound function:
procedure PlaySound(const ResourceID: String);
var
ResStream: TResourceStream;
TempFile, FileName: String;
begin
if MediaPlayer.State = TMediaState.Playing then Exit;
FileName := ResourceID + '_tmp.mp3';
TempFile := TPath.Combine( TPath.GetTempPath, FileName );
if not FileExists( TempFile ) then
begin
ResStream := TResourceStream.Create(HInstance, ResourceID, RT_RCDATA);
try
ResStream.SaveToFile( TempFile );
finally
ResStream.Free;
end;
end;
MediaPlayer.FileName := TempFile;
MediaPlayer.Play;
end;
Head over and check out the full blog post about the Delphi XE5 Firemonkey Snowcraft clone source code.
Mirror: Delphi XE5 Firemonkey SnowCraft Clone Source Code