characters

package
v0.0.2-0...-4882181 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2018 License: MIT Imports: 9 Imported by: 1

Documentation

Overview

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

Index

Constants

This section is empty.

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 {
	Kid             bool       `json:"kid"`
	Vectors         Renderable `json:"vectors"`
	HeadAnchor      pixel.Vec  `json:"head_anchor"`
	LeftHandAnchor  pixel.Vec  `json:"left_hand_anchor"`
	RightHandAnchor pixel.Vec  `json:"right_hand_anchor"`
	ChestAnchors    Renderable `json:"armor_anchors"`
	PantsAnchors    Renderable `json:"pants_anchors"`
	HelmetAnchor    pixel.Vec  `json:"helmet_anchor"`
	ShoulderAnchors Renderable `json:"shoulder_anchors"`
}

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.

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"`
	Equiped   []*Equipable `json:"equipement"`
	SkinColor pixel.RGBA   `json:"skin_color"`
	HeadColor pixel.RGBA   `json:"head_color"`
}

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"`
	Renderables    []Renderable   `json:"renderables"`
	PrimaryColor   pixel.RGBA     `json:"primary_color"`
	SecondaryColor pixel.RGBA     `json:"secondary_color"`
}

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

type Head struct {
	Vectors  Renderable `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.

type RenderPriority

type RenderPriority int

RenderPriority defines the order of drawing of an equiped object.

const (
	Low RenderPriority = 1 + iota
	High
)

The priority of the rendering of the object within a character

type Renderable

type Renderable []pixel.Vec

Renderable is a set of vectors which we can render indo a poligon reading it from json.

Jump to

Keyboard shortcuts

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