GameDev.Kit
1.0.6
See the version list below for details.
dotnet add package GameDev.Kit --version 1.0.6
NuGet\Install-Package GameDev.Kit -Version 1.0.6
<PackageReference Include="GameDev.Kit" Version="1.0.6" />
paket add GameDev.Kit --version 1.0.6
#r "nuget: GameDev.Kit, 1.0.6"
// Install GameDev.Kit as a Cake Addin
#addin nuget:?package=GameDev.Kit&version=1.0.6
// Install GameDev.Kit as a Cake Tool
#tool nuget:?package=GameDev.Kit&version=1.0.6
GameDev.Kit v1.0.6 (major update 1)
The game dev's kit for developing 2d console games
Use this library of classes to help speed up your game development process with pre-built Vectors and 2d Objects with Velocities and Positions. With a built-in game Loop method and Regenerate Map method, these three classes will help a bit.
C# Code Snippets:
public class Pong : IGame
{
public bool finished { get; set; }
public Object2D ball = new();
public Pong()
{
finished = false;
}
public void perFrameOperations(int fps)
{
float time = (1f / fps) * 1000;
ball.Move(time);
}
public void onGenerate(char[] row, char pixel)
{
Write(pixel switch
{
'X' => '█',
'B' => '█',
'P' => '■',
' ' => ' '
});
}
}
static void Main(string[] args)
{
var map = new char[][]
{
new char[] {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
new char[] {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
new char[] {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
new char[] {'X', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'X'},
new char[] {'X', ' ', ' ', ' ', ' ', ' ', 'P', ' ', ' ', ' ', ' ', ' ', ' ', 'X'},
new char[] {'X', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', 'X'},
new char[] {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
new char[] {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
new char[] {' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '},
}
IGame pong = new Pong();
pong.StartGame(map, 30);
}
Classes and Properties
- Vector: Has two properties: X and Y. Has a constructor that sets these two values to its parameters.
- Object2D: Has two properties: A vector called Position, and a vector called Velocity. Has a Move method that updates the position of the object based on the length of a frame and the pixels per millisecond.
The IGame Interface
The IGame Interface is to be implemented by the class that controls per-frame operations and re-generating the map. To implement the interface, the bool
finished needs to be added to the class, a void
named perFrameOperations, and a void
named regenerateMap, which has two parameters, a char[]
called row, which is the current row that is being generated, and a char
called pixel, which is the pixel about to be generated. You can see the following implemented class below:
public class Pong : IGame
{
public bool finished { get; set; }
public Object2D ball = new();
public Pong()
{
finished = false;
}
public void perFrameOperations(int fps)
{
float time = (1f / fps) * 1000;
ball.Move(time);
}
public void onGenerate(char[] row, char pixel)
{
Write(pixel switch
{
'X' => '█',
'B' => '█',
'P' => '■',
' ' => ' '
});
}
}
The StartGame method in the interface will regenerate the map, run any per-frame operations, and put the Thread to sleep for one frame. It will loop like this until finished is set to true
.
The regenerateMap method will run the onGenerate method for every pixel and row it iterates through. The following example shows a sample 'onGenerate' method:
public void onGenerate(char[] row, char pixel)
{
Write(pixel switch
{
'X' => '█',
'B' => '█',
'P' => '■',
' ' => ' '
});
}
Happy Game Developing!
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net5.0 is compatible. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. |
-
net5.0
- No dependencies.
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Made 'Game' an interface, IGame, with externally implemented properties onGenerate, perFrameOperations, and the boolean finished.