コード例 #1
0
ファイル: main.go プロジェクト: ArchRobison/FrequonInvaders
func endGame() {
	teletype.Reset()
	n := universe.NKill()
	if n >= 64 {
		teletype.PrintUpper(grammar.Generate(rune('W')) + "\n")
	}
	if vanity.IsWorthyScore(records, uint8(n)) {
		setMode(modeName)
	} else {
		setMode(modeVanity)
	}
}
コード例 #2
0
ファイル: boot.go プロジェクト: ArchRobison/FrequonInvaders
/* The "boot sequence" was created in the 1990's to create eye candy while
   the program was slowly computing lookup tables.  By the mid-2000s machines
   were so fast that it has no practical purpose anymore.  But to retain
   the original look of Frequon Invaders, it's done nonethless, with the
   teletype techno-babble.  It like the flutes on concrete columnes. */
func advanceBootSequence(dt float32) {
	if bootSequenceIndex < 0 || bootSequenceIndex >= 10 {
		return
	}
	bootSequenceFrac += dt
	if bootSequenceFrac < bootSequencePeriod {
		return
	}
	bootSequenceFrac = 0
	n := bootSequenceIndex
	bootSequenceIndex = n + 1
	if 1 <= n && n <= 8 {
		teletype.PrintUpper(grammar.Generate(rune('0' + n)))
		teletype.PrintChar('\n')
	}
	if 0 < n && n <= 8 {
		sound.Play(sound.Wobble, float32(n+1)*0.25)
	}
	switch n {
	case 1:
		break
	case 2, 3, 4:
		dividerCount = n - 1
	case 5:
		fallIsVisible = true
	case 6:
		radarIsVisible = true
		radarIsRunning = true
	case 7:
		scoreIsVisible = true
	case 9:
		// C++ original does following actions for n==8, but that hides the 8th techobabble.
		fourierIsVisible = true
		setZoom(zoomGrow)
		teletype.Reset()
	}
}
コード例 #3
0
ファイル: main.go プロジェクト: ArchRobison/FrequonInvaders
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)
}
コード例 #4
0
ファイル: menu.go プロジェクト: ArchRobison/FrequonInvaders
	beginGameItem, trainingItem *menu.SimpleItem

	exitItem = menu.MakeSimpleItem("Exit", func() {
		nimble.Quit()
	})
)

// Items for "Display" menu
var autoGain = menu.MakeCheckItem("Autogain", true, nil)

// Items for "Ratings" menu
var (
	highScores *menu.SimpleItem
	cpuSpeed   = menu.MakeSimpleItem("CPU Speed", func() {
		teletype.Reset()
		teletype.PrintUpper(fmt.Sprintf("HFT SPEED = %.1f GFlops\n", fourier.Benchmark()*1E-9))
	})
)

// State of stationary/moving radio buttons on the "Invaders" menu.
var letFrequonsMove = menu.RadioState{OnSelect: func(value int) {
	if value == 0 {
		universe.SetVelocityMax(0)
	} else {
		universe.SetVelocityMax(30. / 1440. * math32.Sqrt(float32(screenWidth*screenHeight)))
	}
}}

// State of "maximum number of Frequons" buttons on the "Invaders" menu.
var maxFrequon = menu.RadioState{Value: 1, OnSelect: func(value int) {
	universe.SetNLiveMax(value)