Skip to content

Instantly share code, notes, and snippets.

View faiface's full-sized avatar

Michal Štrba faiface

View GitHub Profile
@faiface
faiface / gist:1ef3eb4f19cb3efbbf49b59b31652283
Created May 4, 2017 14:41
Replace "Pacifico.ttf" with arbitrary TTF font file path
package main
import (
"fmt"
"io/ioutil"
"math/rand"
"os"
"time"
_ "image/jpeg"
@faiface
faiface / .go
Created May 4, 2017 14:44
Replace "Pacifico.ttf" with an actual TTF file path
package main
import (
"fmt"
"io/ioutil"
"math/rand"
"os"
"time"
_ "image/jpeg"
Operation complex128 struct
New vector pixel.V(x, y) pixel.Vec{X: x, Y: y} or pixel.V(x, y)
Get coord u.X() u.X
Set coord u = u.WithX(x) u.X = x
Add to coord u += pixel.X(x) u.X += x
Mul coord u = u.ScaledXY(pixel.V(c, 1)) u.X *= c
Add vectors u + v u.Add(v)
Scale vector u = u.Scaled(c) u = u.Scaled(c)
Mul vectors u = u.ScaledXY(v) u = u.ScaledXY(v)
package main
import (
"image"
"image/draw"
"math/rand"
"golang.org/x/image/colornames"
"github.com/faiface/pixel"
cmd1 := exec.Command("cmd1")
cmd2 := exec.Command("cmd2")
cmd1.Stdin = cmd2.Stdout
cmd2.Stdin = cmd1.Stdout
cmd1.Start()
cmd2.Start()
type Proboj interface {
ReadPlayer(r io.Reader) interface{}
ActPlayer(i int, turn interface{})
WriteState(w io.Writer)
Update()
}
func RunProboj(proboj Proboj, players []string) {
turnChans := make([]chan interface{}, len(players))
playerIns := make([]io.Writer, len(players))
package main
import (
"math"
"time"
"github.com/faiface/pixel/audio"
"github.com/faiface/pixel/audio/speaker"
)
package main
import (
"math"
"time"
"github.com/faiface/pixel/audio"
"github.com/faiface/pixel/audio/speaker"
)
package main
import (
"math"
"time"
"github.com/faiface/pixel"
"github.com/faiface/pixel/audio"
"github.com/faiface/pixel/audio/speaker"
"github.com/faiface/pixel/pixelgl"
@faiface
faiface / .go
Last active July 7, 2017 11:31
package main
import (
"math"
"time"
"github.com/faiface/pixel"
"github.com/faiface/pixel/audio"
"github.com/faiface/pixel/audio/speaker"
"github.com/faiface/pixel/pixelgl"