Example #1
0
func acceptScore(score uint8, name string) {
	records = vanity.Insert(records, score, name)
	err := vanity.WriteToFile(records)
	setMode(modeVanity)
	if err != nil {
		teletype.Print(err.Error())
	}
}
Example #2
0
func (context) Init(width, height int32) {
	if width < 640 || height < 400 {
		panic(fmt.Sprintf("screen size of %v x %v is too small!", width, height))
	}
	screenWidth, screenHeight = width, height
	nShade := int32(math32.Round(math32.Sqrt(float32(width*height)) * (32. / 1440)))
	initCritterSprites(width, height)
	pastels = coloring.PastelPalette(universe.MaxCritter, nShade)
	teletype.Init("Characters.png")
	if benchmarking {
		bootSequencePeriod = 0
		setMode(modeTraining)
	} else {
		setMode(modeSplash) // N.B. also causes partitionScreen to be called
		if devConfig {
			teletype.Print("[debug mode]\n")
		}
	}
}
Example #3
0
func setMode(m mode) {
	fourierIsVisible = false
	fallIsVisible = false
	radarIsVisible = false
	scoreIsVisible = false
	dividerCount = 0
	switch m {
	case modeSplash:
		teletype.PrintUpper(title + "\n")
		teletype.PrintUpper(edition + "\n")
		teletype.PrintUpper("By Arch D. Robison\n")
		var err error
		records, err = vanity.ReadFromFile()
		if err != nil {
			if devConfig {
				teletype.Print(err.Error())
			}
		}
	case modeName:
		teletype.Reset()
		teletype.PrintUpper(grammar.GenerateWithNumber(rune('H'), universe.NKill()) + "\n")
		teletype.PrintUpper("Please enter your name:\n")
		teletype.DisplayCursor(true)
	case modeTraining, modeGame:
		universe.BeginGame(m == modeTraining)
		// Temporarily set NLiveMax to 0.  End of boot sequence will set it to 1.
		universe.SetNLiveMax(0)
		startBootSequence()
	case modeVanity:
		teletype.Reset()
		teletype.DisplayCursor(false)
		teletype.PrintUpper("Supreme Freqs\n\nScore Player\n")
		for _, r := range records {
			teletype.PrintUpper(fmt.Sprintf("%5d %s\n", r.Score, r.Name))
		}
	}
	currentMode = m
	setMenus(m)
}