Skip to content

Instantly share code, notes, and snippets.

View TinkerWorX's full-sized avatar

Nikolaj Mariager TinkerWorX

  • Protominox
  • Denmark
View GitHub Profile
...
private static void BindNative(IntPtr functionPtr, String name, String prototype)
{
// Manual implementation of __fastcall.
// Moves the two first arguments to the registers, and pushes the rest on the stack.
var code = new byte[32];
var stream = new MemoryStream(code);
var writer = new BinaryWriter(stream);
...
public abstract class ImplicitModuleBase
{
public virtual Int32 Seed { get; set; }
public virtual Double Get(Double x, Double y) { return 0.00; }
public virtual Double Get(Double x, Double y, Double z) { return 0.00; }
public virtual Double Get(Double x, Double y, Double z, Double w) { return 0.00; }
@TinkerWorX
TinkerWorX / gist:2847947
Created June 1, 2012 01:37
Module chain in JSON
{
"modules": [
{ "type": "constant", "key": "tile_air", "value": "1" },
{ "type": "constant", "key": "tile_dirt", "value": "2" },
{ "type": "constant", "key": "tile_stone", "value": "3" },
{ "type": "constant", "key": "tile_copper", "value": "4" },
{ "type": "constant", "key": "tile_silver", "value": "5" },
{ "type": "constant", "key": "tile_gold", "value": "6" },
{ "type": "gradient", "key": "contour_gradient", "x0":"0.00", "x1":"0.00", "y0": "0.00", "y1": "1.00" },
@TinkerWorX
TinkerWorX / gist:2847952
Created June 1, 2012 01:38
Module chain in XML
<chain source="ground_select">
<module type="constant" name="tile_air" value="1.00" />
<module type="constant" name="tile_dirt" value="2.00" />
<module type="constant" name="tile_stone" value="3.00" />
<module type="constant" name="tile_copper" value="4.00" />
<module type="constant" name="tile_silver" value="5.00" />
<module type="constant" name="tile_gold" value="6.00" />
<module type="constant" name="tile_bedrock" value="255.00" />
<module type="gradient" name="contour_gradient" x0="0.00" x1="0.00" y0="0.00" y1="1.00" />
...
private Vector2 ApplyTileCollision(Vector2 deltaVelocity)
{
var deltaPosition = this.Position + deltaVelocity;
// Reset active values, as they are recalculated.
this.ActiveFriction = Single.NaN;
this.ActiveElasticity = Single.NaN;
var startx = this.TileStartX - 1;
Techno-magic is a setting where magic has been industrialized, and is used much like electricity is in our modern world. The difference
comes from the different magic types(power types), which rarely mix with good results, forcing a need to separate power conductors to keep
the various power types from mixing, though clever design may allow shared conductors. Power storage(batteries) also suffers from this,
forcing a different battery for each power type. Special converters exist that accept all types of power, but does so very inefficiently,
often sacrificing much of the potential energy in the conversion process.
Power types:
* Angelic/Good (visual:gold+effects) (damage:holy)
* Solar/Holy/Good (visual:gold) (damage:holy) (effect:extra good against undead/demonic creatures)
* Frost/Cold/Neutral (visual:blue) (damage:frost) (effect:slows down targets)
@TinkerWorX
TinkerWorX / Legeria.Core
Created August 6, 2012 02:22
Core features of Legeria
Equipment
Tools
- Shovel, for harvesting sand, gravel, dirt and other soft materials.
* Pickaxe, for harvesting rocks and ores and other hard materials.
- Axe, for harvesting wood type materials.
* Crowbar, for havesting background tiles.
- Hoe, prepares dirt for sowing.
Weapons
* Sword
public class EntityPhysicsSystem : GameComponent
{
private readonly HashSet<Entity> entities;
public EntityPhysicsSystem(Game game, HashSet<Entity> entities)
: base(game)
{
this.entities = entities;
}
@TinkerWorX
TinkerWorX / TinkerWorX.EntitySystemFramework.cs
Created August 11, 2012 15:07
My take on an entity system framework in C#.
using System;
using System.Collections.Generic;
namespace TinkerWorX.EntitySystemFramework
{
public sealed class Entity
{
private readonly Dictionary<Type, IComponent> components = new Dictionary<Type, IComponent>();
public void Add(IComponent component)
private void RunGame(bool useBlockingRun)
{
try
{
try
{
this.graphicsDeviceManager = this.Services.GetService(typeof(IGraphicsDeviceManager)) as IGraphicsDeviceManager;
if (this.graphicsDeviceManager != null)
{
this.graphicsDeviceManager.CreateDevice();