From Clomosy Docs

TclGameEngine is a game engine component used on the Clomosy platform. This component is used to develop word-based games. It retrieves word data from Clomosy's dedicated service and makes it available for use within the game.


Feature Use of Definition
TclGameEngine GameEngine1 : TclGameEngine; An object of the TclGameEngine class has been defined.
TclGameEngine.Create GameEngine1 = TclGameEngine.Create; An object of the TclGameEngine class has been created.


TclGameEngine retrieves word data through a service call using the WordService method. The first parameter represents the character value request for the desired word (In the range of 3 to 11 characters). The second parameter indicates that the word may belong to a specific category.

There are two usage options:

The category can be set to "forkids".
IncomingValue = MyGameEngine.WordService('GETWORD:3','forkids'); //IncomingValue: String;
If no filtering is required, the parameter can be left empty.
IncomingValue = MyGameEngine.WordService('GETWORD:3',''); //IncomingValue: String;

It returns data in JSON format as a string.

Sample string output:

{"Word":"yay","MeanText":"Zodyak üzerinde, Akrep ile Oğlak arasında bulunan burç, Zodyak"}

The received data contains the word and its meaning.

If separate access to these values is required the JSON array can be converted into a dataset object as shown below, allowing retrieval using field names.

  With Clomosy.ClDataSetFromJSON(MyGameEngine.WordService('GETWORD:2','forkids')) Do 
  {
    ShowMessage(FieldByName('MeanText').AsString);
    ShowMessage(FieldByName('Word').AsString);
  } 

Example

var
  MainForm:TCLForm;
  GameEngine1 : TclGameEngine;
  btnGetWordMeaning: TclButton;
  lblWord: TclLabel;
  lblMeaning: TclLabel;
  jsonWordMeaning : String;

void getWordMeaningClick;
{
  GameEngine1 = TclGameEngine.Create;
  jsonWordMeaning = GameEngine1.WordService('GETWORD:6','');
  With Clomosy.ClDataSetFromJSON(jsonWordMeaning) Do 
  {
    lblWord.Text = 'Word: ' + FieldByName('Word').AsString;
    lblMeaning.Text = 'Meaning: ' + FieldByName('MeanText').AsString;
  }
}

{
  MainForm = TCLForm.Create(Self);
  btnGetWordMeaning = MainForm.AddNewButton(MainForm,'btnGetWordMeaning','Get Word and Meaning');
  btnGetWordMeaning.Align = alMostBottom;
  btnGetWordMeaning.Height = 75;
  btnGetWordMeaning.StyledSettings = ssFamily;
  btnGetWordMeaning.TextSettings.Font.Size = 20;
  btnGetWordMeaning.TextSettings.FontColor = clAlphaColor.clHexToColor('#8a067c');
  MainForm.AddNewEvent(btnGetWordMeaning,tbeOnClick,'getWordMeaningClick');

  lblWord = MainForm.AddNewLabel(MainForm,'lblWord','Word: ');
  lblWord.Align = alMostTop;
  lblWord.Height = 75;
  lblWord.Margins.Left = 20;
  lblWord.Margins.Right = 20;
  lblWord.Margins.Bottom = 20;

  lblMeaning = MainForm.AddNewLabel(MainForm,'lblMeaning','Meaning: ');
  lblMeaning.Align = alTop;
  lblMeaning.Height = 75;
  lblMeaning.Margins.Left = 20;
  lblMeaning.Margins.Right = 20;

  MainForm.Run;

}


See Also