Short_Tools 1.0.19
See the version list below for details.
dotnet add package Short_Tools --version 1.0.19
NuGet\Install-Package Short_Tools -Version 1.0.19
<PackageReference Include="Short_Tools" Version="1.0.19" />
paket add Short_Tools --version 1.0.19
#r "nuget: Short_Tools, 1.0.19"
// Install Short_Tools as a Cake Addin #addin nuget:?package=Short_Tools&version=1.0.19 // Install Short_Tools as a Cake Tool #tool nuget:?package=Short_Tools&version=1.0.19
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, bool down)
{
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, bool down)
{
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();
...
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 (Program.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 class Manager : ShortSocketHandler
{
public Manager() : base(1234, 10) {}
public override bool ValidateClient(Socket socket)
{
return true; // no validation required for this.
}s
}
...
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.
V1.0.9: Animations Added
To make an animation, have a player class which you render like
public class Player
{
public Vector2 pos;
public Player(Vector2 pos)
{
this.pos = pos;
}
}
And draw that in your renderer, then you can add an animation in your main function
renderer.AddAnimation(new Renderer.Animation(player.pos, new Vector2() { X = 1000, Y = 500 }, ref player.pos, 0.1f, Renderer.Animation.Flags.Linear));
And the player will move to the point (1000, 500) with a speed of 0.1
V1.0.14: ShortSettings added (ini files)
To use the settings you need to make a new class which inherits from ShortSettings
public class Settings : ShortSettings
{
}
You can then add variables to the settings, which you can edit in the ini file
public class Settings : ShortSettings
{
public int num { get; set; } = 1;
public string name { get; set; } = "none";
public float deci { get; set; } = 1.1;
public bool flag { get; set; } = false;
}
Then we can create the ini file
[Values]
num = 3
name = "Program"
deci = 3.2
flag = true
the [Values] is not necessary, but it is very useful as headings. using // before an entry will mark it as a comment, so it will not affect anything.
to designate a string, use "" to designate an int, write a number with no decimal point to designate a float, write a number (optional), then a decimal point and the rest of the decimal. (like 1.2 or .447) to designate a boolean, write either true or false (capital T or F are valid)
To use the ini file, this code is required
static void Main()
{
Settings settings = new Settings();
settings.LoadINI<Settings>("Settings\\Settings.ini")
}
The ini will then be loaded into the settings class.
If you make changes to the class in runtime, and want to save those changes in the ini, you can use
static void Main()
{
Settings settings = new Settings();
settings.LoadINI<Settings>("Settings\\Settings.ini")
...
settings.SaveINI<Settings>("Settings\\Settings.ini");
}
This will only edit existing entries in the ini file, but will change them to the value that the settings class has at that time.
Flags:
Object | Name | Description | Version Added
---------------|--------------------|-----------------------------|-------------------------------
| | Automatically calls the |
ShortRenderer | Auto_Draw_Clear | RenderClear() function | V1.0.8
| | before renderering and the |
| | RenderDraw() function after|
---------------|--------------------|-----------------------------|-------------------------------
| | |
ShortRenderer | Debug | Displays some debug info | V1.0.8
| | To the console |
---------------|--------------------|-----------------------------|-------------------------------
| | Displays what inputs have |
ShortHandler | Debug | been registered in the | V1.0.8
| | Console |
---------------|--------------------|-----------------------------|-------------------------------
| | |
ShortListener | Debug | Displays nothing for now | V1.0.8
| | |
---------------|--------------------|-----------------------------|-------------------------------
| | |
ShortSocket- | Debug | Displays nothing for now | V1.0.8
Handler | | |
---------------|--------------------|-----------------------------|-------------------------------
| | Changes the movement curve |
ShortRenderer.|Linear, Exponential,| of the animation, interact- | V1.0.9
Animation | Root, Sigmoid | ive graph @ https://www.desm|
| | os.com/calculator/kpldcor3nt|
---------------|--------------------|-----------------------------|-------------------------------
| | |
ShortDebugger | DISPLAY_ON_ADD_LOG | Displays a message in the | V1.0.12
| | Console when a log is added |
---------------|--------------------|-----------------------------|-------------------------------
| | |
ShortDebugger | ADD_LOG_ON_- | Adds a log whenever the | V1.0.12
| PRIORITY_CHANGE | default priority is changed |
| | |
---------------|--------------------|-----------------------------|-------------------------------
| | Makes the debugger save |
ShortDebugger | SAVE_ON_CONSOLE- | when the console is closed |
| _CLOSE | (default clean 10 files) | V1.0.18
| | disable clean via flags |
---------------|--------------------|-----------------------------|-------------------------------
| | |
ShortDebugger | DISABLE_CONSOLE_ | Disables the default |
| CLEAN | 10 file clean from flag | V1.0.18
| | SAVE_ON_CONSOLE_CLOSE |
| | |
If you find any issues or have any questions, feel free to email me at matthew.short.nh@gmail.com.
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 | 132 | 8/16/2024 | |
1.0.19 | 107 | 8/12/2024 | |
1.0.18 | 119 | 8/10/2024 | |
1.0.17.2 | 134 | 6/29/2024 | |
1.0.17.1 | 114 | 6/28/2024 | |
1.0.17 | 109 | 6/28/2024 | |
1.0.16 | 116 | 6/26/2024 | |
1.0.15 | 151 | 6/5/2024 | |
1.0.14.1 | 114 | 6/1/2024 | |
1.0.14 | 115 | 6/1/2024 | |
1.0.13.2 | 124 | 6/1/2024 | |
1.0.13.1 | 108 | 6/1/2024 | |
1.0.13 | 115 | 6/1/2024 | |
1.0.12 | 128 | 5/16/2024 | |
1.0.11.3 | 94 | 5/3/2024 | |
1.0.11.2 | 93 | 5/3/2024 | |
1.0.11.1 | 85 | 5/2/2024 | |
1.0.11 | 86 | 5/2/2024 | |
1.0.10 | 140 | 4/8/2024 | |
1.0.9 | 143 | 3/27/2024 | |
1.0.8.1 | 159 | 3/20/2024 | |
1.0.8 | 125 | 3/20/2024 | |
1.0.7 | 139 | 2/21/2024 | |
1.0.6 | 145 | 2/1/2024 | |
1.0.5 | 129 | 1/30/2024 | |
1.0.4 | 119 | 1/29/2024 | |
1.0.3 | 124 | 1/28/2024 | |
1.0.2 | 109 | 1/28/2024 | |
1.0.1 | 114 | 1/26/2024 | |
1.0.0 | 126 | 1/25/2024 |