From Clomosy Docs

(Created page with "TclGameForm is a customized game form design for Clomosy. Here you can use features such as animation and sound effects. Now, to create the form, it is necessary to define. MyGameForm:TclGameForm; Now we need to add and run the form before giving properties to the form. begin MyGameForm := TclGameForm.Create(Self); ... MyGameForm.Run; End;")
 
No edit summary
Line 10: Line 10:
   MyGameForm.Run;
   MyGameForm.Run;
  End;
  End;
Documents taken from url addresses are added to the form with the "AddGameAssetFromUrl" parameter. For example; such as background and animation images, sound file.<br>
MyForm.AddGameAssetFromUrl('https://www.clomosy.com/game/assets/Tank.png');
After adding the images, these images can be transferred to a component (TclProImage, TclImage). The transfer method is as follows:<br>
ImgTank.clSetImage('Tank.png');
We can use animation and sound effects in TclGameForm. <br>
:<span style="color:blue">How to Animation?</span>
It is making a movie by showing animated pictures and still objects as if they are moving. This is how we make the pictures added on Clomosy animated.
You can set the animation height and width on the form. For this:<br>
MyGameForm.AnimationWidth := 75;
MyGameForm.AnimationHeight := 75;
If you want to give the number of animations:
MyGameForm.clAnimateBitmap.AnimationCount :=9;
To adjust the number of animation lines:
MyGameForm.clAnimateBitmap.AnimationRowCount:=3;
You can set the animation delay time on the form.
MyGameForm.clAnimateBitmap.Delay := 10;
You can set the animation duration time on the form.
MyGameForm.clAnimateBitmap.Duration := 2;
Now the "clAnimation" parameter is used so that we can show the animation on our screen. This parameter takes 4 values. (x_position,y_position,integer_value, animation_document)<br>
Random() is used below to set a random location.
MyGameForm.clAnimation(Random() * TForm(MyGameForm).ClientWidth, Random() * TForm(MyGameForm).ClientHeight, 20, 'Explosion.png');
'''Example:'''<br>
'''var'''
  MyGameForm:TclGameForm;
  BtnRandomFire:TclButton;
  '''Procedure''' BtnRandomFireClick;
  '''var'''
    i:Integer;
  '''begin'''
    MyGameForm.AnimationWidth := 75;
    MyGameForm.AnimationHeight := 75;
    MyGameForm.clAnimateBitmap.AnimationCount :=9;
    MyGameForm.clAnimateBitmap.AnimationRowCount:=3;
    MyGameForm.clAnimateBitmap.Delay := 10;
    MyGameForm.clAnimateBitmap.Duration := 2;
    For i:=0 to 5 do
    Begin
      MyGameForm.clAnimateBitmap.Delay := Random()*10;
      MyGameForm.clAnimation(Random() * TForm(MyGameForm).ClientWidth, Random() * TForm(MyGameForm).ClientHeight, 20, 'Explosion.png');           
    End;
  '''End;'''
'''begin'''
  MyGameForm := TclGameForm.Create(Self);
  MyGameForm.AddGameAssetFromUrl('https://www.clomosy.com/game/assets/Explosion.png');
 
  BtnRandomFire:= MyGameForm.AddNewButton(MyGameForm,'BtnRandomFire','RANDOM FIRE');
  MyGameForm.AddNewEvent(BtnRandomFire,tbeOnClick,'BtnRandomFireClick');
  BtnRandomFire.Align := alBottom;
  MyGameForm.Run;
'''End;'''
:<span style="color:blue">How to Sound Effect?</span>
You can include the sound effect in an event triggered within your applications, messages to alert, or wherever you want to use it.<br>
We need to add the sound that we will use in the form to our project.<br>
MyGameForm.AddGameAssetFromUrl('https://www.clomosy.com/game/assets/Fire.wav');
Then we record the sound in a variable with the "RegisterSound" parameter.
SndFire := MyGameForm.RegisterSound('Fire.wav');
To enable the sound effect to be heard, we need to activate it.
MyGameForm.SoundIsActive:=True;
We have activated the sound in our application by making all the definitions. Now to run this in the project:<br>
MyGameForm.PlayGameSound(SndFire);
'''Example:'''<br>
'''var'''
  MyGameForm:TclGameForm;
  BtnRandomFire:TclButton;
  SndFire:Integer;
  '''Procedure''' BtnRandomFireClick;
  '''begin'''
    MyGameForm.PlayGameSound(SndFire);
  '''End;'''
'''begin'''
  MyGameForm := TclGameForm.Create(Self);
  MyGameForm.AddGameAssetFromUrl('https://www.clomosy.com/game/assets/Fire.wav');
  SndFire := MyGameForm.RegisterSound('Fire.wav');
  MyGameForm.SoundIsActive:=True;
  BtnRandomFire:= MyGameForm.AddNewButton(MyGameForm,'BtnRandomFire','RANDOM FIRE');
  MyGameForm.AddNewEvent(BtnRandomFire,tbeOnClick,'BtnRandomFireClick');
  BtnRandomFire.Align := alBottom;
  MyGameForm.Run;
'''End;'''

Revision as of 11:18, 28 March 2023

TclGameForm is a customized game form design for Clomosy. Here you can use features such as animation and sound effects. Now, to create the form, it is necessary to define.

MyGameForm:TclGameForm;

Now we need to add and run the form before giving properties to the form.

begin
  MyGameForm := TclGameForm.Create(Self);
  ...
  MyGameForm.Run;
End;

Documents taken from url addresses are added to the form with the "AddGameAssetFromUrl" parameter. For example; such as background and animation images, sound file.

MyForm.AddGameAssetFromUrl('https://www.clomosy.com/game/assets/Tank.png');

After adding the images, these images can be transferred to a component (TclProImage, TclImage). The transfer method is as follows:

ImgTank.clSetImage('Tank.png');

We can use animation and sound effects in TclGameForm.

How to Animation?

It is making a movie by showing animated pictures and still objects as if they are moving. This is how we make the pictures added on Clomosy animated.

You can set the animation height and width on the form. For this:

MyGameForm.AnimationWidth := 75; 
MyGameForm.AnimationHeight := 75;

If you want to give the number of animations:

MyGameForm.clAnimateBitmap.AnimationCount :=9;

To adjust the number of animation lines:

MyGameForm.clAnimateBitmap.AnimationRowCount:=3;

You can set the animation delay time on the form.

MyGameForm.clAnimateBitmap.Delay := 10;

You can set the animation duration time on the form.

MyGameForm.clAnimateBitmap.Duration := 2;

Now the "clAnimation" parameter is used so that we can show the animation on our screen. This parameter takes 4 values. (x_position,y_position,integer_value, animation_document)

Random() is used below to set a random location.

MyGameForm.clAnimation(Random() * TForm(MyGameForm).ClientWidth, Random() * TForm(MyGameForm).ClientHeight, 20, 'Explosion.png');

Example:

var 
  MyGameForm:TclGameForm;
  BtnRandomFire:TclButton;

  Procedure BtnRandomFireClick;
  var 
    i:Integer;
  begin
    MyGameForm.AnimationWidth := 75; 
    MyGameForm.AnimationHeight := 75;
    MyGameForm.clAnimateBitmap.AnimationCount :=9;
    MyGameForm.clAnimateBitmap.AnimationRowCount:=3;
    MyGameForm.clAnimateBitmap.Delay := 10; 
    MyGameForm.clAnimateBitmap.Duration := 2;
    For i:=0 to 5 do
    Begin
      MyGameForm.clAnimateBitmap.Delay := Random()*10;
      MyGameForm.clAnimation(Random() * TForm(MyGameForm).ClientWidth, Random() * TForm(MyGameForm).ClientHeight, 20, 'Explosion.png');            
    End;
  End;

begin
  MyGameForm := TclGameForm.Create(Self);
  MyGameForm.AddGameAssetFromUrl('https://www.clomosy.com/game/assets/Explosion.png');
 
  BtnRandomFire:= MyGameForm.AddNewButton(MyGameForm,'BtnRandomFire','RANDOM FIRE');
  MyGameForm.AddNewEvent(BtnRandomFire,tbeOnClick,'BtnRandomFireClick');
  BtnRandomFire.Align := alBottom;

  MyGameForm.Run;
End;


How to Sound Effect?

You can include the sound effect in an event triggered within your applications, messages to alert, or wherever you want to use it.

We need to add the sound that we will use in the form to our project.

MyGameForm.AddGameAssetFromUrl('https://www.clomosy.com/game/assets/Fire.wav');

Then we record the sound in a variable with the "RegisterSound" parameter.

SndFire := MyGameForm.RegisterSound('Fire.wav');

To enable the sound effect to be heard, we need to activate it.

MyGameForm.SoundIsActive:=True;

We have activated the sound in our application by making all the definitions. Now to run this in the project:

MyGameForm.PlayGameSound(SndFire);

Example:

var
  MyGameForm:TclGameForm;
  BtnRandomFire:TclButton;
  SndFire:Integer;

  Procedure BtnRandomFireClick;
  begin
    MyGameForm.PlayGameSound(SndFire);
  End;

begin
  MyGameForm := TclGameForm.Create(Self);
  MyGameForm.AddGameAssetFromUrl('https://www.clomosy.com/game/assets/Fire.wav');

  SndFire := MyGameForm.RegisterSound('Fire.wav');
  MyGameForm.SoundIsActive:=True;

  BtnRandomFire:= MyGameForm.AddNewButton(MyGameForm,'BtnRandomFire','RANDOM FIRE');
  MyGameForm.AddNewEvent(BtnRandomFire,tbeOnClick,'BtnRandomFireClick');
  BtnRandomFire.Align := alBottom;
  MyGameForm.Run;
End;