-
Notifications
You must be signed in to change notification settings - Fork 14
02. Hello World
Here I assume that you have the basic knowledge of C#, and you have installed Visual Studio.
This section will tell you how to start a Love2dCS project.
When beginning to write games using LÖVE, the most important parts of the API are the callbacks :
-
Love.Scene.Load : to do one-time setup of your game.
-
Love.Scene.Update : which is used to manage your game's state frame-to-frame.
-
Love.Scene.Draw : which is used to render the game state onto the screen.
By inheriting the class Scene
and override the method void Load()
void Update(dt)
void Draw()
, you can handle input from the user, and other aspects of a full-featured game.
In the Visual Studio Solution Explorer window, right-click on the project node and you will see a new context menu, Manage NuGet Packages.
Clicking on this menu will bring up the Manage NuGet Packages dialog. The dialog defaults to show packages that are installed in your project and have updates available on the office package source, as seen in below. The package source is a publicly hosted server on the Internet that hosts both open-source and closed-source libraries and components.
And click Browse
, type Love2dCS
in search box. And then you get result :
Click Install
to setup Love2dCS library.
using Love;
namespace Example
{
class Program : Love.Scene
{
float x, y, w, h;
public override void Load()
{
x = 20;
y = 20;
w = 60;
h = 20;
}
public override void Update(float dt)
{
w = w + 1;
h = h + 1;
}
public override void Draw()
{
Graphics.SetColor(0, 0.3f, 0.3f);
Graphics.Rectangle(DrawMode.Fill, x, y, w, h);
}
static void Main(string[] args)
{
Boot.Run(new Program());
}
}
}