characters

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: May 4, 2018 License: MIT Imports: 9 Imported by: 0

Documentation

Overview

Package characters provides a set of tools to construct your chars made of parts and equipement

Index

Constants

View Source
const (
	StdChestHeigh = 24
	StdLegsHeigh  = 16
	StdWidth      = 32
)

Std are the standart size, using which we calculate the proportions to redimensionate the equipment

Variables

This section is empty.

Functions

func LoadAllBodies

func LoadAllBodies(path string) (map[string][]Body, error)

LoadAllBodies loads the bodies from all json files for all races in a path.

Types

type Body

type Body struct {
	Drawable    Part      `json:""`
	HeadAnchor  pixel.Vec `json:"head_anchor"`
	ChestAnchor pixel.Vec `json:"chest_anchor"`
	LegsAnchor  pixel.Vec `json:"legs_anchor"`
}

Body of a character, contains the rest of the anchors of the wearables.

func LoadBodies

func LoadBodies(file string) ([]Body, error)

LoadBodies gets a *bodies.json into a bodies array for a race.

func NewBody

func NewBody(legs, chest, head pixel.Vec) Body

NewBody from three anchor points

func (Body) Draw

func (body Body) Draw(target pixel.Target, imd *imdraw.IMDraw, position pixel.Vec)

Draw the head at the character position + head anchor

func (*Body) SetVectors

func (body *Body) SetVectors()

SetVectors creates the drawable vectors from the main proportions

type Character

type Character struct {
	// Basic info
	Name     string `json:"name"`
	Nickname string `json:"nickname"`
	Lastname string `json:"lastname"`
	Race     string `json:"race"`
	Job      string `json:"job"`
	Age      int16  `json:"age"`

	// Stats, perks and etc.
	Position pixel.Vec `json:"position"`
	Speed    float64   `json:"speed"`

	// Apearence
	Head     Head         `json:"head"`
	Body     Body         `json:"body"`
	Equipped []*Equipable `json:"equipement"`
}

Character is the basic individual unit in the game

func LoadChar

func LoadChar(file string) (Character, error)

LoadChar expects a json file to read a char stats

func (*Character) Draw

func (character *Character) Draw(target pixel.Target)

Draw all the parts of our character in the correct order

type Equipable

type Equipable struct {
	// TODO: cuando se saquen los puntos de anclaje al constuir al personaje, se rellenan los puntos de renderables
	Prority RenderPriority `json:"prority"`
	Parts   []Part         `json:"renderables"`
}

Equipable has a type, color and uses the anchors to adjust perfectly to a character.

type Head struct {
	Drawable Part `json:"vectors"`
	RoundTop bool `json:"round_top"`
	Circular bool `json:"circular"`
}

Head of a character, contains the anchor for the helmet, and data about the head shape.

func (Head) Draw

func (head Head) Draw(target pixel.Target, imd *imdraw.IMDraw, position pixel.Vec)

Draw the head at the character position + head anchor

type Part

type Part struct {
	Vectors []pixel.Vec `json:"vectors"`
	Color   pixel.RGBA  `json:"color"`
}

Part is a set of local point to an anchor.

type RenderPriority

type RenderPriority int

RenderPriority defines the order of drawing of an equipped object.

const (
	Low RenderPriority = 1 + iota
	Middle
	High
)

The priority of the rendering of the object within a character

Jump to

Keyboard shortcuts

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