package main import ( "errors" "strings" "time" door "git.red-green.com/RedGreen/doorgo/door" ) var ( d door.Door db *DataBase ) func Notice(msg string) { if d.Disconnected { return } d.WriteS(door.SavePos + door.GotoS(0, door.Height-1) + door.Reset + strings.Repeat(" ", door.Width) + door.GotoS(0, door.Height-1) + msg + door.RestorePos) } func main() { d := door.Door{} d.Init("space_construct") defer d.Close() d.WriteS(door.Reset + door.Clrscr) // This entire thing takes 3/4 of a second (And stops immediately if any key or extended key occurs) txt := "Space Construct v1.0 Apollo@21:1/236" d.WriteS(door.SavePos + door.GotoS(door.Width/2-(len(txt)/2), door.Height/2) + door.ColorTextS("BRI WHI ON BLA") + txt + door.RestorePos) cont_display := true r, ext, err := d.WaitKey(time.Duration(250) * time.Millisecond) if err != nil { if errors.Is(err, door.ErrDisconnected) { return } } if r != 0 || ext != door.NOP { cont_display = false } if cont_display { d.WriteS(door.SavePos + door.GotoS(door.Width/2-(len(txt)/2), door.Height/2) + door.ColorTextS("WHI ON BLA") + txt + door.RestorePos) r, ext, err = d.WaitKey(time.Duration(250) * time.Millisecond) if err != nil { if errors.Is(err, door.ErrDisconnected) { return } } if r != 0 || ext != door.NOP { cont_display = false } if cont_display { d.WriteS(door.SavePos + door.GotoS(door.Width/2-(len(txt)/2), door.Height/2) + door.ColorTextS("BRI BLA ON BLA") + txt + door.RestorePos) _, _, err = d.WaitKey(time.Duration(250) * time.Millisecond) if err != nil { if errors.Is(err, door.ErrDisconnected) { return } } } } d.WriteS(door.Clrscr) db, err = OpenDB("data.db3") if err != nil { Notice(door.ColorTextS("BRI RED ON BLA") + "Err: " + err.Error()) d.WaitKey(door.Inactivity) return } defer db.Close() if db.GetShipModelById(1) == nil { db.SaveShipModel(&ShipModel{ Name: "Neptune I", BaseHull: 10, BaseShields: 0, Purchaseable: false, CostMetal: 10, CostCircuit: 0, MaxGuns: 2, MaxRocketLaunchers: 1, MaxArmorPlates: 1, MaxRepairBays: 0, MaxShieldCapacitors: 1, MaxShieldGenerators: 1, MaxEngines: 1, StartingGuns: 1, StartingRocketLaunchers: 0, StartingArmorPlates: 1, StartingRepairBays: 0, StartingRepairDrones: 0, StartingShieldCapacitors: 0, StartingShieldGenerators: 0, StartingEngines: 1, }) } }