-
Notifications
You must be signed in to change notification settings - Fork 0
Setup
The setup template is simple:
// GameBox does not need to be set to a variable
new GameBox(new Program(), new Vector2(window width, window height), "title");
public partial class Program : GameLoop
{
public override void Init()
{
// game object initialization
// if you have objects that just need to render and update
// then use RegisterGameObj()
}
// tip: it is unwise to make new objects during Update and Render
public override void UpdateLoop()
{
// put update loop stuff here
}
public override void RenderLoop()
{
// put render loop stuff here
}
}GameObject is a foundation in which most objects inside RayWrapper extend from
Every GameObject has 3 parts to it:
- Initialization through the constructor
- Update
- Render
99% of the time a GameObject will not be able to be initialized in class fields due to the need of the initialization of GameBox so they need to be initialized in the constructors of the class they are inside.
Not all, but most GameObjects will need to be updated and rendered with Object.Update() and Object.Render() respectively. There is away around needing to have 50 class variables for each object and typing Object.Update() in the update loop and Object.Render() 50 times, and that solution is RegisterGameObj(). RegisterGameObj() takes any amount of GameObjects as parameters, it will automatically call the Object.Update() and Object.Render() for you AFTER their respective loops.
Do you want a single type that represents both a normal variable AND a Func? Then Actionable<T> is your solution! Actionable is a very important and powerful tool, with it you can set a normal variable like Color fontColor = Raylib.Black but also have a Func like Func<int, Color> fontColor = i => GetColor(i) in 1 variable. This is how you can do the same with actionable:
public Actionable<Color> fontColor = Raylib.Black;
public int counter;
public RandomFunction()
{
// font color will now be based on the counter variable with a GetColor method
fontColor = new Actionable<Color>(() => GetColor(counter));
}ColorModule is basically an Actionable<Color>, but with extra steps and features.
ColorModule has:
-
ToString()for converting the color into a string implicitly - Deconstructor for converting color to
(int r, int g, int b, int a)
ColorModule also has 2 constructors that help with creating a color.