Skip to content

Instantly share code, notes, and snippets.

@egonelbre
egonelbre / main.go
Created March 1, 2018 18:09
Size visual changing
package main
import (
"encoding/hex"
"fmt"
"math/rand"
"github.com/gopherjs/vecty"
"github.com/gopherjs/vecty/elem"
"github.com/gopherjs/vecty/event"
@egonelbre
egonelbre / main.go
Last active October 14, 2018 02:17
Vecty bugs
package main
import (
"encoding/hex"
"fmt"
"math/rand"
"github.com/gopherjs/vecty"
"github.com/gopherjs/vecty/elem"
"github.com/gopherjs/vecty/event"
package main
import (
"fmt"
"reflect"
)
func assert(k bool, msg string) {
if !k {
panic(msg)
@egonelbre
egonelbre / main.go
Created August 23, 2017 09:34
Go: reflection based generation (https://play.golang.org/p/y5qKxuoV9t)
package main
import (
"fmt"
"reflect"
"time"
)
type Status struct {
APC string
@egonelbre
egonelbre / collision.cpp
Created August 9, 2017 09:06
Shape Collision
#include "stdio.h"
#include "math.h"
#include "assert.h"
#define static_assert _Static_assert
typedef float f32;
typedef struct Vec2 { f32 X, Y; } Vec2;
float Vec2_Distance(Vec2 a, Vec2 b){
f32 dx = a.X - b.X;
@egonelbre
egonelbre / ebiten-bad.s
Created March 4, 2017 20:32
ebiten compilation issue
TEXT github.com/hajimehoshi/ebiten.vertices(SB)
:0 0xebc68 e59a1008 MOVW 0x8(R10), R1
:0 0xebc6c e15d0001 CMP R1, R13
:0 0xebc70 9a000227 B.LS 0xec514
:0 0xebc74 e52de068 MOVW.W R14, -0x68(R13)
:0 0xebc78 ebffd931 BL github.com/hajimehoshi/ebiten/internal/graphics.QuadVertexSizeInBytes(SB)
:0 0xebc7c e59d0004 MOVW 0x4(R13), R0
:0 0xebc80 e58d0060 MOVW R0, 0x60(R13)
:0 0xebc84 e59d106c MOVW 0x6c(R13), R1
:0 0xebc88 e5912018 MOVW 0x18(R1), R2
set VCVARS="C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat"
call %VCVARS% x64
cl /O1 -Feloader.64.exe loader.cpp
call %VCVARS% x86
cl /O1 -Feloader.32.exe loader.cpp
del *.obj
@egonelbre
egonelbre / build.bat
Created November 14, 2016 12:32
shell32 load time measurement
rem don't use optimizations otherwise cl may remove Shell32 dependency
cl dynamic.cpp
cl static.cpp
cl none.cpp
del *.obj
rem compiled x64 https://dl.dropboxusercontent.com/u/4300994/Go/measure-shell32-loading.zip
@egonelbre
egonelbre / glfw_example.go
Last active August 21, 2023 15:15
Input handling in Go for games
// adjust the input/controller to your own liking
type Device interface {
Update(input *Controller, window *glfw.Window)
}
// this is the general
type Controller struct {
ID int
Device Device
use as
go build -gantt <project> 2> build.html
then add <table> and </table> to the beginning and end of build.html