diff --git a/engine/debug.go b/engine/debug.go index d4c4567..a01e5dd 100644 --- a/engine/debug.go +++ b/engine/debug.go @@ -1,13 +1,9 @@ package engine import ( - "compress/gzip" "encoding/gob" - "errors" "fmt" "math" - "os" - "time" "github.com/hajimehoshi/ebiten/v2" "github.com/hajimehoshi/ebiten/v2/ebitenutil" @@ -17,14 +13,9 @@ var ( _ Drawer = PerfDisplay{} _ DrawOrderer = PerfDisplay{} _ Hider = &PerfDisplay{} - - _ Disabler = &GobDumper{} - _ Prepper = &GobDumper{} - _ Updater = &GobDumper{} ) func init() { - gob.Register(&GobDumper{}) gob.Register(&PerfDisplay{}) } @@ -76,44 +67,3 @@ func (PerfDisplay) DrawOrder() float64 { // Always draw on top return math.MaxFloat64 } - -// GobDumper waits for a given key combo, then dumps the game into a gob file -// in the current directory. -type GobDumper struct { - Disabled - KeyCombo []ebiten.Key - - game *Game -} - -// Prepare simply stores the reference to the Game. -func (d *GobDumper) Prepare(g *Game) { d.game = g } - -// Update waits for the key combo, then dumps the game state into a gzipped gob. -func (d *GobDumper) Update() error { - if d.Disabled { - return nil - } - for _, key := range d.KeyCombo { - if !ebiten.IsKeyPressed(key) { - return nil - } - } - if d.game == nil { - return errors.New("nil d.game in GobDumper.Update") - } - f, err := os.Create(time.Now().Format("20060102030405.gob.gz")) - if err != nil { - return err - } - defer f.Close() - gz := gzip.NewWriter(f) - defer gz.Close() - if err := gob.NewEncoder(gz).Encode(d.game); err != nil { - return err - } - if err := gz.Close(); err != nil { - return err - } - return f.Close() -} diff --git a/main.go b/main.go index acdb39d..d3c63b1 100644 --- a/main.go +++ b/main.go @@ -119,9 +119,6 @@ func main() { Root: &engine.Scene{ ID: "root", Components: []interface{}{ - &engine.GobDumper{ - KeyCombo: []ebiten.Key{ebiten.KeyControl, ebiten.KeyD}, - }, &engine.Camera{ ID: "game_camera", Scene: &engine.SceneRef{Path: "assets/level1.gobz"},