ebs.go 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. package main
  2. // import "fmt"
  3. import "flag"
  4. import "runtime"
  5. import "gitlab.com/beoran/ebsgo/engine/global"
  6. import "gitlab.com/beoran/ebsgo/engine/fifi"
  7. import "gitlab.com/beoran/ebsgo/monolog"
  8. // import "path/filepath"
  9. // import "math/rand"
  10. // some parameters
  11. const SCREEN_W = 640
  12. const SCREEN_H = 480
  13. const WINDOW_TITLE = "Eruta Blessed Saviour"
  14. // Log levels for monolog
  15. type logLevels []string
  16. var EbsLogLevels logLevels = logLevels{
  17. "FATAL", "ERROR", "WARNING", "INFO",
  18. }
  19. // Command line flags
  20. var fullscreen_flag = flag.Bool("fullscreen", false, "Run fullscreen or not")
  21. var enable_logs = flag.String("el", "FATAL,ERROR,WARNING,INFO", "Log levels to enable")
  22. var disable_logs = flag.String("dl", "", "Log levels to disable")
  23. func enableDisableLogs() {
  24. monolog.EnableLevels(*enable_logs)
  25. monolog.DisableLevels(*disable_logs)
  26. monolog.Info("Log levels: %v", monolog.DefaultLog.EnabledLevels())
  27. }
  28. func init() {
  29. runtime.LockOSThread()
  30. }
  31. func main() {
  32. flag.Parse()
  33. monolog.Setup("ebsgo.log", true, false)
  34. defer monolog.Close()
  35. enableDisableLogs()
  36. state := global.State{}
  37. if ! fifi.Initialize() {
  38. monolog.Fatal("Could not find data file directory.")
  39. return
  40. }
  41. if ! state.InstallAllegro() {
  42. monolog.Fatal("Could not initialize allegro.")
  43. return
  44. }
  45. monolog.Info("Will open a screen, full screen: %B", *fullscreen_flag)
  46. if state.OpenDisplay(SCREEN_W, SCREEN_H, WINDOW_TITLE, *fullscreen_flag) == nil {
  47. monolog.Fatal("Error creating display.")
  48. return
  49. }
  50. state.Run()
  51. /*
  52. blue := CreateColor(0.0, 0.0, 1.0, 1.0)
  53. yellow := CreateColor(1.0, 1.0, 0.0, 1.0)
  54. ClearToColor(blue)
  55. DrawPixel(20.0, 10.0, yellow)
  56. FlipDisplay()
  57. Rest(1.0)
  58. display.SetWindowPosition(50, 100)
  59. ClearToColor(yellow)
  60. DrawPixel(20.0, 10.0, blue)
  61. FlipDisplay()
  62. display.Destroy()
  63. Rest(1.0)
  64. **/
  65. }