Skip to content

Instantly share code, notes, and snippets.

View jackmott's full-sized avatar

Jack Mott jackmott

  • Looking for employment
  • Texas,USA
View GitHub Profile
@jackmott
jackmott / macfix.go
Created March 9, 2018 03:22
mac fix for rpg
package main
import (
"github.com/jackmott/rpg/game"
"github.com/jackmott/rpg/ui2d"
)
func main() {
game := game.NewGame(1, "game/maps/level1.map")
@jackmott
jackmott / apt.go
Created February 24, 2018 01:48
Expressions in Go
type Node interface {
Eval(x, y float32) float32
String() string
SetParent(parent Node)
GetParent() Node
GetChildren() []Node
SetChildren([]Node)
AddRandom(node Node)
AddLeaf(leaf Node) bool
NodeCount() int
@jackmott
jackmott / if.fs
Created February 12, 2018 01:43
if expression
x :=
if foo {
do_stuff() // returns an int
} else if bar {
a := do_stuff()
print("stuff"
3*a
} else {
5
}
@jackmott
jackmott / apt.go
Last active February 10, 2018 18:28
abstract picture tree
package apt
import (
"github.com/jackmott/noise"
"math"
"math/rand"
"strconv"
)
@jackmott
jackmott / simplex.go
Created January 21, 2018 19:47
simplex noise in go
/* This code ported to Go from Stefan Gustavson's C implementation, his comments follow:
* https://github.com/stegu/perlin-noise/blob/master/src/simplexnoise1234.c
* SimplexNoise1234, Simplex noise with true analytic
* derivative in 1D to 4D.
*
* Author: Stefan Gustavson, 2003-2005
* Contact: stefan.gustavson@liu.se
*
*
* This code was GPL licensed until February 2011.
@jackmott
jackmott / sdl2.go
Created January 15, 2018 15:05
Games With Go EP06 OSX fix
package main
// Experiment! draw some crazy stuff!
// Gist it next week and I'll show it off on stream
import (
"fmt"
"github.com/veandco/go-sdl2/sdl"
)
@jackmott
jackmott / draw.cs
Created December 22, 2017 18:33
monogame problem
public static void Draw(GameTime gameTime)
{
var effect = DDGame.contentManager.Load<Effect>("road");
effect.Parameters["TerrainTexture"].SetValue(MainState.level.tex);
effect.Parameters["MaskTexture"].SetValue(MainState.maskTex);
DDGame.batch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, null, null, null, effect);
DDGame.batch.Draw(MainState.roadTex, new Rectangle(0, 0, Settings.WINDOW_WIDTH, Settings.WINDOW_HEIGHT), Color.White);
DDGame.batch.End();
}
@jackmott
jackmott / RotatedRectangle.cs
Created October 11, 2017 14:06
Rotated rectangle collision detection
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
//Faster linq-style convenience functions https://github.com/jackmott/LinqFaster
using JM.LinqFaster;
namespace DrawAndDrive
{
@jackmott
jackmott / slow.md
Created July 10, 2017 14:45
A List Of Modern Software That Is Annoyingly Slow

I will add to this during the day each time I encounter annoyingly slow software

  • Microsoft Visual Studio 2015 Shell Uninstall. ~1 hour on an I7 laptop with an SSD
@jackmott
jackmott / finishline.rs
Created June 10, 2017 11:54
checkerboard pattern sdl2 rust
let mut finish_line_tex = texture_creator
.create_texture_streaming(PixelFormatEnum::RGB24,
FINISH_LINE_LENGTH as u32,
FINISH_LINE_WIDTH as u32)
.unwrap();
finish_line_tex.set_blend_mode(BlendMode::Add);
finish_line_tex
.with_lock(None,
|buffer: &mut [u8], pitch: usize| for y in 0..FINISH_LINE_WIDTH {