Skip to content

Instantly share code, notes, and snippets.

View roy-t's full-sized avatar

Roy Triesscheijn roy-t

View GitHub Profile
@roy-t
roy-t / Example.cs
Created September 14, 2021 18:31
Polymorphic serialization/deserialization using System.Text.Json
using System;
using System.Collections.Generic;
using System.Text.Json;
using System.Text.Json.Serialization;
namespace Poly
{
public abstract class BaseClass
{
public string Hello { get; } = "Hello";
@roy-t
roy-t / MatrixMath.cs
Created February 6, 2021 14:37
Constructing a billboard Matrix - MonoGame version
// Based on: https://swiftcoder.wordpress.com/2008/11/25/constructing-a-billboard-matrix/
public static Matrix CreateBillboard(Vector3 position, Matrix view)
{
var result = Matrix.Identity;
result.Translation = position;
result.M11 = view.M11;
result.M12 = view.M21;
result.M13 = view.M31;
result.M21 = view.M12;
@roy-t
roy-t / statics.md
Created February 8, 2018 21:50
The static keyword in C#

So C# is an object oriented (OO) programming language. I'm assuming you're used to OO languages and might not have worked with procedural or functional programming languages. So I will try to explain everything from an OO point of view.

As you well know in an Object Oriented programming language you have objects. Take the following example:

public class Window
{
	private bool open;
@roy-t
roy-t / Units.cs
Created December 20, 2017 10:34
Using real units in C# (meters, seconds, meters per second)
MetersPerSecond speed = 5.0f;
Seconds elapsed = 1.0f / 60.0f
Meters distance = speed * elapsed;
public struct Meters
{
public Meters(float value)
{
this.Value = value;
}
@roy-t
roy-t / xna4_vs2017.md
Last active February 19, 2023 10:43
Install XNA 4.0 under Microsoft Visual Studio 2017

This guide will provide you with a workaround for using XNA in Visual Studio 2017. This will solve problems with the target files and Microsoft.Build.Framework.dll such as: Error loading pipeline assembly "C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.0\Microsoft.Build.Framework.dll"

  1. Download a modified version of the XNA vsix: https://mxa.codeplex.com/
  2. Unzip XNA Game Studio 4.0.vsix and replace the <Installation /> tag in extension.vsixmanifest with this:
 <Installation InstalledByMsi="false">
    <InstallationTarget Version="[12.0,16.0)" Id="Microsoft.VisualStudio.VSWinDesktopExpress" />
    <InstallationTarget Version="[12.0,16.0)" Id="Microsoft.VisualStudio.Pro" />