1
1
mirror of https://github.com/OpenDiablo2/OpenDiablo2 synced 2024-11-02 09:17:19 -04:00
OpenDiablo2/main.go

37 lines
978 B
Go
Raw Normal View History

2019-10-24 09:31:59 -04:00
package main
import (
"log"
"github.com/essial/OpenDiablo2/Core"
2019-10-25 19:37:04 -04:00
"github.com/essial/OpenDiablo2/MPQ"
2019-10-24 09:31:59 -04:00
"github.com/hajimehoshi/ebiten"
)
var d2Engine *Core.Engine
2019-10-24 09:31:59 -04:00
func main() {
log.SetFlags(log.Ldate | log.LUTC | log.Lmicroseconds | log.Llongfile)
2019-10-24 09:31:59 -04:00
log.Println("OpenDiablo2 - Open source Diablo 2 engine")
2019-10-25 19:37:04 -04:00
MPQ.InitializeCryptoBuffer()
d2Engine = Core.CreateEngine()
2019-10-24 09:31:59 -04:00
ebiten.SetCursorVisible(false)
ebiten.SetFullscreen(d2Engine.Settings.FullScreen)
ebiten.SetRunnableInBackground(d2Engine.Settings.RunInBackground)
ebiten.SetVsyncEnabled(d2Engine.Settings.VsyncEnabled)
ebiten.SetMaxTPS(d2Engine.Settings.TicksPerSecond)
if err := ebiten.Run(update, 800, 600, d2Engine.Settings.Scale, "OpenDiablo 2"); err != nil {
log.Fatal(err)
}
}
func update(screen *ebiten.Image) error {
d2Engine.Update()
if ebiten.IsDrawingSkipped() {
return nil
}
d2Engine.Draw(screen)
//ebitenutil.DebugPrint(screen, "FPS:"+strconv.Itoa(int(ebiten.CurrentFPS())))
2019-10-24 09:31:59 -04:00
return nil
}