Skip to content

Instantly share code, notes, and snippets.

Anton Pantev antonpantev

Block or report user

Report or block antonpantev

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@antonpantev
antonpantev / State.cs
Created Apr 25, 2019
Basic StateMachines for Unity
View State.cs
using UnityEngine;
public class State : MonoBehaviour
{
public virtual void StateStart() { }
public virtual void StateUpdate() { }
public virtual void StateEnd() { }
}
View TilemapExtension.cs
using UnityEngine;
using UnityEngine.Tilemaps;
public static class TilemapExtension
{
public static void DebugDraw(this Tilemap tilemap, float size, Color color = default(Color), float duration = 0.0f, bool depthTest = true)
{
BoundsInt bounds = tilemap.cellBounds;
TileBase[] allTiles = tilemap.GetTilesBlock(bounds);
@antonpantev
antonpantev / TileComponent.cs
Created Jan 19, 2019
A Unity component that is also a Tile in a Tilemap.
View TileComponent.cs
using UnityEngine;
using UnityEngine.Tilemaps;
/// <summary>
/// A component that is also a Tile in a Tilemap. If the Tilemap is not
/// specified it will default to the Tilemap in the parent Game Object.
/// </summary>
public class TileComponent : MonoBehaviour
{
public Tilemap tilemap;
@antonpantev
antonpantev / Manager.cs
Last active Dec 29, 2018
This is a manager class that can be used for game objects that need to be singletons. Often used to hold game data or to control interactions across multiple game objects.
View Manager.cs
public abstract class Manager<T> : MonoBehaviour where T : Manager<T>
{
public static T Instance { get; private set; }
public virtual void Awake()
{
if (Instance != null && Instance != this)
{
Destroy(gameObject);
}
View ListExtensionMethods.cs
using System.Collections.Generic;
using UnityEngine;
public static class ListExtensionMethods
{
public static T PickRandom<T>(this IList<T> list)
{
T result = default(T);
if (list.Count > 0)
View python-notes.sh
### virtualenv
# install virtualenv
sudo easy_install pip virtualenv
# create a virtualenv
mkdir new-project
cd new-project
virtualenv --no-site-package new-project-env
View points-on-circle.js
var DEG_TO_RAD = Math.PI / 180;
var num = 5;
var r = 1;
var startAngle = 90 * DEG_TO_RAD;
var angle = (360 / num) * DEG_TO_RAD;
var str = '';
View color-mix.js
var colorSpaces = ['rgb', 'hsl', 'lab', 'lch', 'lrgb'];
var colors1 = ["#b2182b", "#d6604d", "#f4a582", "#fddbc7"];
var colors2 = ["#2166ac", "#4393c3", "#92c5de", "#d1e5f0"];
var str = '';
for (let space of colorSpaces) {
str += '"--- ' + space + ' ---";\n';
View geometry-zine.js
let deg2rad = Math.PI / 180;
var viewBox = d3.select('svg').node().getAttribute('viewBox').split(/\s+|,/);
let width = Number.parseFloat(viewBox[2]);
let height = Number.parseFloat(viewBox[3]);
let center = [width/2, height/2];
let clipRadius = 20;
View color-wheel.html
<!DOCTYPE html>
<html>
<body>
<canvas id="myCanvas" width="1024" height="1024" style="border:1px solid #d3d3d3;"></canvas>
<script>
var c = document.getElementById("myCanvas");
var ctx = c.getContext("2d");
You can’t perform that action at this time.