Twin-stick shooter
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

70 lines
1.0 KiB

2 months ago
package main
import (
"log"
"math/rand"
_ "net/http/pprof"
2 months ago
"os"
"os/signal"
"syscall"
"time"
2 months ago
"github.com/hajimehoshi/ebiten/v2"
)
func main() {
rand.Seed(time.Now().UnixNano())
2 months ago
ebiten.SetWindowTitle("Carotid Artillery")
ebiten.SetWindowResizable(true)
ebiten.SetFullscreen(true)
ebiten.SetMaxTPS(144)
2 months ago
ebiten.SetRunnableOnUnfocused(true) // Note - this currently does nothing in ebiten
ebiten.SetWindowClosingHandled(true)
ebiten.SetFPSMode(ebiten.FPSModeVsyncOn)
g, err := NewGame()
if err != nil {
log.Fatal(err)
}
1 month ago
parseFlags(g)
2 months ago
sigc := make(chan os.Signal, 1)
signal.Notify(sigc,
syscall.SIGINT,
syscall.SIGTERM)
go func() {
<-sigc
g.exit()
}()
// Handle warp.
if g.levelNum > 0 {
warpTo := g.levelNum
go func() {
time.Sleep(2 * time.Second)
g.Lock()
defer g.Unlock()
g.reset()
g.levelNum = warpTo - 1
g.nextLevel()
}()
}
err = g.reset()
if err != nil {
panic(err)
}
if !g.debugMode {
g.gameStartTime = time.Time{}
}
2 months ago
err = ebiten.RunGame(g)
if err != nil {
log.Fatal(err)
}
}