<commit_before>{$I terra.inc}
{$IFDEF MOBILE}Library{$ELSE}Program{$ENDIF} BasicSample;

Uses TERRA_Application, TERRA_Scene, TERRA_GraphicsManager, TERRA_Viewport,
  TERRA_ResourceManager, TERRA_Color, TERRA_Texture, TERRA_OS, TERRA_PNG, TERRA_Vector2D,
  TERRA_SpriteManager, TERRA_FileManager, TERRA_Math, TERRA_Vector3D, TERRA_Utils,
  TERRA_InputManager, TERRA_UI;

Type
  // A client is used to process application events
  Demo = Class(Application)
    Protected
      _Scene:Scene;

			Procedure OnCreate; Override;
			Procedure OnIdle; Override;
  End;

  // A scene is used to render objects
  MyScene = Class(Scene)
      Procedure RenderSprites(V:Viewport); Override;
  End;

Const
  Limit = 500;

Var
  Tex:Texture = Nil;

  Pos:Array[0..Pred(Limit)]Of Vector3D;
  Dir:Array[0..Pred(Limit)]Of Vector2D;

{ Game }
Procedure Demo.OnCreate;
Var
  I:Integer;
  W,H:Single;
Begin
  // Added Asset folder to search path
  FileManager.Instance.AddPath('assets');

  // Create a scene and set it as the current scene
  _Scene := MyScene.Create;
  GraphicsManager.Instance.SetScene(_Scene);

  // Load a Tex
  Tex := TextureManager.Instance.GetTexture('ghost');

  GraphicsManager.Instance.ActiveViewport.BackgroundColor := ColorBlue;

  W := UIManager.Instance.Width;
  H := UIManager.Instance.Height;

  For I:=0 To Pred(Limit) Do
  Begin
    Pos[I] := VectorCreate(RandomFloat(0, W), RandomFloat(0, H), Trunc(RandomFloat(20, 40)));
    Dir[I] := VectorCreate2D(RandomFloat(-1, 1), RandomFloat(-1, 1));
  End;
End;

// OnIdle is called once per frame, put your game logic here
Procedure Demo.OnIdle;
Begin
  If InputManager.Instance.Keys.WasPressed(keyEscape) Then
    Application.Instance.Terminate;
End;

{ MyScene }
Procedure MyScene.RenderSprites;
Var
  I:Integer;
  W,H,Z:Single;
  S:QuadSprite;
Begin
  W := UIManager.Instance.Width;
  H := UIManager.Instance.Height;<commit_msg>Fixed crash on sprite sample<commit_after>{$I terra.inc}
{$IFDEF MOBILE}Library{$ELSE}Program{$ENDIF} BasicSample;

Uses TERRA_Application, TERRA_Scene, TERRA_GraphicsManager, TERRA_Viewport,
  TERRA_ResourceManager, TERRA_Color, TERRA_Texture, TERRA_OS, TERRA_PNG, TERRA_Vector2D,
  TERRA_SpriteManager, TERRA_FileManager, TERRA_Math, TERRA_Vector3D, TERRA_Utils,
  TERRA_InputManager, TERRA_UI;

Type
  // A client is used to process application events
  Demo = Class(Application)
    Protected
      _Scene:Scene;

			Procedure OnCreate; Override;
			Procedure OnIdle; Override;
  End;

  // A scene is used to render objects
  MyScene = Class(Scene)
      Procedure RenderSprites(V:Viewport); Override;
  End;

Const
  Limit = 500;

Var
  Tex:Texture = Nil;

  Pos:Array[0..Pred(Limit)]Of Vector3D;
  Dir:Array[0..Pred(Limit)]Of Vector2D;

{ Game }
Procedure Demo.OnCreate;
Var
  I:Integer;
  W,H:Single;
Begin
  // Added Asset folder to search path
  FileManager.Instance.AddPath('assets');

  // Create a scene and set it as the current scene
  _Scene := MyScene.Create;
  GraphicsManager.Instance.SetScene(_Scene);

  // Load a Tex
  Tex := TextureManager.Instance.GetTexture('ghost');

  GraphicsManager.Instance.DeviceViewport.BackgroundColor := ColorBlue;

  W := UIManager.Instance.Width;
  H := UIManager.Instance.Height;

  For I:=0 To Pred(Limit) Do
  Begin
    Pos[I] := VectorCreate(RandomFloat(0, W), RandomFloat(0, H), Trunc(RandomFloat(20, 40)));
    Dir[I] := VectorCreate2D(RandomFloat(-1, 1), RandomFloat(-1, 1));
  End;
End;

// OnIdle is called once per frame, put your game logic here
Procedure Demo.OnIdle;
Begin
  If InputManager.Instance.Keys.WasPressed(keyEscape) Then
    Application.Instance.Terminate;
End;

{ MyScene }
Procedure MyScene.RenderSprites;
Var
  I:Integer;
  W,H,Z:Single;
  S:QuadSprite;
Begin
  W := UIManager.Instance.Width;
  H := UIManager.Instance.Height;
{'fraction_non_alphanumeric': 0.11166710560969186, 'fraction_numerical': 0.011061364234922308, 'mean_word_length': 4.560761346998536, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '969352', 'n_tokens_mistral': 1400, 'n_tokens_neox': 1325, 'n_words': 313}