game

package
v0.0.0-...-1c99cfb Latest Latest
Warning

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

Go to latest
Published: Sep 24, 2025 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type LightSource

type LightSource struct {
	Position  Vector
	Radius    float64
	Intensity float64
	Color     [3]float64 // RGB values 0-1
}

func (LightSource) GetLightingAt

func (ls LightSource) GetLightingAt(pos Vector) float64

type Map

type Map struct {
	Width  int
	Height int
	Grid   [][]int
}

func LoadMapFromFile

func LoadMapFromFile(filename string) (*Map, error)

func NewMap

func NewMap() *Map

func (*Map) GetWallType

func (m *Map) GetWallType(x, y int) int

func (*Map) IsWall

func (m *Map) IsWall(x, y int) bool

type NPC

type NPC struct {
	Position      Vector
	Direction     Vector
	Speed         float64
	MovementTimer float64 // Time until next direction change
	NPCType       NPCType
}

NPC represents a non-player character in the game world

func NewNPC

func NewNPC(x, y float64, npcType NPCType) *NPC

NewNPC creates a new NPC at the specified position

func (*NPC) Update

func (npc *NPC) Update(deltaTime float64, worldMap *Map)

Update updates the NPC's position and behavior

type NPCType

type NPCType int

NPCType defines different types of NPCs

const (
	Wanderer NPCType = iota // Basic wandering NPC
)

type Player

type Player struct {
	Position    Vector
	Direction   Vector
	CameraPlane Vector
	MoveSpeed   float64
	RotSpeed    float64
}

func NewPlayer

func NewPlayer(x, y float64) *Player

func (*Player) MoveBackward

func (p *Player) MoveBackward(deltaTime float64, worldMap *Map)

func (*Player) MoveForward

func (p *Player) MoveForward(deltaTime float64, worldMap *Map)

func (*Player) RotateLeft

func (p *Player) RotateLeft(deltaTime float64)

func (*Player) RotateRight

func (p *Player) RotateRight(deltaTime float64)

func (*Player) StrafeLeft

func (p *Player) StrafeLeft(deltaTime float64, worldMap *Map)

func (*Player) StrafeRight

func (p *Player) StrafeRight(deltaTime float64, worldMap *Map)

type Projectile

type Projectile struct {
	Position  Vector
	Direction Vector
	Speed     float64
	Life      float64 // Time to live in seconds
	MaxLife   float64
	Active    bool
	Type      ProjectileType
}

func NewFireball

func NewFireball(startPos, direction Vector) *Projectile

func (*Projectile) GetLightIntensity

func (p *Projectile) GetLightIntensity() float64

func (*Projectile) GetLightRadius

func (p *Projectile) GetLightRadius() float64

func (*Projectile) Update

func (p *Projectile) Update(deltaTime float64, worldMap *Map)

type ProjectileManager

type ProjectileManager struct {
	Projectiles []*Projectile
}

func NewProjectileManager

func NewProjectileManager() *ProjectileManager

func (*ProjectileManager) AddProjectile

func (pm *ProjectileManager) AddProjectile(p *Projectile)

func (*ProjectileManager) GetActiveLights

func (pm *ProjectileManager) GetActiveLights() []LightSource

func (*ProjectileManager) Update

func (pm *ProjectileManager) Update(deltaTime float64, worldMap *Map)

type ProjectileType

type ProjectileType int
const (
	Fireball ProjectileType = iota
)

type Vector

type Vector struct {
	X, Y float64
}

func (Vector) Add

func (v Vector) Add(other Vector) Vector

func (Vector) Length

func (v Vector) Length() float64

func (Vector) Normalize

func (v Vector) Normalize() Vector

func (Vector) Rotate

func (v Vector) Rotate(angle float64) Vector

func (Vector) Scale

func (v Vector) Scale(s float64) Vector

func (Vector) Sub

func (v Vector) Sub(other Vector) Vector

Jump to

Keyboard shortcuts

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