Open Shadowblitz16 opened 4 years ago
actually you can do this now:
using System;
using Love;
namespace Project1
{
class Issue_100: Scene
{
bool sholdClosed = false;
public override bool Quit()
{
sholdClosed = true; // mark it as true to break loop
return false; // return true will lead Application.Exit();
}
static void Main()
{
Boot.Init();
var scene = new Issue_100();
while (!scene.sholdClosed)
{
Boot.SystemStep(scene); // poll the event
Graphics.Clear(); // clean the window
Graphics.Line(Vector2.Zero, Mouse.GetPosition());
Graphics.Present(); // show the next frame
if (Keyboard.IsPressed(KeyConstant.Space)) // update logic
scene.sholdClosed = true;
Window.SetTitle("fps:" + FPSCounter.GetFPS());
}
Console.WriteLine("-end-");
}
}
}
Dose it can meet your requirements ❓
kinda ya but It would be better if it required less implementation. I mean I could get around it but something more of what I suggested where you don't need to create a instance of a class.
may be you mean:
Main(...)
{
Boot.Init();
while (!Boot.QuitFlag)
{
Boot.SystemStep();
// or do this .....
//Boot.SystemStep(new Boot.SystemStepConfig(){
// OnKeyPressed = (k, s, i) => Console.WriteLine(k),
//});
Graphics.Clear();
Graphics.Line(Vector2.Zero, Mouse.GetPosition());
Graphics.Present();
if (Keyboard.IsPressed(KeyConstant.Space))
Boot.QuitFlag = true;
Window.SetTitle("fps:" + FPSCounter.GetFPS());
}
Console.WriteLine("-end-");
}
@endlesstravel yep but Boot.QuitFlag
should be a method called Boot.IsRunning()
and Boot.SystemStep();
should a be abstracted so it doesn't need to be called.
also Boot should accept a optional window size and title
Main(...)
{
Boot.Init(800, 600, "fps:" + FPSCounter.GetFPS());
///Window.SetTitle(); //optional Boot.Init() can Initialize window width, height and title.
while (!Boot.IsRunning())
{
// Boot.SystemStep is not needed at all it is updated by Boot.Init(); using a object
Graphics.Clear();
Graphics.Line(Vector2.Zero, Mouse.GetPosition());
Graphics.Present();
if (Keyboard.IsPressed(KeyConstant.Space))
Boot.QuitFlag = true;
}
Console.WriteLine("-end-");
}``
i will not push the function : Boot.IsRunning()
I think it's confusing. A function should only be as literal as it means, otherwise function name matching is not the actual task.
I had add new way to Boot.SystemStep(new Boot.SystemStepConfig() ...
in version 11.0.45
I'm not sure what you mean by Boot.IsRunning() is confusing. I agree it is probably not the best class to put it in since something like.. Window.IsOpen() is probably better. also I do agree now that the running check and the events should be separated maybe in something like Window.PollEvents() but idk.
so I just was messing around with RayLibCS and I really liked how the main loop worked. it allowed the user to control the flow of the program and draw inside the things like load and update functions.
here is a example..
I think Love2d cs should allow something like this even if it was a optional thing. it Love could update the stuff behind the scenes and allow the user to control the flow of the program.
for example..