Short_Tools 1.0.6
See the version list below for details.
dotnet add package Short_Tools --version 1.0.6
NuGet\Install-Package Short_Tools -Version 1.0.6
<PackageReference Include="Short_Tools" Version="1.0.6" />
paket add Short_Tools --version 1.0.6
#r "nuget: Short_Tools, 1.0.6"
// Install Short_Tools as a Cake Addin #addin nuget:?package=Short_Tools&version=1.0.6 // Install Short_Tools as a Cake Tool #tool nuget:?package=Short_Tools&version=1.0.6
Here is a small tutorial on how to use some of the parts of this library.
The Renderer (V1.0.3):
To create a renderer, we first must create a subclass that inherits from the ShortRenderer class.
internal class Renderer : ShortRenderer
{
public override void Render()
{
RenderClear(); // use at the start of the function to clear the screen
// code will go here for drawing
RenderDraw(); // applies Draw functions to the screen
}
}
Now we can create an instance of this class, and set it up.
static void Main()
{
bool Running = true;
Renderer renderer = new Renderer();
renderer.Load_Images
(
new Dictionary<string, string>()
{
{ "Background", "res\\background.png" },
{ "image", "res\\random image.png" }
}
)
renderer.Start();
while (Running)
{
// your game/app code will go here
}
renderer.Stop();
}
This code will start up the renderer, load the images given to it, and then start rendering, but the draw function is currently empty, so all that will appear will be a purple screen, you can test this.
To change this we can now edit the Render function
public override void Render()
{
RenderClear();
Draw(0, 0, screenwidth, screenheight, "background");
Draw(500, 500, 200, 200, "image");
RenderDraw();
}
This code will draw the background fully covering the screen, and will then draw the image at "res\random image.png" at the coordinates given and the size given.
Setting up player inputs and closing of the game/app (V1.0.4).
The current code will never quit, and will not be able to be changed by the user, to fix this we can use the ShortHandler. To start the process, we will do that same thing as with the renderer, and create a subclass.
internal class Handler : ShortHandler
{
public override void Handle(string inp)
{
switch (inp)
{
case ("a"):
// do something
break;
case ("d"):
// do something else
break;
}
}
}
Then, we can create an instance and run it in the game/app loop.
Renderer renderer = new Renderer();
Handler handler = new Handler();
...
while (Running)
{
handler.HandleInputs(ref Running);
// your game/app code
}
renderer.Stop();
This will now allow quitting, but to make the "a" and "d" keys do something, we will make a public static variable.
internal class Program
{
public static double angle { get; set; } = 0d; // sets up the angle and initiates a value
static void Main()
{
...
}
...
}
Then we can edit the handle code to change angle on button press
internal class Handler : ShortHandler
{
public override void Handle(string inp)
{
switch (inp)
{
case ("a"):
Program.angle--;
break;
case ("d"):
Program.angle++;
break;
}
}
}
Now finally, we can apply this angle to the image drawn to screen in the Render function from the renderer.
public override void Render()
{
RenderClear();
Draw(0, 0, screenwidth, screenheight, "background");
Draw(500, 500, 200, 200, "image", Program.angle);
RenderDraw();
}
This will now draw the background, then the image given ontop of that and you can rotate that image via "a" and "d".
Adding buttons to make images appear and dissapear (V1.0.5).
To change the state of a drawing, we will need to make another static variable.
internal class Program
{
public static double angle { get; set; } = 0d;
public static bool drawImage { get; set; } = true;
static void Main()
{
...
}
...
}
To add buttons, we need to create a new button and add it to the handlers list of buttons.
Renderer renderer = new Renderer();
Handler handler = new Handler();
...
ShortHandler.ShortButton button = new(500, 500, 200, 200); // same coordinates as the image that i am drawing, rotating buttons will be added in a later update.
handler.AddButton(ref button);
while (Running)
{
handler.HandleInputs(ref Running);
if (button.pressed)
{
button.pressed = false;
if (drawImage == true) { drawImage = false; }
else { drawImage = true; }
}
// your game/app code
}
renderer.Stop();
Then we just have to change the rendering code.
public override void Render()
{
RenderClear();
Draw(0, 0, screenwidth, screenheight, "background");
if (drawImage)
{
Draw(500, 500, 200, 200, "image", Program.angle);
}
RenderDraw();
}
Now you have a renderer, an input handler, and an image that dissapears and reappears if you click it.
You can also make Sockets easily in (V1.0.6)
Here we will do some simple code to pass hello world between a client and a server.
Client code:
// using static Short_Tools.Sockets;
static void Main()
{
ShortListener listener = new ShortListener("127.0.0.1", 1234);
listener.SendMessage("Hello Server!");
Console.WriteLine("XX " + listener.GetMessage());
}
Server code:
// using static Short_Tools.Sockets;
public Manager : ShortSocketHandler
{
public Manager() : base(1234, 10) {}
public override bool ValidateClient(Socket socket)
{
return true; // no validation required for this.
}
}
static void Main()
{
Manager manager = new Manager();
bool Running = true;
while (Running)
{
if (manager.NewConnection())
{
Console.WriteLine("\nNew Connection:");
Socket newPerson = manager.GetClient();
ShortListener listener = new ShortListener(newPerson);
string message = listener.GetMessage();
Console.WriteLine("CC " + message);
listener.SendMessage("Hello Client!");
listener.Stop();
}
}
}
This code will allow the server to host multiple clients, and each one will send a message of "Hello Server" and recieve a reply of "Hello Client" before having their connection terminated.
Product | Versions Compatible and additional computed target framework versions. |
---|---|
.NET | net6.0 is compatible. 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. |
-
net6.0
- Sayers.SDL2.Core (>= 1.0.11)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Version | Downloads | Last updated | |
---|---|---|---|
1.0.20 | 139 | 8/16/2024 | |
1.0.19 | 112 | 8/12/2024 | |
1.0.18 | 124 | 8/10/2024 | |
1.0.17.2 | 139 | 6/29/2024 | |
1.0.17.1 | 118 | 6/28/2024 | |
1.0.17 | 113 | 6/28/2024 | |
1.0.16 | 120 | 6/26/2024 | |
1.0.15 | 155 | 6/5/2024 | |
1.0.14.1 | 118 | 6/1/2024 | |
1.0.14 | 119 | 6/1/2024 | |
1.0.13.2 | 128 | 6/1/2024 | |
1.0.13.1 | 114 | 6/1/2024 | |
1.0.13 | 119 | 6/1/2024 | |
1.0.12 | 132 | 5/16/2024 | |
1.0.11.3 | 98 | 5/3/2024 | |
1.0.11.2 | 97 | 5/3/2024 | |
1.0.11.1 | 89 | 5/2/2024 | |
1.0.11 | 90 | 5/2/2024 | |
1.0.10 | 146 | 4/8/2024 | |
1.0.9 | 147 | 3/27/2024 | |
1.0.8.1 | 163 | 3/20/2024 | |
1.0.8 | 129 | 3/20/2024 | |
1.0.7 | 143 | 2/21/2024 | |
1.0.6 | 153 | 2/1/2024 | |
1.0.5 | 133 | 1/30/2024 | |
1.0.4 | 125 | 1/29/2024 | |
1.0.3 | 128 | 1/28/2024 | |
1.0.2 | 113 | 1/28/2024 | |
1.0.1 | 118 | 1/26/2024 | |
1.0.0 | 130 | 1/25/2024 |