Example #1
0
func updateZoom(dt float32) {
	z := zoomAmount + zoomRate*dt
	if z > 1 {
		z = 1
		if zoomAmount < 1 {
			// Have reached full zoom.  Enable birthing of Frequons.
			if currentMode == modeGame {
				universe.SetNLiveMax(1)
			} else if benchmarking {
				universe.SetNLiveMax(8)
			} else {
				universe.SetNLiveMax(maxFrequon.Value)
			}
		}
	} else if z < 0 {
		z = 0
	}
	zoomAmount = z
	if z != 0 {
		const min, max = 1., 16.
		zoomCompression = min / (min + (max-min)*(1-z))
	} else {
		fourierIsVisible = false
		endGame()
	}
}
Example #2
0
// Set zoom rate.  Argument should be zoomGrow or zoomShrink for normal speed.
func setZoom(dir float32) {
	zoomRate = dir
	if benchmarking {
		// Accelerate zoom
		zoomRate *= 20
	}
	if dir > 0 {
		zoomAmount = 0
		// Disable birthing of Frequons until zoom completes.
		universe.SetNLiveMax(0)
	} else {
		// Use current zoomAmount
	}
}
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)
}
Example #4
0
		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)
}}

// Entry for "Color" menu
type colorSchemeItem struct {
	name    string              // Name of scheme
	missing coloring.SchemeBits // Aspect that is missing from the color scheme
}

var colorSchemeInfo = []colorSchemeItem{
	{"Complex", 0},
	{"Real", coloring.ImagBit},
	{"Imaginary", coloring.RealBit},
	{"Magnitude", coloring.PhaseBit},
	{"Phase", coloring.MagnitudeBit},
}