add mono c# (using dotnet9.0 from https://github.com/dotnet/runtime), add ECS (entt), add some c# code, add fastNoise
This commit is contained in:
38
ExampleApp/Src/Script.cs
Normal file
38
ExampleApp/Src/Script.cs
Normal file
@ -0,0 +1,38 @@
|
||||
using System;
|
||||
|
||||
using Prism;
|
||||
|
||||
namespace Example
|
||||
{
|
||||
public class Script : Entity
|
||||
{
|
||||
public float Speed = 5.0f;
|
||||
|
||||
public void OnCreate()
|
||||
{
|
||||
Console.WriteLine("Script.OnCreate");
|
||||
Console.WriteLine("this is c# function OnCreate, this will be called by cpp");
|
||||
}
|
||||
|
||||
public void OnUpdate(float ts)
|
||||
{
|
||||
Mat4 transform = GetTransform();
|
||||
Vec3 translation = transform.Translation;
|
||||
|
||||
float speed = Speed * ts;
|
||||
|
||||
if (Input.IsKeyPressed(KeyCode.Up))
|
||||
translation.Y += speed;
|
||||
else if (Input.IsKeyPressed(KeyCode.Down))
|
||||
translation.Y -= speed;
|
||||
if (Input.IsKeyPressed(KeyCode.Right))
|
||||
translation.X += speed;
|
||||
else if (Input.IsKeyPressed(KeyCode.Left))
|
||||
translation.X -= speed;
|
||||
|
||||
transform.Translation = translation;
|
||||
SetTransform(transform);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user