doodle/pkg/cheats.go
Noah Petherbridge fb5a8a1ae8 Async Giant Screenshot, Player Physics and UI Polish
* The "Giant Screenshot" feature takes a very long time, so it is made
  asynchronous. If you try and run a second one while the first is busy,
  you get an error flash. You can continue editing the level, even
  playtest it, or load a different level, and it will continue crunching
  on the Giant Screenshot and flash when it's finished.
* Updated the player physics to use proper Velocity to jump off the
  ground rather than the hacky timer-based fixed speed approach.
* FlashError() function to flash "error level" messages to the screen.
  They appear in orange text instead of the usual blue, and most error
  messages in the game use this now. The dev console "error <msg>"
  command can simulate an error message.
* Flashed message fonts are updated. The blue font now uses softer
  stroke and shadow colors and the same algorithm applies to the orange
  error flashes.

Some other changes to player physics:

* Max velocity, acceleration speed, and gravity have been tweaked.
* Fast turn-around if you are moving right and then need to go left.
  Your velocity resets to zero at the transition so you quickly get
  going the way you want to go.

Some levels that need a bit of love for the new platforming physics:

* Tutorial 3.level
2021-10-07 18:27:38 -07:00

125 lines
3.5 KiB
Go

package doodle
import (
"git.kirsle.net/apps/doodle/pkg/balance"
)
// cheatCommand is a subroutine of the Command.Run() method of the Doodle
// developer shell (commands.go). It looks for special cheat codes entered
// into the command shell and executes them.
//
// Returns true if a cheat was intercepted, false if the command is not a cheat.
func (c Command) cheatCommand(d *Doodle) bool {
// Some cheats only work in Play Mode.
playScene, isPlay := d.Scene.(*PlayScene)
// Cheat codes
switch c.Raw {
case "unleash the beast":
if fpsDoNotCap {
d.Flash("Reset frame rate throttle to factory default FPS")
} else {
d.Flash("Unleashing as many frames as we can render!")
}
fpsDoNotCap = !fpsDoNotCap
case "don't edit and drive":
if isPlay {
playScene.drawing.Editable = true
d.Flash("Level canvas is now editable. Don't edit and drive!")
} else {
d.FlashError("Use this cheat in Play Mode to make the level canvas editable.")
}
case "scroll scroll scroll your boat":
if isPlay {
playScene.drawing.Scrollable = true
d.Flash("Level canvas is now scrollable with the arrow keys.")
} else {
d.FlashError("Use this cheat in Play Mode to make the level scrollable.")
}
case "import antigravity":
if isPlay {
playScene.antigravity = !playScene.antigravity
playScene.Player.SetGravity(!playScene.antigravity)
if playScene.antigravity {
d.Flash("Gravity disabled for player character.")
} else {
d.Flash("Gravity restored for player character.")
}
} else {
d.FlashError("Use this cheat in Play Mode to disable gravity for the player character.")
}
case "ghost mode":
if isPlay {
playScene.noclip = !playScene.noclip
playScene.Player.SetNoclip(playScene.noclip)
playScene.antigravity = playScene.noclip
playScene.Player.SetGravity(!playScene.antigravity)
if playScene.noclip {
d.Flash("Clipping disabled for player character.")
} else {
d.Flash("Clipping and gravity restored for player character.")
}
} else {
d.FlashError("Use this cheat in Play Mode to disable clipping for the player character.")
}
case "show all actors":
if isPlay {
for _, actor := range playScene.drawing.Actors() {
actor.Show()
}
d.Flash("All invisible actors made visible.")
} else {
d.FlashError("Use this cheat in Play Mode to show hidden actors, such as technical doodads.")
}
case "give all keys":
if isPlay {
playScene.Player.AddItem("key-red.doodad", 0)
playScene.Player.AddItem("key-blue.doodad", 0)
playScene.Player.AddItem("key-green.doodad", 0)
playScene.Player.AddItem("key-yellow.doodad", 0)
playScene.Player.AddItem("small-key.doodad", 99)
d.Flash("Given all keys to the player character.")
} else {
d.FlashError("Use this cheat in Play Mode to get all colored keys.")
}
case "drop all items":
if isPlay {
playScene.Player.ClearInventory()
d.Flash("Cleared inventory of player character.")
} else {
d.FlashError("Use this cheat in Play Mode to clear your inventory.")
}
case "fly like a bird":
balance.PlayerCharacterDoodad = "bird-red.doodad"
d.Flash("Set default player character to Bird (red)")
case "pinocchio":
balance.PlayerCharacterDoodad = "boy.doodad"
d.Flash("Set default player character to Boy")
case "the cell":
balance.PlayerCharacterDoodad = "azu-blu.doodad"
d.Flash("Set default player character to Blue Azulian")
case "play as thief":
balance.PlayerCharacterDoodad = "thief.doodad"
d.Flash("Set default player character to Thief")
default:
return false
}
return true
}