new server
All checks were successful
Create and publish a Docker image 🚀 / build-and-push-image (push) Successful in 1m19s
All checks were successful
Create and publish a Docker image 🚀 / build-and-push-image (push) Successful in 1m19s
This commit is contained in:
8
models/client.go
Normal file
8
models/client.go
Normal file
@@ -0,0 +1,8 @@
|
||||
package models
|
||||
|
||||
import "github.com/gorilla/websocket"
|
||||
|
||||
type Client struct {
|
||||
ID uint32
|
||||
Conn *websocket.Conn
|
||||
}
|
||||
@@ -8,12 +8,44 @@ const (
|
||||
EntityBullet EntityType = 3
|
||||
)
|
||||
|
||||
type Entity struct {
|
||||
ID uint32
|
||||
Type EntityType
|
||||
|
||||
X float32
|
||||
Y float32
|
||||
Z float32
|
||||
Yaw float32
|
||||
type Entity interface {
|
||||
GetID() uint32
|
||||
GetType() EntityType
|
||||
GetPosition() (float32, float32, float32)
|
||||
SetPosition(float32, float32, float32)
|
||||
GetYaw() float32
|
||||
SetYaw(float32)
|
||||
}
|
||||
|
||||
type BaseEntity struct {
|
||||
ID uint32
|
||||
Type EntityType
|
||||
X, Y, Z float32
|
||||
Yaw float32
|
||||
}
|
||||
|
||||
func (e *BaseEntity) GetID() uint32 {
|
||||
return e.ID
|
||||
}
|
||||
|
||||
func (e *BaseEntity) GetType() EntityType {
|
||||
return e.Type
|
||||
}
|
||||
|
||||
func (e *BaseEntity) GetPosition() (float32, float32, float32) {
|
||||
return e.X, e.Y, e.Z
|
||||
}
|
||||
|
||||
func (e *BaseEntity) SetPosition(x, y, z float32) {
|
||||
e.X = x
|
||||
e.Y = y
|
||||
e.Z = z
|
||||
}
|
||||
|
||||
func (e *BaseEntity) GetYaw() float32 {
|
||||
return e.Yaw
|
||||
}
|
||||
|
||||
func (e *BaseEntity) SetYaw(yaw float32) {
|
||||
e.Yaw = yaw
|
||||
}
|
||||
|
||||
@@ -1,9 +1,20 @@
|
||||
package models
|
||||
|
||||
import "github.com/gorilla/websocket"
|
||||
|
||||
type Player struct {
|
||||
Entity
|
||||
BaseEntity
|
||||
Name string
|
||||
Conn *websocket.Conn
|
||||
}
|
||||
|
||||
func NewPlayer(id uint32, name string) *Player {
|
||||
return &Player{
|
||||
BaseEntity: BaseEntity{
|
||||
ID: id,
|
||||
Type: EntityPlayer,
|
||||
X: 0,
|
||||
Y: 0,
|
||||
Z: 0,
|
||||
Yaw: 0,
|
||||
},
|
||||
Name: name,
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user