Commit Graph

8 Commits (c1a87e03e6f6253ff466c0ad662f555c18473a12)

Author SHA1 Message Date
Noah c1a87e03e6 Switch JavaScript engine to goja
* Switch from otto to goja for JavaScript engine.
* goja supports many ES6 syntax features like arrow functions,
  const/let, for-of with more coming soon.
* Same great features as otto, more modern environment for doodads!
2022-01-16 20:09:27 -08:00
Noah 8b47e6c4cb Various updates
New doodad interactions:
* Sticky Buttons will emit a "sticky:down" event to linked doodads, with
  a boolean value showing the Sticky Button's state.
* Normal Buttons will listen for "sticky:down" -- when a linked Sticky
  Button is pressed, the normal Button presses in as well, and stays
  pressed while the sticky:down signal is true.
* When the Sticky Button is released (e.g. because it received power
  from another doodad), any linked buttons which were sticky:down
  release as well.
* Switch doodads emit a new "switch:toggle" event JUST BEFORE sending
  the "power" event. Sensitive Doodads can listen for switches in
  particular this way.
* The Electric Door listens for switch:toggle; if a Switch is activated,
  the Electric Door always flips its current state (open to close, or
  vice versa) and ignores the immediately following power event. This
  allows doors to toggle on/off regardless of sync with a Switch.

Other changes:
* When the player character dies by fire, instead of the message saying
  "Watch out for fire!" it will use the name of the fire swatch that
  hurt the player. This way levels could make it say "Watch out for
  spikes!" or "lava" or whatever they want. The "Fire" attribute now
  just means "instantly kills the player."
* Level Editor: You can now edit the Title and Author name of your level
  in the Page Settings window.
* Bugfix: only the player character ends the game by dying in fire.
  Other mobile doodads just turn dark but don't end the game.
* Increase the size of Trapdoor doodad sprites by 150% as they were a
  bit small for the player character.
* Rename the game from "Project: Doodle" to "Sketchy Maze"
2021-03-30 23:40:41 -07:00
Noah 375af544a7 Doodads: Use Key and Working Warp Doors
* The "Use Key" (Q or Spacebar) now activates the Warp Door instead of a
  collision event doing so.
* Warp Doors are now functional: the player opens a door, disappears,
  the door closes; player is teleported to the linked door which opens,
  appears the player and closes.
* If the player exits thru a Blue or Orange door which is disabled
  (dotted outline), the door still opens and drops the player off but
  returns to a Disabled state, acting as a one-way door.
* Clean up several debug log lines from Doodle and doodad scripts.
2021-01-03 15:19:21 -08:00
Noah 227a58bb39 Tighten Doodad JavaScript API, User Documentation
* Tightens up the surface area of API methods available to the
  JavaScript VMs for doodads. Variables and functions are carefully
  passed in one-by-one so the doodad script can only access intended
  functions and not snoop on undocumented APIs.
* Wrote tons of user documentation for Doodad Scripts: documented the
  full surface area of the exposed JavaScript API now that the surface
  area is known and limited.
* Early WIP code for the Campaign JSON
2020-04-21 23:50:45 -07:00
Noah 81e986fadf Overhaul the Platformer Physics System
* Player character now experiences acceleration and friction when
  walking around the map!
* Actor position and movement had to be converted from int's
  (render.Point) to float64's to support fine-grained acceleration
  steps.
* Added "physics" package and physics.Vector to be a float64 counterpart
  for render.Point. Vector is used for uix.Actor.Position() for the sake
  of movement math. Vector is flattened back to a render.Point for
  collision purposes, since the levels and hitboxes are pixel-bound.
* Refactor the uix.Actor to no longer extend the doodads.Drawing (so it
  can have a Position that's a Vector instead of a Point). This broke
  some code that expected `.Doodad` to directly reference the
  Drawing.Doodad: now you had to refer to it as `a.Drawing.Doodad` which
  was ugly. Added convenience method .Doodad() for a shortcut.
* Moved functions like GetBoundingRect() from doodads package to
  collision, where it uses its own slimmer Actor interface for just the
  relevant methods it needs.
2020-04-04 21:00:32 -07:00
Noah a4e3dbb8d4 Doodad Tool: Add Tag Support for edit-doodad
* The `doodad edit-doodad` command now allows setting custom key/value
  tags in doodad files, for extra data storage useful to their scripts.
* Colored keys and doors now store a `color` tag with the appropriate
  color so that their scripts don't have to parse their Title to find
  that information.
* Trapdoors now store a `direction` tag to hold the direction the door
  is facing.
2020-01-02 22:12:20 -08:00
Noah 93b28ccc04 Improve Collision Detection: More Active w/ Actors
* Improve the collision detection algorithm so that Actor OnCollide
  scripts get called more often WHILE an actor is moving, to prevent a
  fast-moving actor from zipping right through the "solid" hitbox and
  not giving the subject actor time to protest the movement.
* It's implemented by adding a `Settled` boolean to the OnCollide event
  object. When the game is testing out movement, Settled=false to give
  the actor a chance to say "I'm solid!" and have the moving party be
  stopped early.
* After all this is done, for any pair of actors still with overlapping
  hitboxes, OnCollide is called one last time with Settled=true. This is
  when the actor should run its actions (like publishing messages to
  other actors, changing state as in a trapdoor, etc.)
* The new collision detection algorithm works as follows:
  * Stage 1 is the same as before, all mobile actors are moved and
    tested against level geometry. They record their Original and New
    position during this phase.
  * Stage 2 is where we re-run that movement but ping actors being
    intersected each step of the way. We trace the steps between
    Original and New position, test OnCollide handler, and if it returns
    false we move the mobile actor to the Last Good Position along the
    trace.
  * Stage 3 we run the final OnCollide(Settled=true) to let actors run
    actions they wanted to for their collide handler, WITHOUT spamming
    those actions during Stage 2.
* This should now allow for tweaking of gravity speed and player speed
  without breaking all actor collision checking.
2019-07-16 21:07:38 -07:00
Noah 91ed6457eb Add More Trapdoor Doodads
* Add the other trapdoor directions: Left, Right and Up.
* UI: Show a color square in each Palette Swatch button in Edit Mode.
  * Instead of just the label like "solid", "fire", "decoration" it also
    shows a square box colored as the swatch color. The label and box
    are left-aligned in the button.
* Minor Play Mode physics update:
  * The player jump is now limited: they may only continue to move
    upwards for 20 ticks, after which they must touch ground before
    jumping again.
  * Remove the "press Down to move down" button. Only gravity moves you
    down.
* Fix a crash in the Editor Mode when you dragged doodads on top of each
  other. Source of bug was the loopActorCollision() function, which only
  should be useful to Play Mode, and it expected the scripting engine to
  be attached to the Canvas. In EditorMode there is no scripting engine.
2019-07-05 15:02:22 -07:00