common

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2021 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CursorNone ...
	CursorNone = iota
	// CursorArrow ...
	CursorArrow
	// CursorCrosshair ...
	CursorCrosshair
	// CursorHand ...
	CursorHand
	// CursorIBeam ...
	CursorIBeam
	// CursorHResize ...
	CursorHResize
	// CursorVResize ...
	CursorVResize
)
View Source
const MouseSystemPriority = 100

MouseSystemPriority ...

View Source
const (
	// MouseZoomerPriority ...
	MouseZoomerPriority = 110
)
View Source
const (
	// RenderSystemPriority ...
	RenderSystemPriority = -1000
)

Variables

This section is empty.

Functions

func SetBackground

func SetBackground(c color.Color)

SetBackground ...

Types

type BytesResource

type BytesResource struct {
	Buffer *bytes.Buffer
	// contains filtered or unexported fields
}

BytesResource ...

func NewBytesResource

func NewBytesResource(buf *bytes.Buffer) BytesResource

NewBytesResource sends the image to the GPU and returns a `BytesResource` for easy access

func (BytesResource) URL

func (t BytesResource) URL() string

URL ...

type Cursor

type Cursor uint8

Cursor is a reference to a GLFW-cursor - to be used with the `SetCursor` method.

type Drawable

type Drawable interface {
	Setup()
	Draw(td float32)
	Delete()
}

Drawable ...

type Mouse

type Mouse struct {
	// X is the current x position of the mouse in the game
	X float32
	// Y is the current y position of the mouse in the game
	Y float32
	// ScrollX is the current scrolled position on the x component
	ScrollX float32
	// ScrollY is the current scrolled position on the y component
	ScrollY float32
	// Action is the currently active Action
	Action minieng.Action
	// Button is which button is being pressed on the mouse
	Button minieng.MouseButton
	// Modifier is whether any modifier mouse buttons are being pressed
	Modifer minieng.Modifier
}

Mouse is the representation of the physical mouse

type MouseComponent

type MouseComponent struct {
	// Clicked is true whenever the Mouse was clicked over
	// the entity space in this frame
	Clicked bool
	// Released is true whenever the left mouse button is released over the
	// entity space in this frame
	Released bool
	// Hovered is true whenever the Mouse is hovering
	// the entity space in this frame. This does not necessarily imply that
	// the mouse button was pressed down in your entity space.
	Hovered bool
	// Dragged is true whenever the entity space was left-clicked,
	// and then the mouse started moving (while holding)
	Dragged bool
	// RightClicked is true whenever the entity space was right-clicked
	// in this frame
	RightClicked bool
	// RightDragged is true whenever the entity space was right-clicked,
	// and then the mouse started moving (while holding)
	RightDragged bool
	// RightReleased is true whenever the right mouse button is released over
	// the entity space in this frame. This does not necessarily imply that
	// the mouse button was pressed down in your entity space.
	RightReleased bool
	// Enter is true whenever the Mouse entered the entity space in that frame,
	// but wasn't in that space during the previous frame
	Enter bool
	// Leave is true whenever the Mouse was in the space on the previous frame,
	// but now isn't
	Leave bool
	// Position of the mouse at any moment this is generally used
	// in conjunction with Track = true
	MouseX float32
	MouseY float32
	// Set manually this to true and your mouse component will track the mouse
	// and your entity will always be able to receive an updated mouse
	// component even if its space is not under the mouse cursor
	// WARNING: you MUST know why you want to use this because it will
	// have serious performance impacts if you have many entities with
	// a MouseComponent in tracking mode.
	// This is ideally used for a really small number of entities
	// that must really be aware of the mouse details event when the
	// mouse is not hovering them
	Track bool
	// Modifier is used to store the eventual modifiers that were pressed during
	// the same time the different click events occurred
	Modifier minieng.Modifier
	// contains filtered or unexported fields
}

MouseComponent is the location for the MouseSystem to store its results; to be used / viewed by other Systems

type MouseSystem

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

MouseSystem listens for mouse events, and changes value for MouseComponent accordingly

func (*MouseSystem) Add

func (m *MouseSystem) Add(basic *minieng.BasicEntity, mouse *MouseComponent, space *SpaceComponent, render *RenderComponent)

Add adds a new entity to the MouseSystem.

  • RenderComponent is only required if you're using the HUDShader on this Entity.
  • SpaceComponent is required whenever you want to know specific mouse-events on this Entity (like hover, click, etc.). If you don't need those, then you can omit the SpaceComponent.
  • MouseComponent is always required.
  • BasicEntity is always required.

func (*MouseSystem) New

func (m *MouseSystem) New(w *minieng.World)

New ...

func (*MouseSystem) Priority

func (m *MouseSystem) Priority() int

Priority returns a priority higher than most, to ensure that this System runs before all others

func (*MouseSystem) Remove

func (m *MouseSystem) Remove(basic minieng.BasicEntity)

Remove ...

func (*MouseSystem) Update

func (m *MouseSystem) Update(dt float32)

Update ...

type MouseZoomer

type MouseZoomer struct {
}

MouseZoomer is a System that allows for zooming when the scroll wheel is used

func (*MouseZoomer) Priority

func (*MouseZoomer) Priority() int

Priority ...

func (*MouseZoomer) Remove

func (*MouseZoomer) Remove(minieng.BasicEntity)

Remove ...

func (*MouseZoomer) Update

func (c *MouseZoomer) Update(float32)

Update ...

type MouseZoomerMessage

type MouseZoomerMessage struct {
	ScrollY float32
}

MouseZoomerMessage ...

func (MouseZoomerMessage) Type

func (MouseZoomerMessage) Type() string

Type ...

type RenderComponent

type RenderComponent struct {
	// Hidden is used to prevent drawing by OpenGL
	Hidden   bool
	Drawable Drawable
	// contains filtered or unexported fields
}

RenderComponent ...

func (*RenderComponent) SetZIndex

func (r *RenderComponent) SetZIndex(index float32)

SetZIndex ...

type RenderSystem

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

RenderSystem ...

func (*RenderSystem) Add

func (rs *RenderSystem) Add(basic *minieng.BasicEntity, render *RenderComponent)

Add ...

func (*RenderSystem) New

func (rs *RenderSystem) New(w *minieng.World)

New ...

func (*RenderSystem) Priority

func (*RenderSystem) Priority() int

Priority ...

func (*RenderSystem) Remove

func (rs *RenderSystem) Remove(basic minieng.BasicEntity)

Remove ...

func (*RenderSystem) RemoveAll

func (rs *RenderSystem) RemoveAll()

RemoveAll ...

func (*RenderSystem) Update

func (rs *RenderSystem) Update(dt float32)

Update ...

type SpaceComponent

type SpaceComponent struct {
	Bounds image.Rectangle
}

SpaceComponent ...

func (*SpaceComponent) Contains

func (m *SpaceComponent) Contains(pt image.Point) bool

Contains ...

type TextureResource

type TextureResource struct {
	Texture *glplus.GPTexture
	Img     *image.RGBA
	// contains filtered or unexported fields
}

TextureResource ...

func NewTextureResource

func NewTextureResource(img *image.RGBA) TextureResource

NewTextureResource sends the image to the GPU and returns a `TextureResource` for easy access

func (TextureResource) URL

func (t TextureResource) URL() string

URL ...

Jump to

Keyboard shortcuts

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