to run: npm start
(starts BE and also serves FE)
- uses paper.js and socket.io
To add a new unit attribute:
- add it to the consts in
./public/constants.js
- update the
calcCost
function on both backend and frontend - implement its behavior
To add a new action type:
- add it to the
ACTION_TYPES
enum in./public/constants.js
- add a handler in
handlePlayerAction()
in./game/game.js
- add a frontend way to call
emitAction(ACTION_TYPES.[your_action_type])
For hot reloading, see this section.
for a given range/speed/turn/rof invariant, let (d,h) represent a unit w/ d=damage, h=health, the cost efficiency rock-paper-scissors cycle is as follows:
- suppose a base unit B = (10,10)
B < (10,1) < (1,1) < (1,10) < B
-
HIGH priority
- implement ControlPointsCaptured unit historical stat
- set unit to also prioritize units that pose a threat to it first in addition to above (prioritize threats)
- [ongoing] unit balance :)
- load from export file...
- make death explosions w/ tween :)
- show turn resolve summary/highlights
- diagonal panning (n-key rollover?)
-
MID priority
- make UI preview units in blueprint + unit fac choice...
- support both manual + AI targetting simultaneously
- better collision resolution
- enable placing more factories
- more map types {height, width, control points}
- make factories destructable
- need to make facs buildable first...
- add ability to unlock higher limits for certain stats?? (like researching tech)
- huge refactor for readability?
-
LOW priority
- better unit visuals based on unit class (artillery, tanky, raider, scout, balanced)
- maybe different pricing formulas based on unit class?
- more unit stats
- sight radius?
- AOE
- short/long reload...
- healing per sec
- all units to show healthbars
- factory upgrade build speed, build radius
- factory choose where to build unit
- use more backend validation instead of frontend validation
-
a lot of hacks/simple tricks are possible simply b/c it's small scale (< 50 units usually)
-
Victor.js is mutable, modifies vector directly unless you use
.clone()
- Frontend doesn't use hot-reload per-se, but preserves state across reloads because of custom server-side socket.io reconnect logic
- Backend uses node-hot for hot-reloading file changes in
./game
without restarting server.- Also can tolerate errors (fix the error, then press enter in console to continue game)
Frontend hot-reload uses webpack-hot-middleware- can't use Parcel for FE b/c v1 trips on sourcemaps so can't import
paper
- parcel2 issues here
- can't use Parcel for FE b/c v1 trips on sourcemaps so can't import
- perf-wise, https://github.com/slaylines/canvas-engines-comparison says most things are pretty decent at 5k moving entities.
in hindsight, should've used Fabric.js http://fabricjs.com/fabric-intro-part-1#why_fabric which is much better maintained, also has scenegraph + collisions via intersection
- docs are crappy though...
- paper js - has vector lib, lots of demos, has scenegraph, has efficient sweep+Prune collision detection paperjs/paper.js#1737
- collisions - http://paperjs.org/reference/item/#intersects-item
- two js - focuses on animation, has basic vector lib, has scenegraph, but doesn't have mouse event support for actual entities, bad docs
- pixi js - just rendering, not enough, has collision detect?
- stage js - not actively developed, no vector lib, has scenegraph, bad docs
- pencil js - bad docs
- p5.js - ??
- b/c paper JS's vector point stuff doesn't really work...
- https://github.com/evanshortiss/vector2d
- ended up using http://victorjs.org/