Skip to content

jasoncabot/wrath-of-toldir

Repository files navigation

Wrath of Toldir

A very simple MMORPG with the aim of learning more about Cloudflare's application platform and doing something fun.

TODO List

  • Interact with objects / friendly NPCs
  • Quests
  • Character should gain/lose health/mana/experience
  • Actually spend some time making the React app frame look semi-decent
  • Dynamic Lighting
  • Sounds
  • Monsters should fight back
  • Magic Attacks
  • Joining a map should only tell you about stuff you can see (so not all people / npcs and their positions)
  • Item system should hold inventory
  • Water should be animated
  • Fishing
  • Crafting
  • Transitions between scenes can be animated nicely
  • Loot items
  • HUD - switch between physical and magical attack (numbers 1, 2, 3)
  • Simple mobile controls using a virtual joystick
  • Attacks should kill NPC
  • Chat bubbles
  • Transitioning between maps should put you in the right position
  • NPCs should have some kind of basic AI - I mean they walk randomly
  • Spawning of players and monsters should not be on an invalid tile
  • Transfer player between maps (zones)
  • Combat system should hold HP, ATK, DEF e.t.c
  • Add NPC characters that just amble about
  • Add an attack action
  • Maps should share tiles
  • Events should trigger animations
  • Tile Collisions

Development

The one thing you should never attempt is to write an MMORPG.

However if you want to give it a go, you can run:

$ yarn
# In ./client
$ yarn start
# In ./server
$ yarn dev

Architecture

Front end is built using a mixture of React for everything out of game and in-game text. Phaser is used to render the WebGL canvas using a 2d tile grid.

API runs using a Cloudflare worker that is responsible for setting up an authenticated WebSocket connection to a Durable Object for all in-game actions.

Players issue Commands encoded in a FlatBuffer, these are validated on the server, which then emits Events to interested Observers.

The current list of commands that a player can issue.

Durable Objects

Used to hold information about various independent systems.

Character

One Durable Object exists for every user of the game. A single user can be considered as an account and has up to 5 characters.

Map

A map is the most complex object. It can be thought of as a zone or area in a traditional MMORPG. When a character connects it is a map that is responsible for establishing the WebSocket connection, responding to commands and issuing events to all characters.

Item

A Durable Object for items exists 1 per map, for every item that is on the floor. This is updated when items are dropped from monsters upon being killed or when a player picks up a particular item.

Combat

A Durable Object exists for every player within the game. It is responsible for holding a single players health, attack and defence statistics. When a player makes an attack or defends the adjustments are synchronously processed by this object.

Map Editing

All Maps are located in ./shared/maps and can be opened using Tiled.

After editing a *.tmx file you must export using Tiled as JSON to ./server/src/data/maps

Credits

About

Is it possible to write an MMORPG system on Cloudflare workers?

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published