models

package
v0.0.0-...-d0abf95 Latest Latest
Warning

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

Go to latest
Published: Jun 29, 2015 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EVENT_PlayerMove   = 1
	EVENT_PlayerJoined = 2
	EVENT_PlayerId     = 3
	EVENT_PlayerDead   = 4
	EVENT_PlayerShoot  = 5
	EVENT_PlayerKey    = 6
	EVENT_PlayerLeave  = 7
	EVENT_NewBullet    = 8
	EVENT_NewPeon      = 9
)
View Source
const (
	KEY_Up        = 1
	KEY_Down      = 2
	KEY_Left      = 3
	KEY_Right     = 4
	KEY_RightUp   = 5
	KEY_RightDown = 6
	KEY_LeftUp    = 7
	KEY_LeftDown  = 8
	KEY_Space     = 9
)
View Source
const MAP_SIZE_X = 500
View Source
const MAP_SIZE_Y = 500

Variables

This section is empty.

Functions

func JoinRoom

func JoinRoom(roomName string, player *Player) (inChannel chan string, outPlayer chan *Player)

func LevelRoutine

func LevelRoutine(eventChannel chan Event, collisionChannel chan Entity)

Types

type Bullet

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

func NewBullet

func NewBullet(x int, y int) (bullet *Bullet)

func (*Bullet) Id

func (b *Bullet) Id() int

func (*Bullet) Kill

func (b *Bullet) Kill()

func (*Bullet) Live

func (b *Bullet) Live(eventChannel chan Event, collisionChannel chan Entity)

func (*Bullet) PosX

func (b *Bullet) PosX() int

func (*Bullet) PosY

func (b *Bullet) PosY() int

type Collision

type Collision struct {
	Entities map[int]Entity
	Test     chan Entity
}

func NewCollisionCenter

func NewCollisionCenter() (collision *Collision)

func (*Collision) CollisionRoutine

func (c *Collision) CollisionRoutine()

type Entity

type Entity interface {
	Id() int
	Live(eventChannel chan Event, collisionChannel chan Entity)
	Kill()
	PosX() int
	PosY() int
}

type Event

type Event struct {
	Type int
	Id   int
	X    int
	Y    int
	Key  int
}

func CreateEvent

func CreateEvent(event int, id int, posX int, posY int) (e Event)

func NewEvent

func NewEvent(jsonData string) (e Event, err error)

func (*Event) Json

func (event *Event) Json() (jsonEvent string)

func (Event) String

func (event Event) String() string

type Level

type Level struct {
	Id   int
	Name string
}

type Map

type Map struct {
	Map [][]int // Map
}

type Peon

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

func NewPeon

func NewPeon(x int, y int) (peon *Peon)

func (*Peon) Id

func (b *Peon) Id() int

func (*Peon) Kill

func (b *Peon) Kill()

func (*Peon) Live

func (p *Peon) Live(eventChannel chan Event, collisionChannel chan Entity)

func (*Peon) PosX

func (b *Peon) PosX() int

func (*Peon) PosY

func (b *Peon) PosY() int

type Player

type Player struct {
	Id         int
	Name       string
	PosX       int
	PosY       int
	OutChannel chan string
}

func NewPlayer

func NewPlayer(name string) (player *Player)

func (*Player) Move

func (player *Player) Move(key int) (e Event)

func (*Player) Send

func (player *Player) Send(e Event)

type Room

type Room struct {
	Name string
	Map  Map

	InChannel  chan string
	OutChannel chan string
	InPlayer   chan *Player
	OutPlayer  chan *Player
	EntityChan chan Event
	// contains filtered or unexported fields
}

func CreateRoom

func CreateRoom(roomName string) (room Room)

func (*Room) AddPlayer

func (room *Room) AddPlayer(player *Player)

func (*Room) FindPlayer

func (room *Room) FindPlayer(id int) (player *Player)

func (*Room) Full

func (room *Room) Full() (full bool)

func (*Room) NbPlayers

func (room *Room) NbPlayers() (nbPlayers int)

func (*Room) RemovePlayer

func (room *Room) RemovePlayer(player *Player)

Jump to

Keyboard shortcuts

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