render

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: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateNavImage

func GenerateNavImage(navPoint *model.NavPoint, imageSize int, font *Font, clr *color.NRGBA) *ebiten.Image

func GetSpriteSheetSlices

func GetSpriteSheetSlices(img *ebiten.Image, columns, rows int) ([]*ebiten.Image, []image.Rectangle)

Types

type Altimeter

type Altimeter struct {
	HUDSprite
	// contains filtered or unexported fields
}

func NewAltimeter

func NewAltimeter(font *Font) *Altimeter

NewAltimeter creates a compass image to be rendered on demand

func (*Altimeter) Draw

func (a *Altimeter) Draw(bounds image.Rectangle, hudOpts *DrawHudOptions)

func (*Altimeter) SetValues

func (a *Altimeter) SetValues(altitude, pitch float64)

type Armament

type Armament struct {
	HUDSprite
	// contains filtered or unexported fields
}

func NewArmament

func NewArmament(font *Font) *Armament

NewArmament creates a weapon list image to be rendered on demand

func (*Armament) Draw

func (a *Armament) Draw(bounds image.Rectangle, hudOpts *DrawHudOptions)

func (*Armament) SetSelectedWeapon

func (a *Armament) SetSelectedWeapon(weaponOrGroupIndex uint, weaponFireMode model.WeaponFireMode)

func (*Armament) SetWeaponGroups

func (a *Armament) SetWeaponGroups(weaponGroups [][]model.Weapon)

func (*Armament) SetWeapons

func (a *Armament) SetWeapons(weapons []model.Weapon)

type BasicHUD

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

func NewHUDSprite

func NewHUDSprite(img *ebiten.Image, scale float64) *BasicHUD

func NewHUDSpriteFromSheet

func NewHUDSpriteFromSheet(img *ebiten.Image, scale float64, columns, rows, frameIndex int) *BasicHUD

func (*BasicHUD) Height

func (h *BasicHUD) Height() int

func (*BasicHUD) NumTextureFrames

func (h *BasicHUD) NumTextureFrames() int

func (*BasicHUD) Scale

func (h *BasicHUD) Scale() float64

func (*BasicHUD) SetScale

func (h *BasicHUD) SetScale(scale float64)

func (*BasicHUD) SetTextureFrame

func (h *BasicHUD) SetTextureFrame(texNum int)

func (*BasicHUD) Texture

func (h *BasicHUD) Texture() *ebiten.Image

func (*BasicHUD) Width

func (h *BasicHUD) Width() int

type Compass

type Compass struct {
	HUDSprite
	// contains filtered or unexported fields
}

func NewCompass

func NewCompass(font *Font) *Compass

NewCompass creates a compass image to be rendered on demand

func (*Compass) Draw

func (c *Compass) Draw(bounds image.Rectangle, hudOpts *DrawHudOptions)

func (*Compass) SetNavEnabled

func (c *Compass) SetNavEnabled(b bool)

func (*Compass) SetNavHeading

func (c *Compass) SetNavHeading(heading float64)

func (*Compass) SetTargetEnabled

func (c *Compass) SetTargetEnabled(b bool)

func (*Compass) SetTargetHeading

func (c *Compass) SetTargetHeading(heading float64)

func (*Compass) SetValues

func (c *Compass) SetValues(heading, turretAngle float64)

type Crosshairs

type Crosshairs struct {
	HUDSprite
}

func NewCrosshairs

func NewCrosshairs(
	img *ebiten.Image, scale float64, columns, rows, crosshairIndex int,
) *Crosshairs

func (*Crosshairs) Draw

func (c *Crosshairs) Draw(bounds image.Rectangle, hudOpts *DrawHudOptions)

type DrawHudOptions

type DrawHudOptions struct {
	Screen           *ebiten.Image
	HudRect          image.Rectangle
	MarginX, MarginY int
	UseCustomColor   bool
	Color            color.NRGBA
}

func (*DrawHudOptions) HudColor

func (o *DrawHudOptions) HudColor(defaultColor color.NRGBA) color.NRGBA

HudColor gets the color that should be used by a HUD element based on its default or custom user color setting

type EffectSprite

type EffectSprite struct {
	*Sprite
	LoopCount int
	AudioFile string

	AttachedTo    *Sprite
	AttachedDepth float64
}

func NewAnimatedEffect

func NewAnimatedEffect(
	r *model.ModelEffectResource, img *ebiten.Image, loopCount int,
) *EffectSprite

func (*EffectSprite) AnimationDuration

func (e *EffectSprite) AnimationDuration() int

func (*EffectSprite) Clone

func (e *EffectSprite) Clone() *EffectSprite

func (*EffectSprite) Update

func (e *EffectSprite) Update(camPos *geom.Vector2)

type EmplacementSprite

type EmplacementSprite struct {
	*Sprite
}

func NewEmplacementSprite

func NewEmplacementSprite(
	emplacement *model.Emplacement, scale float64, img *ebiten.Image,
) *EmplacementSprite

func (*EmplacementSprite) Clone

func (t *EmplacementSprite) Clone(asUnit model.Unit) *EmplacementSprite

type FPSIndicator

type FPSIndicator struct {
	HUDSprite
	// contains filtered or unexported fields
}

func NewFPSIndicator

func NewFPSIndicator(font *Font) *FPSIndicator

NewFPSIndicator creates an FPS indicator to be rendered on demand

func (*FPSIndicator) Draw

func (f *FPSIndicator) Draw(bounds image.Rectangle, hudOpts *DrawHudOptions)

func (*FPSIndicator) SetFPSText

func (f *FPSIndicator) SetFPSText(fpsText string)

type Font

type Font struct {
	*etxt.Font
	FontCache *ecache.DefaultCache
	FontName  string
	FontPath  string
}

type FontHandler

type FontHandler struct {
	HUDFont *Font
}

func NewFontHandler

func NewFontHandler(hudFont string) (*FontHandler, error)

func (*FontHandler) LoadFont

func (f *FontHandler) LoadFont(fontFile string) (*Font, error)

type HUDSprite

type HUDSprite interface {
	Width() int
	Height() int
	Scale() float64
	SetScale(float64)

	Texture() *ebiten.Image
	NumTextureFrames() int
	SetTextureFrame(int)
}

type HeatIndicator

type HeatIndicator struct {
	HUDSprite
	// contains filtered or unexported fields
}

func NewHeatIndicator

func NewHeatIndicator(font *Font) *HeatIndicator

NewHeatIndicator creates a heat indicator image to be rendered on demand

func (*HeatIndicator) Draw

func (h *HeatIndicator) Draw(bounds image.Rectangle, hudOpts *DrawHudOptions)

func (*HeatIndicator) SetValues

func (h *HeatIndicator) SetValues(heat, maxHeat, dissipation float64)

type InfantrySprite

type InfantrySprite struct {
	*Sprite

	// TODO: move to separate AI handler
	PatrolPathIndex int
	PatrolPath      [][2]float64
}

func NewInfantrySprite

func NewInfantrySprite(
	infantry *model.Infantry, scale float64, img *ebiten.Image,
) *InfantrySprite

func (*InfantrySprite) Clone

func (t *InfantrySprite) Clone(asUnit model.Unit) *InfantrySprite

type JumpJetIndicator

type JumpJetIndicator struct {
	HUDSprite
	// contains filtered or unexported fields
}

func NewJumpJetIndicator

func NewJumpJetIndicator(font *Font) *JumpJetIndicator

NewJumpJetIndicator creates a jump jet indicator image to be rendered on demand

func (*JumpJetIndicator) Draw

func (j *JumpJetIndicator) Draw(bounds image.Rectangle, hudOpts *DrawHudOptions)

func (*JumpJetIndicator) SetValues

func (j *JumpJetIndicator) SetValues(jumpJetDuration, maxJumpJetDuration float64)

type MechAnimationIndex

type MechAnimationIndex int
const (
	MECH_ANIMATE_IDLE MechAnimationIndex = iota
	MECH_ANIMATE_STRUT
	MECH_ANIMATE_JUMP_JET
	MECH_ANIMATE_SHUTDOWN
	MECH_ANIMATE_DESTRUCT
	NUM_MECH_ANIMATIONS
	MECH_ANIMATE_STATIC MechAnimationIndex = -1
)

type MechPart

type MechPart int
const (
	MECH_PART_STATIC MechPart = 0
	MECH_PART_CT     MechPart = 1
	MECH_PART_LA     MechPart = 2
	MECH_PART_RA     MechPart = 3
	MECH_PART_LL     MechPart = 4
	MECH_PART_RL     MechPart = 5
	NUM_MECH_PARTS   MechPart = 6
)

type MechSprite

type MechSprite struct {
	*Sprite

	// TODO: move to separate AI handler
	PatrolPathIndex int
	PatrolPath      [][2]float64

	// TODO: general purpose method to track state of similar things
	JetsPlaying bool
	// contains filtered or unexported fields
}

func NewMechSprite

func NewMechSprite(
	mech *model.Mech, scale float64, img *ebiten.Image,
) *MechSprite

func (*MechSprite) Clone

func (m *MechSprite) Clone(asUnit model.Unit) *MechSprite

func (*MechSprite) Mech

func (m *MechSprite) Mech() *model.Mech

func (*MechSprite) MechAnimation

func (s *MechSprite) MechAnimation() MechAnimationIndex

func (*MechSprite) ResetAnimation

func (s *MechSprite) ResetAnimation()

func (*MechSprite) ResetStrideStomp

func (s *MechSprite) ResetStrideStomp()

func (*MechSprite) SetMechAnimation

func (s *MechSprite) SetMechAnimation(animateIndex MechAnimationIndex, reversed bool)

func (*MechSprite) StrideStomp

func (s *MechSprite) StrideStomp() bool

func (*MechSprite) Update

func (s *MechSprite) Update(camPos *geom.Vector2)

type MechSpriteAnimate

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

func NewMechAnimationSheetFromImage

func NewMechAnimationSheetFromImage(srcImage *ebiten.Image) *MechSpriteAnimate

NewMechAnimationSheetFromImage creates a new image sheet with generated image frames for mech sprite animation

type NavReticle struct {
	HUDSprite
}

func NewNavReticle

func NewNavReticle(scale float64, img *ebiten.Image) *NavReticle

NewNavReticle creates a nav reticle from an image

func (t *NavReticle) Draw(bounds image.Rectangle, hudOpts *DrawHudOptions)
type NavSprite struct {
	*Sprite
	NavPoint *model.NavPoint
}

func NewNavSprite

func NewNavSprite(
	navPoint *model.NavPoint, scale float64,
) *NavSprite
type NavStatus struct {
	HUDSprite
	// contains filtered or unexported fields
}

func NewNavStatus

func NewNavStatus(font *Font) *NavStatus

NewNavStatus creates a nav status element image to be rendered on demand

func (n *NavStatus) Draw(bounds image.Rectangle, hudOpts *DrawHudOptions)
func (n *NavStatus) SetNavDistance(distance float64)
func (n *NavStatus) SetNavPoint(navPoint *model.NavPoint)

type ProjectileSprite

type ProjectileSprite struct {
	*Sprite
	ImpactAudioFiles []string
	ImpactEffect     EffectSprite
	Projectile       *model.Projectile
}

func NewAnimatedProjectile

func NewAnimatedProjectile(
	projectile *model.Projectile, scale float64, img *ebiten.Image, impactEffect EffectSprite, impactAudioFiles []string,
) *ProjectileSprite

func (*ProjectileSprite) Clone

func (p *ProjectileSprite) Clone() *ProjectileSprite

func (*ProjectileSprite) Damage

func (p *ProjectileSprite) Damage() float64

func (*ProjectileSprite) DecreaseLifespan

func (p *ProjectileSprite) DecreaseLifespan(decreaseBy float64) float64

func (*ProjectileSprite) Destroy

func (p *ProjectileSprite) Destroy()

func (*ProjectileSprite) ImpactAudio

func (p *ProjectileSprite) ImpactAudio() string

func (*ProjectileSprite) Lifespan

func (p *ProjectileSprite) Lifespan() float64

func (*ProjectileSprite) SpawnEffect

func (p *ProjectileSprite) SpawnEffect(x, y, z, angle, pitch float64) *EffectSprite

func (*ProjectileSprite) Update

func (s *ProjectileSprite) Update(camPos *geom.Vector2)

type Radar

type Radar struct {
	HUDSprite
	// contains filtered or unexported fields
}

func NewRadar

func NewRadar(font *Font) *Radar

NewRadar creates a radar image to be rendered on demand

func (*Radar) Draw

func (r *Radar) Draw(bounds image.Rectangle, hudOpts *DrawHudOptions)

func (*Radar) SetMapLines

func (r *Radar) SetMapLines(lines []*geom.Line)

func (*Radar) SetNavPoints

func (r *Radar) SetNavPoints(radarNavPoints []*RadarNavPoint)

func (*Radar) SetRadarBlips

func (r *Radar) SetRadarBlips(blips []*RadarBlip)

func (*Radar) SetValues

func (r *Radar) SetValues(position *geom.Vector2, heading, turretAngle, fovDegrees float64)

type RadarBlip

type RadarBlip struct {
	Unit     model.Unit
	Angle    float64
	Distance float64
	IsTarget bool
}

type RadarNavPoint

type RadarNavPoint struct {
	NavPoint *model.NavPoint
	Angle    float64
	Distance float64
	IsTarget bool
}

type Sprite

type Sprite struct {
	model.Entity
	// contains filtered or unexported fields
}

func NewAnimatedSprite

func NewAnimatedSprite(
	modelEntity model.Entity, scale float64, img *ebiten.Image,
	columns, rows, animationRate int,
) *Sprite

func NewSprite

func NewSprite(
	modelEntity model.Entity, scale float64, img *ebiten.Image,
) *Sprite

func NewSpriteFromSheet

func NewSpriteFromSheet(
	modelEntity model.Entity, scale float64, img *ebiten.Image,
	columns, rows, spriteIndex int,
) *Sprite

func (*Sprite) AnimationFrameCounter

func (s *Sprite) AnimationFrameCounter() int

func (*Sprite) AnimationReversed

func (s *Sprite) AnimationReversed() bool

func (*Sprite) Clone

func (s *Sprite) Clone() *Sprite

func (*Sprite) DestroyCounter

func (s *Sprite) DestroyCounter() int

DestroyCounter used only when destroyed to remain visible until ready to be removed

func (*Sprite) Illumination

func (s *Sprite) Illumination() float64

func (*Sprite) IsFocusable

func (s *Sprite) IsFocusable() bool

func (*Sprite) LoopCounter

func (s *Sprite) LoopCounter() int

func (*Sprite) NumAnimationFrames

func (s *Sprite) NumAnimationFrames() int

func (*Sprite) Pos

func (s *Sprite) Pos() *geom.Vector2

func (*Sprite) PosZ

func (s *Sprite) PosZ() float64

func (*Sprite) ResetAnimation

func (s *Sprite) ResetAnimation()

func (*Sprite) Scale

func (s *Sprite) Scale() float64

func (*Sprite) ScreenRect

func (s *Sprite) ScreenRect(renderScale float64) *image.Rectangle

func (*Sprite) SetAnimationReversed

func (s *Sprite) SetAnimationReversed(isReverse bool)

func (*Sprite) SetDestroyCounter

func (s *Sprite) SetDestroyCounter(counter int) int

SetDestroyCounter to set how many ticks to remain visible after destroyed before removal

func (*Sprite) SetIlluminationPeriod

func (s *Sprite) SetIlluminationPeriod(illumination float64, periodSeconds float64)

func (*Sprite) SetScale

func (s *Sprite) SetScale(scale float64)

func (*Sprite) SetScreenRect

func (s *Sprite) SetScreenRect(rect *image.Rectangle)

func (*Sprite) SetTextureFacingMap

func (s *Sprite) SetTextureFacingMap(texFacingMap map[float64]int)

func (*Sprite) SetTextureFrame

func (s *Sprite) SetTextureFrame(texNum int)

func (*Sprite) StaticTexture

func (s *Sprite) StaticTexture() *ebiten.Image

func (*Sprite) Texture

func (s *Sprite) Texture() *ebiten.Image

func (*Sprite) TextureRect

func (s *Sprite) TextureRect() image.Rectangle

func (*Sprite) Update

func (s *Sprite) Update(camPos *geom.Vector2)

func (*Sprite) VerticalAnchor

func (s *Sprite) VerticalAnchor() raycaster.SpriteAnchor

type TargetReticle

type TargetReticle struct {
	HUDSprite
}

func NewTargetReticle

func NewTargetReticle(scale float64, img *ebiten.Image) *TargetReticle

NewTargetReticle creates a target reticle from an image with 2 rows and 2 columns, representing the four corners of it

func (*TargetReticle) Draw

func (t *TargetReticle) Draw(bounds image.Rectangle, hudOpts *DrawHudOptions)

type Throttle

type Throttle struct {
	HUDSprite
	// contains filtered or unexported fields
}

func NewThrottle

func NewThrottle(font *Font) *Throttle

NewThrottle creates a speed indicator image to be rendered on demand

func (*Throttle) Draw

func (t *Throttle) Draw(bounds image.Rectangle, hudOpts *DrawHudOptions)

func (*Throttle) SetValues

func (t *Throttle) SetValues(velocity, targetVelocity, velocityZ, maxVelocity, maxReverse float64)

type UnitStatus

type UnitStatus struct {
	HUDSprite
	// contains filtered or unexported fields
}

func NewUnitStatus

func NewUnitStatus(isPlayer bool, font *Font) *UnitStatus

NewUnitStatus creates a unit status element image to be rendered on demand

func (*UnitStatus) Draw

func (u *UnitStatus) Draw(bounds image.Rectangle, hudOpts *DrawHudOptions)

func (*UnitStatus) SetTargetLock

func (u *UnitStatus) SetTargetLock(lockPercent float64)

func (*UnitStatus) SetTargetReticle

func (u *UnitStatus) SetTargetReticle(reticle *TargetReticle)

func (*UnitStatus) SetUnit

func (u *UnitStatus) SetUnit(unit *Sprite)

func (*UnitStatus) SetUnitDistance

func (u *UnitStatus) SetUnitDistance(distance float64)

func (*UnitStatus) ShowTargetLock

func (u *UnitStatus) ShowTargetLock(show bool)

func (*UnitStatus) Unit

func (u *UnitStatus) Unit() *Sprite

type VTOLSprite

type VTOLSprite struct {
	*Sprite

	// TODO: move to separate AI handler
	PatrolPathIndex int
	PatrolPath      [][2]float64
}

func NewVTOLSprite

func NewVTOLSprite(
	vtol *model.VTOL, scale float64, img *ebiten.Image,
) *VTOLSprite

func (*VTOLSprite) Clone

func (v *VTOLSprite) Clone(asUnit model.Unit) *VTOLSprite

type VehicleSprite

type VehicleSprite struct {
	*Sprite

	// TODO: move to separate AI handler
	PatrolPathIndex int
	PatrolPath      [][2]float64
}

func NewVehicleSprite

func NewVehicleSprite(
	vehicle *model.Vehicle, scale float64, img *ebiten.Image,
) *VehicleSprite

func (*VehicleSprite) Clone

func (v *VehicleSprite) Clone(asUnit model.Unit) *VehicleSprite

type Weapon

type Weapon struct {
	HUDSprite
	// contains filtered or unexported fields
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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