game

package
v0.0.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 15, 2024 License: GPL-2.0 Imports: 39 Imported by: 0

Documentation

Index

Constants

View Source
const (
	CONFIG_KEY_DEBUG   = "debug"
	CONFIG_KEY_SHOWFPS = "show_fps"

	CONFIG_KEY_SCREEN_WIDTH     = "screen.width"
	CONFIG_KEY_SCREEN_HEIGHT    = "screen.height"
	CONFIG_KEY_RENDER_SCALE     = "screen.render_scale"
	CONFIG_KEY_FOV_DEGREES      = "screen.fov_degrees"
	CONFIG_KEY_FULLSCREEN       = "screen.fullscreen"
	CONFIG_KEY_VSYNC            = "screen.vsync"
	CONFIG_KEY_RENDER_FLOOR     = "screen.render_floor"
	CONFIG_KEY_RENDER_DISTANCE  = "screen.render_distance"
	CONFIG_KEY_CLUTTER_DISTANCE = "screen.clutter_distance"
	CONFIG_KEY_OPENGL           = "screen.opengl"

	CONFIG_KEY_HUD_ENABLED      = "hud.enabled"
	CONFIG_KEY_HUD_SCALE        = "hud.scale"
	CONFIG_KEY_HUD_FONT         = "hud.font"
	CONFIG_KEY_HUD_COLOR_CUSTOM = "hud.color.use_custom"
	CONFIG_KEY_HUD_COLOR_R      = "hud.color.red"
	CONFIG_KEY_HUD_COLOR_G      = "hud.color.green"
	CONFIG_KEY_HUD_COLOR_B      = "hud.color.blue"
	CONFIG_KEY_HUD_COLOR_A      = "hud.color.alpha"

	CONFIG_KEY_AUDIO_BGM_VOL      = "audio.bgm_volume"
	CONFIG_KEY_AUDIO_SFX_VOL      = "audio.sfx_volume"
	CONFIG_KEY_AUDIO_SFX_CHANNELS = "audio.sfx_channels"

	CONFIG_KEY_CONTROL_DECAY = "controls.throttle_decay"
)
View Source
const (
	ActionUnknown input.Action = iota
	ActionUp
	ActionDown
	ActionLeft
	ActionRight
	ActionMoveAxes
	ActionTurretUp
	ActionTurretDown
	ActionTurretLeft
	ActionTurretRight
	ActionTurretAxes
	ActionMenu
	ActionBack
	ActionThrottleReverse
	ActionThrottle0
	ActionJumpJet
	ActionDescend
	ActionWeaponFire
	ActionWeaponCycle
	ActionWeaponGroupFireToggle
	ActionWeaponGroupSetModifier
	ActionWeaponGroup1
	ActionWeaponGroup2
	ActionWeaponGroup3
	ActionWeaponGroup4
	ActionWeaponGroup5
	ActionWeaponFireGroup1
	ActionWeaponFireGroup2
	ActionWeaponFireGroup3
	ActionWeaponFireGroup4
	ActionWeaponFireGroup5
	ActionNavCycle
	ActionTargetCrosshairs
	ActionTargetNearest
	ActionTargetNext
	ActionTargetPrevious
	ActionZoomToggle
	ActionLightAmpToggle
	ActionPowerToggle
)
View Source
const (
	StrideStompLeft  = -1
	StrideStompRight = 1
	StrideStompBoth  = 0
)
View Source
const (
	SPLASH_TIMEOUT = 5.0
)

Variables

This section is empty.

Functions

func JumpJetSFXForMech

func JumpJetSFXForMech(m *model.Mech) (string, error)

func NewUIResources

func NewUIResources(fonts *fonts) (*uiResources, error)

func StompSFXForMech

func StompSFXForMech(m *model.Mech) (string, error)

Types

type AudioHandler

type AudioHandler struct {
	// contains filtered or unexported fields
}

func NewAudioHandler

func NewAudioHandler() *AudioHandler

NewAudioHandler creates a new audio handler instance

func (*AudioHandler) EngineAmbience

func (a *AudioHandler) EngineAmbience() _sfxTypeHint

IsEngineAmbience indicates whether the current engine audio is the ambience loop

func (*AudioHandler) IsButtonAudioPlaying

func (a *AudioHandler) IsButtonAudioPlaying() bool

IsButtonAudioPlaying returns true if the button audio channel is still playing

func (*AudioHandler) IsMusicPlaying

func (a *AudioHandler) IsMusicPlaying() bool

IsMusicPlaying return true if background music is currently playing

func (*AudioHandler) PauseMusic

func (a *AudioHandler) PauseMusic()

PauseMusic pauses play of background music

func (*AudioHandler) PauseSFX

func (a *AudioHandler) PauseSFX()

PauseSFX pauses all sound effect sources

func (*AudioHandler) PlayButtonAudio

func (a *AudioHandler) PlayButtonAudio(buttonResource AudioInterfaceResource)

PlayButtonAudio plays the indicated button audio channel resource

func (*AudioHandler) PlayEffectAudio

func (a *AudioHandler) PlayEffectAudio(g *Game, p *render.EffectSprite)

PlayEffectAudio plays effect audio near the player

func (*AudioHandler) PlayEntityAudioLoop

func (a *AudioHandler) PlayEntityAudioLoop(g *Game, sfxFile string, entity model.Entity, intensityDist, maxVolume float64)

PlayEntityAudioLoop plays audio that may be near the player emitted from an Entity object intensityDist - distance of 100% sound intensity before volume begins to dropoff at a rate of 1/d^2 maxVolume - the maximum volume percent to be perceived by the player

func (*AudioHandler) PlayExternalAudio

func (a *AudioHandler) PlayExternalAudio(g *Game, sfxFile string, extPosX, extPosY, extPosZ, intensityDist, maxVolume float64)

PlayExternalAudio plays audio that may be near the player taking into account distance/direction for volume/panning intensityDist - distance of 100% sound intensity before volume begins to dropoff at a rate of 1/d^2 maxVolume - the maximum volume percent to be perceived by the player

func (*AudioHandler) PlayExternalWeaponFireAudio

func (a *AudioHandler) PlayExternalWeaponFireAudio(g *Game, weapon model.Weapon, extUnit model.Unit)

PlayExternalWeaponFireAudio plays weapon fire audio fired by units other than the player

func (*AudioHandler) PlayLocalWeaponFireAudio

func (a *AudioHandler) PlayLocalWeaponFireAudio(weapon model.Weapon)

PlayLocalWeaponFireAudio plays weapon fire audio intended only if fired by the player unit

func (*AudioHandler) PlayLoopEntitySFX

func (a *AudioHandler) PlayLoopEntitySFX(sfxFile string, entity model.Entity, sourceVolume, panPercent float64)

PlayLoopEntitySFX plays given looping sound effect as emitted from an Entity object, if not already playing

func (*AudioHandler) PlayPowerOffSequence

func (a *AudioHandler) PlayPowerOffSequence()

PlayPowerOffSequence plays the power down sound using the engine audio source

func (*AudioHandler) PlayPowerOnSequence

func (a *AudioHandler) PlayPowerOnSequence()

PlayPowerOnSequence plays the power on sound using the engine audio source

func (*AudioHandler) PlayProjectileImpactAudio

func (a *AudioHandler) PlayProjectileImpactAudio(g *Game, p *render.ProjectileSprite)

PlayProjectileImpactAudio plays projectile impact audio near the player

func (*AudioHandler) PlaySFX

func (a *AudioHandler) PlaySFX(sfxFile string, sourceVolume, panPercent float64)

PlaySFX plays given external sound effect file

func (*AudioHandler) ResumeMusic

func (a *AudioHandler) ResumeMusic()

ResumeMusic resumes play of background music

func (*AudioHandler) ResumeSFX

func (a *AudioHandler) ResumeSFX()

ResumeSFX resumes play of all sound effect sources

func (*AudioHandler) SetMusicVolume

func (a *AudioHandler) SetMusicVolume(strength float64)

SetMusicVolume sets volume of background music

func (*AudioHandler) SetSFXChannels

func (a *AudioHandler) SetSFXChannels(numChannels int)

SetSFXChannels sets max number of external sound effect channels

func (*AudioHandler) SetSFXVolume

func (a *AudioHandler) SetSFXVolume(strength float64)

SetSFXVolume sets volume of all sound effect sources

func (*AudioHandler) SetStompSFX

func (a *AudioHandler) SetStompSFX(sfxFile string)

func (*AudioHandler) StartEngineAmbience

func (a *AudioHandler) StartEngineAmbience()

StartEngineAmbience starts the ambient engine audio loop

func (*AudioHandler) StartMenuMusic

func (a *AudioHandler) StartMenuMusic()

StartMenuMusic starts main menu background music audio loop

func (*AudioHandler) StartMusicFromFile

func (a *AudioHandler) StartMusicFromFile(path string)

StartMusicFromFile starts background music audio loop

func (*AudioHandler) StopEngineAmbience

func (a *AudioHandler) StopEngineAmbience()

StopEngineAmbience stop the ambient engine audio loop

func (*AudioHandler) StopEntityAudioLoop

func (a *AudioHandler) StopEntityAudioLoop(g *Game, sfxFile string, entity model.Entity)

StopEntityAudioLoop stops audio emitted from an Entity object that may have been playing

func (*AudioHandler) StopLoopEntitySFX

func (a *AudioHandler) StopLoopEntitySFX(sfxFile string, entity model.Entity)

StopLoopEntitySFX stops given looping sound effect as emitted from an Entity object

func (*AudioHandler) StopMusic

func (a *AudioHandler) StopMusic()

StopMusic stops and closes the background music source

func (*AudioHandler) StopSFX

func (a *AudioHandler) StopSFX()

StopSFX stops and closes all sound effect sources

type AudioInterfaceResource

type AudioInterfaceResource string
const (
	AUDIO_BUTTON_AFF    AudioInterfaceResource = "audio/sfx/button-aff.ogg"
	AUDIO_BUTTON_NEG    AudioInterfaceResource = "audio/sfx/button-neg.ogg"
	AUDIO_BUTTON_OVER   AudioInterfaceResource = "audio/sfx/button-over.ogg"
	AUDIO_CLICK_AFF     AudioInterfaceResource = "audio/sfx/click-aff.ogg"
	AUDIO_CLICK_NEG     AudioInterfaceResource = "audio/sfx/click-neg.ogg"
	AUDIO_SELECT_TARGET AudioInterfaceResource = "audio/sfx/select-target.ogg"
)

type AudioMainSource

type AudioMainSource int
const (
	AUDIO_INTERFACE AudioMainSource = iota
	AUDIO_ENGINE
	AUDIO_STOMP_LEFT
	AUDIO_STOMP_RIGHT
	AUDIO_JUMP_JET
)

type BGMHandler

type BGMHandler struct {
	// contains filtered or unexported fields
}

type ClutterHandler

type ClutterHandler struct {
	// contains filtered or unexported fields
}

func NewClutterHandler

func NewClutterHandler() *ClutterHandler

func (*ClutterHandler) Update

func (c *ClutterHandler) Update(g *Game, forceUpdate bool)

type DelayedProjectileSpawn

type DelayedProjectileSpawn struct {
	// contains filtered or unexported fields
}

type EntityCollision

type EntityCollision struct {
	// contains filtered or unexported fields
}

type FloorTexture

type FloorTexture struct {
	// contains filtered or unexported fields
}

type Game

type Game struct {
	// contains filtered or unexported fields
}

Game - This is the main type for your game.

func NewGame

func NewGame() *Game

NewGame - Allows the game to perform any initialization it needs to before starting to run. This is where it can query for any required services and load any non-graphic related content. Calling base.Initialize will enumerate through any components and initialize them as well.

func (*Game) Draw

func (g *Game) Draw(screen *ebiten.Image)

Draw draws the game screen. Draw is called every frame (typically 1/60[s] for 60Hz display).

func (*Game) GetHUDElement

func (g *Game) GetHUDElement(t HUDElementType) HUDElement

func (*Game) Layout

func (g *Game) Layout(outsideWidth, outsideHeight int) (int, int)

Layout takes the outside size (e.g., the window size) and returns the (logical) screen size. If you don't have to adjust the screen size with the outside size, just return a fixed size.

func (*Game) Move

func (g *Game) Move(mSpeed float64)

Move player by move speed in the forward/backward direction

func (*Game) Pitch

func (g *Game) Pitch(pSpeed float64)

Update player pitch angle by pitch speed

func (*Game) Rotate

func (g *Game) Rotate(rSpeed float64)

Rotate player heading angle by rotation speed

func (*Game) RotateTurret

func (g *Game) RotateTurret(rSpeed float64)

Rotate player turret angle, relative to body heading, by rotation speed

func (*Game) Run

func (g *Game) Run()

Run is the Ebiten Run loop caller

func (*Game) SetPlayerUnit

func (g *Game) SetPlayerUnit(unit model.Unit)

func (*Game) Strafe

func (g *Game) Strafe(sSpeed float64)

Move player by strafe speed in the left/right direction

func (*Game) Update

func (g *Game) Update() error

Update - Allows the game to run logic such as updating the world, gathering input, and playing audio. Update is called every tick (1/60 [s] by default).

func (*Game) VerticalMove

func (g *Game) VerticalMove(vSpeed float64)

Move player by vertical speed in the up/down direction

type GameMenu

type GameMenu struct {
	*MenuModel
	// contains filtered or unexported fields
}

func (*GameMenu) Draw

func (m *GameMenu) Draw(screen *ebiten.Image)

func (*GameMenu) Update

func (m *GameMenu) Update()

type HUDElement

type HUDElement interface {
	Draw(bounds image.Rectangle, hudOpts *render.DrawHudOptions)
	Width() int
	Height() int
	Scale() float64
	SetScale(float64)
}

type HUDElementType

type HUDElementType int
const (
	HUD_FPS HUDElementType = iota
	HUD_ALTIMETER
	HUD_ARMAMENT
	HUD_COMPASS
	HUD_CROSSHAIRS
	HUD_HEAT
	HUD_JETS
	HUD_NAV_RETICLE
	HUD_NAV_STATUS
	HUD_PLAYER_STATUS
	HUD_RADAR
	HUD_TARGET_RETICLE
	HUD_TARGET_STATUS
	HUD_THROTTLE
	TOTAL_HUD_ELEMENT_TYPES
)

type InstantActionScene

type InstantActionScene struct {
	Game *Game
	// contains filtered or unexported fields
}

func NewInstantActionScene

func NewInstantActionScene(g *Game) *InstantActionScene

func (*InstantActionScene) Draw

func (s *InstantActionScene) Draw(screen *ebiten.Image)

func (*InstantActionScene) SetMenu

func (s *InstantActionScene) SetMenu(m Menu)

func (*InstantActionScene) Update

func (s *InstantActionScene) Update() error

type IntroScene

type IntroScene struct {
	Game *Game
	// contains filtered or unexported fields
}

func NewIntroScene

func NewIntroScene(g *Game) *IntroScene

func (*IntroScene) Draw

func (s *IntroScene) Draw(screen *ebiten.Image)

func (*IntroScene) Update

func (s *IntroScene) Update() error

type LaunchMenu

type LaunchMenu struct {
	*MenuModel
	// contains filtered or unexported fields
}

func (*LaunchMenu) Draw

func (m *LaunchMenu) Draw(screen *ebiten.Image)

func (*LaunchMenu) Update

func (m *LaunchMenu) Update()

type LogFormat

type LogFormat struct {
	TimestampFormat string
}

func (*LogFormat) Format

func (f *LogFormat) Format(entry *logrus.Entry) ([]byte, error)
type MainMenu struct {
	*MenuModel
}
func (m *MainMenu) Draw(screen *ebiten.Image)
func (m *MainMenu) Update()
type Menu interface {
	Active() bool
	Closing() bool
	UI() *ebitenui.UI
	Root() *widget.Container
	SetWindow(*widget.Window)
	CloseWindow() *widget.Window
	Resources() *uiResources
	Game() *Game
	FontScale() float64
	MarginX() int
	MarginY() int
	Padding() int
	Spacing() int
	Resolutions() []MenuResolution
	Update()
	Draw(screen *ebiten.Image)
}
type MenuAspectRatio struct {
	// contains filtered or unexported fields
}
type MenuModel struct {
	// contains filtered or unexported fields
}
func (m *MenuModel) Active() bool
func (m *MenuModel) CloseWindow() *widget.Window
func (m *MenuModel) Closing() bool
func (m *MenuModel) FontScale() float64
func (m *MenuModel) Game() *Game
func (m *MenuModel) MarginX() int
func (m *MenuModel) MarginY() int
func (m *MenuModel) Padding() int
func (m *MenuModel) Resolutions() []MenuResolution
func (m *MenuModel) Resources() *uiResources
func (m *MenuModel) Root() *widget.Container
func (m *MenuModel) SetWindow(window *widget.Window)
func (m *MenuModel) Spacing() int
func (m *MenuModel) UI() *ebitenui.UI
type MenuResolution struct {
	// contains filtered or unexported fields
}
func (r MenuResolution) String() string
type MenuScene struct {
	Game *Game
	// contains filtered or unexported fields
}

func NewMenuScene

func NewMenuScene(g *Game) *MenuScene
func (s *MenuScene) Draw(screen *ebiten.Image)
func (s *MenuScene) SetMenu(m Menu)
func (s *MenuScene) Update() error

type MissionCard

type MissionCard struct {
	*widget.Container
	// contains filtered or unexported fields
}

type MissionCardStyle

type MissionCardStyle int
const (
	MissionCardSelect MissionCardStyle = iota
	MissionCardLaunch
)

type MissionMenu

type MissionMenu struct {
	*MenuModel
	// contains filtered or unexported fields
}

func (*MissionMenu) Draw

func (m *MissionMenu) Draw(screen *ebiten.Image)

func (*MissionMenu) Update

func (m *MissionMenu) Update()

type MissionScene

type MissionScene struct {
	Game *Game
}

func NewMissionScene

func NewMissionScene(g *Game) *MissionScene

func (*MissionScene) Draw

func (s *MissionScene) Draw(screen *ebiten.Image)

func (*MissionScene) Update

func (s *MissionScene) Update() error

type MouseMode

type MouseMode int
const (
	MouseModeTurret MouseMode = iota
	MouseModeBody
	MouseModeCursor
)

type Player

type Player struct {
	model.Unit
	// contains filtered or unexported fields
}

func NewPlayer

func NewPlayer(unit model.Unit, sprite *render.Sprite, x, y, z, angle, pitch float64) *Player

func (*Player) CameraPosition

func (p *Player) CameraPosition() (pos *geom.Vector2, posZ float64)

func (*Player) SetPosZ

func (p *Player) SetPosZ(z float64)

func (*Player) Update

func (p *Player) Update() bool

type SFXHandler

type SFXHandler struct {
	// contains filtered or unexported fields
}

type SFXSource

type SFXSource struct {
	// contains filtered or unexported fields
}

func NewSoundEffectSource

func NewSoundEffectSource(sourceVolume float64) *SFXSource

NewSoundEffectSource creates a new sound effect channel

func (*SFXSource) Close

func (s *SFXSource) Close()

Close stops and closes the sound effect player

func (*SFXSource) IsPlaying

func (s *SFXSource) IsPlaying() bool

IsPlaying returns true if the sound effect is currently playing

func (*SFXSource) LoadLoopSFX

func (s *SFXSource) LoadLoopSFX(a *AudioHandler, sfxFile string) error

LoadLoopSFX loads a new looping sound effect player into the sound effect channel

func (*SFXSource) LoadSFX

func (s *SFXSource) LoadSFX(a *AudioHandler, sfxFile string) error

LoadSFX loads a new sound effect player into the sound effect channel

func (*SFXSource) Pause

func (s *SFXSource) Pause()

Pause pauses the sound effect player

func (*SFXSource) Play

func (s *SFXSource) Play()

Play starts playing the sound effect player from the beginning of the effect

func (*SFXSource) Resume

func (s *SFXSource) Resume()

Resume resumes the sound effect player without rewinding

func (*SFXSource) SetPan

func (s *SFXSource) SetPan(panPercent float64)

SetPan sets the left/right panning percent of the sound channel

func (*SFXSource) SetSourceVolume

func (s *SFXSource) SetSourceVolume(sourceVolume float64)

SetSourceVolume sets the relative volume modifier of the sound channel

func (*SFXSource) UpdateVolume

func (s *SFXSource) UpdateVolume()

UpdateVolume updates the volume of the sound channel taking into account relative volume modifier

type Scene

type Scene interface {
	Update() error
	Draw(*ebiten.Image)
}

type SceneEffect

type SceneEffect interface {
	Update() error
	Draw(*ebiten.Image)
}

type SceneTransition

type SceneTransition interface {
	Update() error
	Draw(*ebiten.Image)
}

type SettingsMenu

type SettingsMenu struct {
	*MenuModel
	// contains filtered or unexported fields
}

func (*SettingsMenu) Draw

func (m *SettingsMenu) Draw(screen *ebiten.Image)

func (*SettingsMenu) Update

func (m *SettingsMenu) Update()

type SplashScreen

type SplashScreen struct {
	*ebiten.Image
	// contains filtered or unexported fields
}

type SpriteHandler

type SpriteHandler struct {
	// contains filtered or unexported fields
}

func NewSpriteHandler

func NewSpriteHandler() *SpriteHandler

type SpriteType

type SpriteType int
const (
	MapSpriteType SpriteType = iota
	MechSpriteType
	VehicleSpriteType
	VTOLSpriteType
	InfantrySpriteType
	EmplacementSpriteType
	ProjectileSpriteType
	EffectSpriteType
	TotalSpriteTypes
)

type StrideDirection

type StrideDirection uint
const (
	StrideUp StrideDirection = iota
	StrideDown
)

type TargetCycleType

type TargetCycleType int
const (
	TARGET_NEXT TargetCycleType = iota
	TARGET_PREVIOUS
	TARGET_NEAREST
)

type TextureHandler

type TextureHandler struct {
	// contains filtered or unexported fields
}

func NewTextureHandler

func NewTextureHandler(mapObj *model.Map) *TextureHandler

func (*TextureHandler) FloorTextureAt

func (t *TextureHandler) FloorTextureAt(x, y int) *image.RGBA

func (*TextureHandler) TextureAt

func (t *TextureHandler) TextureAt(x, y, levelNum, side int) *ebiten.Image

type UnitCard

type UnitCard struct {
	*widget.Container
	// contains filtered or unexported fields
}

type UnitCardStyle

type UnitCardStyle int
const (
	UnitCardSelect UnitCardStyle = iota
	UnitCardLaunch
	UnitCardMission
)

type UnitMenu

type UnitMenu struct {
	*MenuModel
	// contains filtered or unexported fields
}

func (*UnitMenu) Draw

func (m *UnitMenu) Draw(screen *ebiten.Image)

func (*UnitMenu) Update

func (m *UnitMenu) Update()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL