enemy

package
v0.0.0-...-8a8a644 Latest Latest
Warning

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

Go to latest
Published: Jun 11, 2025 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	WALK_RIGHT   string = "walkRight"
	WALK_LEFT    string = "walkLeft"
	ATTACK_RIGHT string = "attack-right"
	ATTACK_LEFT  string = "attack-left"
	SPAWN        string = "spawn"
	DEATH        string = "death"
)

Variables

This section is empty.

Functions

func DefaultDrop

func DefaultDrop(elapsedMinutes float32, x, y float64) []item.Item

Types

type BaseMeleeEnemy

type BaseMeleeEnemy struct {
	Enemy
	AttackRange float64
	// contains filtered or unexported fields
}

func NewBaseMeleeEnemy

func NewBaseMeleeEnemy(enemyType EnemyType, pos component.Vector2D, store *animation.AnimationStore, op *BaseMeleeOptions) *BaseMeleeEnemy

func (*BaseMeleeEnemy) Draw

func (e *BaseMeleeEnemy) Draw(screen *ebiten.Image, camX, camY float64)

func (*BaseMeleeEnemy) IsAlive

func (e *BaseMeleeEnemy) IsAlive() bool

Mark enemies as dead after the death animation is finished

func (*BaseMeleeEnemy) SetAttackAnimation

func (e *BaseMeleeEnemy) SetAttackAnimation(player *player.Player)

func (*BaseMeleeEnemy) SetWalkingAnimation

func (e *BaseMeleeEnemy) SetWalkingAnimation(player *player.Player)

func (*BaseMeleeEnemy) TakeDamage

func (e *BaseMeleeEnemy) TakeDamage(damage float64)

func (*BaseMeleeEnemy) TryDrop

func (e *BaseMeleeEnemy) TryDrop(elapsedMinutes float32) []item.Item

func (*BaseMeleeEnemy) Update

func (e *BaseMeleeEnemy) Update(player *player.Player, dt float64)

type BaseMeleeOptions

type BaseMeleeOptions struct {
	Speed               float64
	MaxHealth           float64
	Damage              float64
	AttackCooldown      float64
	DropProb            float32
	DropAmount          int
	DropAmountPerMinute float32
	AttackRange         float64
	SpawnItem           func(x, y float64) *item.Item
}

type CabbageEnemy

type CabbageEnemy struct {
	BaseMeleeEnemy
}

func NewCabbageEnemy

func NewCabbageEnemy(pos component.Vector2D) *CabbageEnemy

type CarrotEnemy

type CarrotEnemy struct {
	BaseMeleeEnemy
}

func NewCarrotEnemy

func NewCarrotEnemy(pos component.Vector2D) *CarrotEnemy

type DamageIndicator

type DamageIndicator struct {
	Damage     float64
	Pos        component.Vector2D
	Offset     component.Vector2D
	Dir        component.Vector2D
	Speed      float64
	AliveUntil time.Time
	Font       font.Face
}

func NewDamageIndicator

func NewDamageIndicator(pos component.Vector2D, dir component.Vector2D, dmg float64) *DamageIndicator

func (*DamageIndicator) Draw

func (d *DamageIndicator) Draw(screen *ebiten.Image, camX, camY float64)

func (*DamageIndicator) Update

func (d *DamageIndicator) Update(pos component.Vector2D) (isAlive bool)

type Enemy

type Enemy struct {
	entity.Entity

	Health         component.Health
	Knockback      component.Knockback
	Speed          float64
	Damage         float64
	AttackCooldown float64

	DropProb            float32
	DropAmount          int
	DropAmountPerMinute float32
	// contains filtered or unexported fields
}

func (*Enemy) AddKnockback

func (e *Enemy) AddKnockback(from *component.Vector2D, dist float64)

func (*Enemy) DefaultDraw

func (e *Enemy) DefaultDraw(screen *ebiten.Image, camX, camY float64, width int, height int, color color.RGBA)

func (*Enemy) GetPosition

func (e *Enemy) GetPosition() component.Vector2D

func (*Enemy) GetType

func (e *Enemy) GetType() EnemyType

func (*Enemy) IsAlive

func (e *Enemy) IsAlive() bool

func (*Enemy) MoveTowards

func (e *Enemy) MoveTowards(target component.Vector2D, dt float64)

func (*Enemy) SetPosition

func (e *Enemy) SetPosition(pos component.Vector2D)

func (*Enemy) TakeDamage

func (e *Enemy) TakeDamage(damage float64)

func (*Enemy) UpdateKnockback

func (e *Enemy) UpdateKnockback()

type EnemyInterface

type EnemyInterface interface {
	Update(player *player.Player, dt float64)
	Draw(screen *ebiten.Image, camX, camY float64)
	GetPosition() component.Vector2D
	SetPosition(pos component.Vector2D)
	IsAlive() bool
	TakeDamage(damage float64)
	AddKnockback(from *component.Vector2D, distance float64)
	TryDrop(elapsedMinutes float32) []item.Item
	GetType() EnemyType
}

type EnemyType

type EnemyType int
const (
	TypeCarrot EnemyType = iota
	TypePotato
	TypeCabbage
	TypeOnion
	TypeLeek
	TypeRadish

	TypePeashooter
)

func RandomEnemyType

func RandomEnemyType() EnemyType

func (EnemyType) String

func (t EnemyType) String() string

type LeekEnemy

type LeekEnemy struct {
	BaseMeleeEnemy
}

type MeleeEnemyData

type MeleeEnemyData struct {
	AttackRange float64
}

type OnionEnemy

type OnionEnemy struct {
	BaseMeleeEnemy
}

func NewLeekEnemy

func NewLeekEnemy(pos component.Vector2D) *OnionEnemy

func NewOnionEnemy

func NewOnionEnemy(pos component.Vector2D) *OnionEnemy

type PotatoEnemy

type PotatoEnemy struct {
	BaseMeleeEnemy
}

func NewPotatoEnemy

func NewPotatoEnemy(pos component.Vector2D) *PotatoEnemy

type RadishEnemy

type RadishEnemy struct {
	BaseMeleeEnemy
}

func NewRadishEnemy

func NewRadishEnemy(pos component.Vector2D) *RadishEnemy

type RangedEnemyData

type RangedEnemyData struct {
	ProjectileSpeed float64
}

Jump to

Keyboard shortcuts

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