Skip to content

Instantly share code, notes, and snippets.

@FaronBracy
FaronBracy / Camera.cs
Created August 23, 2021 12:34
Camera with Pan and Zoom
using Microsoft.Xna.Framework;
using ZoomEngine.Animation;
namespace Game
{
public class Camera
{
private ClockManager _clockManager;
// position of the camera
@FaronBracy
FaronBracy / FlyCamera.cs
Created June 9, 2020 15:47 — forked from gunderson/FlyCamera.cs
Unity Script to give camera WASD + mouse control
using UnityEngine;
using System.Collections;
public class FlyCamera : MonoBehaviour {
/*
Writen by Windexglow 11-13-10. Use it, edit it, steal it I don't care.
Converted to C# 27-02-13 - no credit wanted.
Simple flycam I made, since I couldn't find any others made public.
Made simple to use (drag and drop, done) for regular keyboard layout
@FaronBracy
FaronBracy / .editorconfig
Last active February 19, 2024 14:13
Editor config file for CSharp .cs files including Visual Studio and ReSharper custom attributes
#####################################################################################################
# 2019-01-15 Initial Creation
# 2019-04-01 Added ReSharper Settings
# 2019-05-16 Naming Rules Work With ReSharper
# 2019-07-09 Constant and Static Readonly Naming Rules
# 2022-09-16 New Settings for Visual Studio 2022
#####################################################################################################
# Based off of generic config from https://github.com/RehanSaeed/EditorConfig
# License MIT - https://github.com/RehanSaeed/EditorConfig/blob/master/LICENSE
#
@FaronBracy
FaronBracy / DotSettingsConverterTest.cs
Created March 26, 2019 15:04
Convert .dotsettings to .editorconfig
using System;
using System.Collections.Generic;
using System.Xml.Linq;
using Microsoft.VisualStudio.TestTools.UnitTesting;
namespace DotSettingsConverter
{
[TestClass]
public class DotSettingsConverterTest
{
@FaronBracy
FaronBracy / warrior.js
Created March 26, 2019 00:30
Warrior JS code
let exploreState = {
execute: function(player,warrior) {
if (player.sense(warrior) === 'empty') {
warrior.walk(player.direction);
}
else if (player.sense(warrior) === 'wall') {
warrior.pivot();
}
else if (player.sense(warrior) === 'enemy') {
warrior.think("It's time to kick ass and chew bubble gum...");
@FaronBracy
FaronBracy / Program.cs
Created March 2, 2019 13:59
Example - Cells further away in FOV are dimmer
public class Program
{
private static double DistanceBetween( int x1, int y1, int x2, int y2 )
{
return Math.Sqrt( Math.Pow( x2 - x1, 2 ) + Math.Pow( y2 - y1, 2 ) );
}
private static int WalkingDistanceBetween( int x1, int y1, int x2, int y2 )
{
return Math.Abs( x2 - x1 ) + Math.Abs( y2 - y1 );
@FaronBracy
FaronBracy / xd2md.cs
Created January 10, 2017 17:55 — forked from formix/xd2md.cs
Generates Markdown From VisualSturio XML documentation files
using System;
using System.Collections.Generic;
using System.IO;
using System.Text.RegularExpressions;
using System.Xml;
using System.Xml.Linq;
namespace Formix.Utils
{
class Program
@FaronBracy
FaronBracy / InterfaceDrawingSample.cs
Created March 12, 2016 21:12
Example of drawing interface elements with MonoGame that do not transform
// Draw everything that will be transformed with the camera like the player, cells, etc.
_spriteBatch.Begin( SpriteSortMode.BackToFront, null, SamplerState.PointClamp, null, null, null, Camera.TranslationMatrix );
for ( int x = minX; x < maxX; x++ )
{
for ( int y = minY; y < maxY; y++ )
{
bool isVisible = Global.GameModel.Map.Properties[x + y * Global.GameModel.Map.Width] == CellProperties.Visible;
Tiles[x, y].Draw( _spriteBatch, SpriteSheet, new Vector2( x * Global.CellWidth, y * Global.CellHeight ), isVisible );
}
@FaronBracy
FaronBracy / ProductVersion.sql
Created March 18, 2015 20:25
Create a project version table
-- Create new table for keeping track of all the versions of project files
CREATE TABLE wa.ProjectVersion(
ProjectVersionId int IDENTITY(1,1) NOT NULL,
ProjectId int NOT NULL,
DateCreated datetime2(7) NOT NULL,
ProjectFileId varchar(50) NOT NULL
PRIMARY KEY CLUSTERED
(
ProjectVersionId ASC
)
@FaronBracy
FaronBracy / EnumExtensions.cs
Created March 8, 2015 02:25
Some extension methods for enums that are useful for older versions of .NET
public static class EnumExtensions
{
private static void CheckIsEnum<T>(bool withFlags)
{
if (!typeof(T).IsEnum)
throw new ArgumentException(string.Format("Type '{0}' is not an enum", typeof(T).FullName));
if (withFlags && !Attribute.IsDefined(typeof(T), typeof(FlagsAttribute)))
throw new ArgumentException(string.Format("Type '{0}' doesn't have the 'Flags' attribute", typeof(T).FullName));
}