-
Notifications
You must be signed in to change notification settings - Fork 2
Basics
SDL2 SDL2_Image SDL2_TTF SDL2_Mixer
sudo apt-get install libsdl2-dev libsdl2-image-dev libsdl2-ttf-dev libsdl2-mixer-dev
(Make sure you have .NET 6.0 installed)
Launch your terminal emulator of choice in an empty folder and run
git clone https://github.com/willmexe/Fjord.git &&
cd Fjord &&
git submodule init &&
git submodule update &&
dotnet restore
Now drag in the dlls from the SDL installs into bin/Debug/net6.0
if you are on Windows.
If you are on Ubuntu then the dependencies are already in path.
Now run
dotnet build
If you don't want to build Fjord then you can always get the same dll from the releases tab on the github.
Launch your terminal emulator of choice in an empty folder and run
dotnet new console &&
dotnet run
It should print "Hello World!" if not you have done something incorrectly.
Now copy the bin/Debug/net6.0/ folder contents from the Fjord build into the bin/Debug/net6.0/ folder and copy the resources
folder from the Fjord repository and copy it into your new project. (Including the SDL2 dlls)
Now add
<ItemGroup>
<Reference Include="Fjord">
<HintPath>bin/Debug/net6.0/Fjord.dll</HintPath>
</Reference>
</ItemGroup>
to your .csproj and now it's for the game logic. (Located under "Basic Game Logic")
Launch your terminal emulator of choice in an empty folder and run
dotnet new console &&
dotnet run
Install the Fjord
Nuget package using the Nuget Package Manager
in Visual Studio Code or by adding a Nuget package to your solution in Visual Studio.
Also drag in the SDL2 dlls from the Install SDL2
chapter into bin/Debug/net6.0/
if you are on Windows.
Now it's the game logic. (Located under "Basic Game Logic")
The most basic game logic is:
using Fjord;
using Fjord.Modules.Game;
namespace Template_Game {
// Scene class this is where your game is
public class game : scene
{
public override void on_load()
{
// This is where you load all your scenes
// The if statement is so that it doesn't trigger multiple times
if(!scene_handler.get_scene("game-template")) {
// Add all scenes
scene_handler.add_scene("game-template", new game());
// Load the first scene this can later be called in any file as for example a win condition to switch scene.
scene_handler.load_scene("game-template");
}
}
// Update method
// This is where all your gamelogic is
public override void update()
{
}
// Render method
// This is where all your rendering is
public override void render()
{
}
}
// Main Class
class Program
{
public static void Main(string[] args)
{
// Function that starts game
// The parameter should be your start scene
game.set_resource_folder("resources");
game.run(new game());
}
}
}
so copy this into your program.cs
file and now you should be good to go.
If you run the project now it should open with a dark gray color and now your set!
The second part is the resources
The resource folder is specified with game.set_resource_folder(string folder);
.
Resources are kept in your specified resource folder.
Assetpacks have a structure of:
-
[asset_pack]/assets/images/
for images -
[asset_pack]/assets/fonts/
for fonts -
[asset_pack]/data/lang/
for language files -
[asset_pack]/data/tilemaps/
for tilemaps
Assetpacks are loaded using the game.set_asset_pack(string asset_pack);
function.