go-tetris/tetris.go

43 lines
753 B
Go
Raw Permalink Normal View History

2017-03-27 15:07:29 -05:00
package main
import (
2018-06-01 10:16:36 -05:00
"log"
"math/rand"
2017-03-27 15:07:29 -05:00
"os"
"path/filepath"
"time"
2017-03-27 15:07:29 -05:00
)
func main() {
baseDir, _ = filepath.Abs(filepath.Dir(os.Args[0]))
2020-09-11 05:33:02 -05:00
logger = log.New(os.Stderr, "", log.Ldate|log.Ltime|log.LUTC|log.Lshortfile)
2018-06-01 10:16:36 -05:00
logFile, err := os.OpenFile(baseDir+"/go-tetris.log", os.O_RDWR|os.O_CREATE|os.O_APPEND, 0644)
if err != nil {
2019-12-01 15:03:27 -06:00
logger.Fatal("opening log file error:", err)
2017-03-27 15:07:29 -05:00
}
2018-06-01 10:16:36 -05:00
defer logFile.Close()
logger.SetOutput(logFile)
2017-03-27 15:07:29 -05:00
rand.Seed(time.Now().UnixNano())
2019-01-09 20:30:45 -06:00
err = loadBoards()
if err != nil {
2019-12-01 15:03:27 -06:00
logger.Fatal("loading internal boards error:", err)
2019-01-09 20:30:45 -06:00
}
err = loadUserBoards()
if err != nil {
2019-12-01 15:03:27 -06:00
logger.Fatal("loading user boards error:", err)
2019-01-09 20:30:45 -06:00
}
2019-12-01 15:03:27 -06:00
NewView()
NewMinos()
NewBoard()
2019-01-09 20:30:45 -06:00
NewEdit()
2019-12-01 15:03:27 -06:00
NewEngine()
2017-03-27 15:07:29 -05:00
2019-12-01 15:03:27 -06:00
engine.Start()
2017-03-27 15:07:29 -05:00
view.Stop()
}