mmo

package module
v0.0.0-...-bf9f9cd Latest Latest
Warning

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

Go to latest
Published: Mar 16, 2023 License: MIT Imports: 8 Imported by: 0

README

Note: I decided to try and turn this into a full-fledge game. Because of that, I started putting the gameplay part of the project in a private repository and stopped adding to this repository. I do still want to open source as much of my code as I can (without giving away the entire project), so I have several other open source repos that I moved a lot of code to:

  1. github.com/unitoftime/glitch - Rendering
  2. github.com/unitoftime/flow - General game components features
  3. github.com/unitoftime/ecs - ECS framework
  4. You can also go here to see the repositories I have in my profile: https://github.com/unitoftime

Welcome!

If you are here, then you may have come from my tutorial series on YouTube. If not, you can go check it out:

If you have any feedback let me know!

Compiling and Running

Get the code

go get github.com/unitoftime/mmo

The current instructions are slightly complicated

cd cmd/
mkdir build

make all
# Everything should build - There will be one step where you generate a key, This is for the TLS connection between your client and proxy. You can leave all of the options blank (ie just hit enter until the key starts generating)

bash run.sh
# This will start the server, then the proxy, then launch a desktop client

If you want to test the wasm you'll have to host the build/ folder at some url. I use a simple go webserver to host my folder. Also, when you access the hosted URL, the browser will complain that the key at localhost:port isn't a part of any Certificate Authority. This is because you just manually generated the key. You have to skip the security check. Chrome had a way for me to allow arbitrary keys for localhost connections, so I enabled that.

You'll have to manually start the server and proxy binaries too:

# Shell 1
cd cmd/build/ && ./server
# Shell 2
cd cmd/build/ && ./proxy
# Shell 3
# Whatever webserver command you use to serve it

Licensing

  1. Code: MIT License.
  2. Artwork: All rights reserved.

Documentation

Index

Constants

View Source
const (
	NoLayer   phy2.CollisionLayer = 0
	BodyLayer phy2.CollisionLayer = 1 << iota
	WallLayer
)
View Source
const (
	GrassTile tile.TileType = iota
	DirtTile
	WaterTile
	ConcreteTile
)
View Source
const ClientDefaultUpdateQueueSize = 2 // TODO - make this dynamic
View Source
const ClientInputResendRate = 2 // The number of times the client resends his input to counter packet loss
View Source
const FixedTimeStep time.Duration = 16 * time.Millisecond
View Source
const NetworkTickDivider = 4 // The number of physics ticks before we send a network update

This defines the ratio of physics ticks to network ticks. TODO - right now I do a % NetworkTickDivider. It'd be nice to make that more systematic

View Source
const NumBodyTypes = 4

Variables

This section is empty.

Functions

func CheckCollisions

func CheckCollisions(world *ecs.World)

func CreateTilemap

func CreateTilemap(seed int64, mapSize, tileSize int) *tile.Tilemap

func FilterChat

func FilterChat(msg string) string

This should probably be somewhere else

func GetScheduler

func GetScheduler() *ecs.Scheduler

func LoadGame

func LoadGame(world *ecs.World) *tile.Tilemap

func MoveCharacter

func MoveCharacter(input *Input, transform *phy2.Pos, collider *phy2.CircleCollider, tilemap *tile.Tilemap, dt time.Duration)

func SpawnPoint

func SpawnPoint() phy2.Pos

Types

type Body

type Body struct {
	Type uint32
}

type Input

type Input struct {
	Up, Down, Left, Right bool
}

type Speech

type Speech struct {
	Text string
	// contains filtered or unexported fields
}

func (*Speech) HandleRender

func (s *Speech) HandleRender() bool

func (*Speech) HandleSent

func (s *Speech) HandleSent() bool

handles the speech, returns true if the speech wasn't already handled

type TileObject

type TileObject struct {
}

Directories

Path Synopsis
app
cmd

Jump to

Keyboard shortcuts

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