objects

package
v0.0.0-...-aac1211 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2022 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ELEMENT = iota
	AMMO
	LOOT
	PLAYER
	WEAPON
)

Constants for collidable objects

View Source
const DEFAULT_HEALTH = 10

Variables

This section is empty.

Functions

This section is empty.

Types

type Ammo

type Ammo struct {
	Base

	Direction keycodes.Direction
}

func NewAmmo

func NewAmmo() *Ammo

func (*Ammo) FromAPIMessage

func (a *Ammo) FromAPIMessage(m *server_external.Ammo)

func (*Ammo) ToAPIMessage

func (a *Ammo) ToAPIMessage() *server_external.Ammo

type Animation

type Animation struct {
	AnimationStartPosition types.Vec2
	FrameCount             uint64
	FrameDelayCounter      uint64
	CurrentFrameMatrix     []float64
}

type Base

type Base struct {
	*sources.MetadataModel
	CollidersModel []*sources.CollidersModel

	Type string

	Animation
	Skin
	Physics

	Parent *Base

	// Names parentid the object referes to
	ID uuid.UUID

	RawPos, RawOffset, LastRawPos types.Vec2
	Direction, SubDirection       keycodes.Direction

	Spawn server_external.PositionInt

	Role Role

	TranslationMovementXBlocked, TranslationMovementYBlocked bool

	PositionHistorySequence zeroshifter.IZeroShifter
}

The object structure which describes each object on the map

func NewBase

func NewBase() *Base

func (*Base) FromAPIMessage

func (o *Base) FromAPIMessage(m *server_external.Base)

func (*Base) GetAnimatedImage

func (o *Base) GetAnimatedImage() *ebiten.Image

Returns image where animation properties applied to

func (*Base) GetAnimationStartPosition

func (o *Base) GetAnimationStartPosition() (float64, float64)

Returns last saved position before animation was executed

func (*Base) GetCopyOfImage

func (o *Base) GetCopyOfImage() *ebiten.Image

func (*Base) GetImage

func (o *Base) GetImage() *ebiten.Image

Returns images for the skin selected

func (*Base) IsDirectionDOWN

func (o *Base) IsDirectionDOWN() bool

func (*Base) IsDirectionLEFT

func (o *Base) IsDirectionLEFT() bool

func (*Base) IsDirectionRIGHT

func (o *Base) IsDirectionRIGHT() bool

func (*Base) IsDirectionUP

func (o *Base) IsDirectionUP() bool

func (*Base) IsEqualTo

func (o *Base) IsEqualTo(ob *Base) bool

func (*Base) IsTranslationMovementBlocked

func (o *Base) IsTranslationMovementBlocked() bool

func (*Base) IsXChanged

func (o *Base) IsXChanged() bool

Checks if x pos has been changed in comparison to the last x poses

func (*Base) IsYChanged

func (o *Base) IsYChanged() bool

Checks if y pos has been changed in comparison to the last y poses

func (*Base) SaveAnimationStartPosition

func (o *Base) SaveAnimationStartPosition()

func (*Base) SetRawOffsetX

func (o *Base) SetRawOffsetX(x float64)

func (*Base) SetRawOffsetY

func (o *Base) SetRawOffsetY(y float64)

func (*Base) SetRawX

func (o *Base) SetRawX(x float64)

func (*Base) SetRawY

func (o *Base) SetRawY(y float64)

func (*Base) SetSkin

func (o *Base) SetSkin(path string)

Sets skin for the object

func (*Base) SetSpawn

func (o *Base) SetSpawn(spawns []image.Point)

Sets spawn point for the object

func (*Base) SetTranslationXMovementBlocked

func (o *Base) SetTranslationXMovementBlocked(s bool)

func (*Base) SetTranslationYMovementBlocked

func (o *Base) SetTranslationYMovementBlocked(s bool)

func (*Base) ToAPIMessage

func (o *Base) ToAPIMessage() *server_external.Base

func (*Base) UpdateDirection

func (o *Base) UpdateDirection()

func (*Base) UpdateLastPosition

func (o *Base) UpdateLastPosition()

type Buffs

type Buffs struct{ SpeedX, SpeedY float64 }

type Camera

type Camera struct {
	Base

	Zoom    float64
	COffset types.Vec2
	CScale  types.Vec2
}

func NewCamera

func NewCamera() *Camera

func (*Camera) ConvertScreenToWorld

func (c *Camera) ConvertScreenToWorld(s types.Vec2) types.Vec2

func (*Camera) ConvertWorldToScreen

func (c *Camera) ConvertWorldToScreen(w types.Vec2) types.Vec2

func (*Camera) GetZoom

func (c *Camera) GetZoom() types.Vec2

func (*Camera) GetZoomedOffset

func (c *Camera) GetZoomedOffset(b *Base) types.Vec2

func (*Camera) GetZoomedPos

func (c *Camera) GetZoomedPos(b *Base) types.Vec2

func (*Camera) GetZoomedScale

func (c *Camera) GetZoomedScale(b *Base) types.Vec2

func (*Camera) IsOuttaRange

func (c *Camera) IsOuttaRange(v1, v2 float64) bool

Checks if passed v2 is outta range of v1

func (*Camera) ZoomIn

func (c *Camera) ZoomIn(o *Base)

Increments zoom property

func (*Camera) ZoomOut

func (c *Camera) ZoomOut(o *Base)

Decrements zoom property

type Element

type Element struct {
	Base
}

func NewElement

func NewElement() *Element

type LootSet

type LootSet struct {
	Base

	IsHidden bool
	Weapon   []*Weapon
	Ammo     []*Ammo
}

func NewLootSet

func NewLootSet(w []*Weapon, a []*Ammo) *LootSet

type Map

type Map struct {
	Base

	*sources.CollidersModel
}

func NewMap

func NewMap() *Map

func (*Map) DebugInit

func (m *Map) DebugInit()

func (*Map) FromAPIMessage

func (w *Map) FromAPIMessage(m *server_external.Map)

func (*Map) GetSpawns

func (w *Map) GetSpawns() []*server_external.PositionInt
	return (y-mm.Buffs.Speed.Y - mo.Size.Height/2) <= ay && ay <= (y+mm.Buffs.Speed.Y + mo.Size.Height/2)
}

func (*Map) String

func (m *Map) String() string

func (*Map) ToAPIMessage

func (w *Map) ToAPIMessage() *server_external.Map

type PC

type PC struct {
	Base

	Killer uuid.UUID

	Username string
	Health   uint64

	LobbyNumber int

	IsKicked     bool
	LastActivity int64
}

func NewPC

func NewPC() *PC

func (*PC) DebugInit

func (p *PC) DebugInit()

func (*PC) FromAPIMessage

func (p *PC) FromAPIMessage(m *server_external.PC)

func (*PC) GetMovementRotation

func (p *PC) GetMovementRotation() float64

//Returns movement rotation related to the last //movement direction

func (*PC) LoadUsername

func (p *PC) LoadUsername()

Initializes pc username by requesting storage

func (*PC) SetKicked

func (p *PC) SetKicked(s bool)

func (*PC) String

func (p *PC) String() string

func (*PC) ToAPIMessage

func (p *PC) ToAPIMessage() *server_external.PC

func (*PC) UpdateLastActivity

func (p *PC) UpdateLastActivity()

type Physics

type Physics struct {
	Jump []keycodes.Direction
}

func (*Physics) IsAnimated

func (p *Physics) IsAnimated() bool

Checks if pc executes animation

type Role

type Role int
const (
	PCRole Role = iota
	ElementRole
	WeaponRole
	AmmoRole
)

type Skin

type Skin struct {
	Name, Path string
}

func (*Skin) IsSet

func (s *Skin) IsSet() bool

type Weapon

type Weapon struct {
	Base

	Name, Radius string
}

func NewWeapon

func NewWeapon() *Weapon

func (*Weapon) ToAPIMessage

func (w *Weapon) ToAPIMessage() *server_external.Weapon

Jump to

Keyboard shortcuts

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