Various minor tweaks and changes

* Recolor some of the region doodads
* Add command: `doodad edit-level --remove-actor` to remove actors from
  your level.
* Tweak the player jump velocity from playtesting levels.
This commit is contained in:
Noah 2021-10-07 20:50:24 -07:00
parent d6acee5a66
commit e80a3f0446
8 changed files with 36 additions and 6 deletions

View File

@ -55,6 +55,10 @@ func init() {
Name: "unlock", Name: "unlock",
Usage: "remove the write-lock on the level file", Usage: "remove the write-lock on the level file",
}, },
&cli.StringFlag{
Name: "remove-actor",
Usage: "Remove all instances of the actor from the level. Value is their filename or UUID.",
},
}, },
Action: func(c *cli.Context) error { Action: func(c *cli.Context) error {
if c.NArg() < 1 { if c.NArg() < 1 {
@ -145,6 +149,29 @@ func editLevel(c *cli.Context, filename string) error {
modified = true modified = true
} }
if c.String("remove-actor") != "" {
var (
match = c.String("remove-actor")
removeIDs = []string{}
)
for id, actor := range lvl.Actors {
if id == match || actor.Filename == match {
removeIDs = append(removeIDs, id)
}
}
if len(removeIDs) > 0 {
for _, id := range removeIDs {
delete(lvl.Actors, id)
}
log.Info("Removed %d instances of actor %s from the level.", len(removeIDs), match)
modified = true
} else {
log.Error("Did not find any actors like %s in the level.", match)
}
}
/****************************** /******************************
* Save level changes to disk * * Save level changes to disk *
******************************/ ******************************/

Binary file not shown.

Before

Width:  |  Height:  |  Size: 957 B

After

Width:  |  Height:  |  Size: 956 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 986 B

After

Width:  |  Height:  |  Size: 990 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 873 B

After

Width:  |  Height:  |  Size: 780 B

View File

@ -24,7 +24,7 @@ var (
// Player speeds // Player speeds
PlayerMaxVelocity float64 = 7 PlayerMaxVelocity float64 = 7
PlayerJumpVelocity float64 = -20 PlayerJumpVelocity float64 = -23
PlayerAcceleration float64 = 0.12 PlayerAcceleration float64 = 0.12
Gravity float64 = 7 Gravity float64 = 7
GravityAcceleration float64 = 0.1 GravityAcceleration float64 = 0.1

View File

@ -470,9 +470,6 @@ func (u *EditorUI) SetupCanvas(d *Doodle) *uix.Canvas {
// Was it an already existing actor to re-add to the map? // Was it an already existing actor to re-add to the map?
if actor.actor != nil { if actor.actor != nil {
actor.actor.Point = position
u.Scene.Level.Actors.Add(actor.actor)
// Was this doodad drop, the Play Level button? // Was this doodad drop, the Play Level button?
if actor.actor.Filename == "__play_from_here__" { if actor.actor.Filename == "__play_from_here__" {
if shmem.Cursor.Inside(u.PlayButton.Rect()) { if shmem.Cursor.Inside(u.PlayButton.Rect()) {
@ -482,6 +479,9 @@ func (u *EditorUI) SetupCanvas(d *Doodle) *uix.Canvas {
} }
return nil return nil
} }
actor.actor.Point = position
u.Scene.Level.Actors.Add(actor.actor)
} else { } else {
u.Scene.Level.Actors.Add(&level.Actor{ u.Scene.Level.Actors.Add(&level.Actor{
Point: position, Point: position,

View File

@ -151,7 +151,11 @@ func NewLevel(ev *event.State) bool {
// Save (Ctrl-S) // Save (Ctrl-S)
func Save(ev *event.State) bool { func Save(ev *event.State) bool {
return ev.Ctrl && ev.KeyDown("s") var result = ev.Ctrl && ev.KeyDown("s")
if result {
ev.SetKeyDown("s", false)
}
return result
} }
// SaveAs (Shift-Ctrl-S) // SaveAs (Shift-Ctrl-S)

View File

@ -541,7 +541,6 @@ func (s *PlayScene) movePlayer(ev *event.State) {
// Moving left or right? Interpolate their velocity by acceleration. // Moving left or right? Interpolate their velocity by acceleration.
if direction != 0 { if direction != 0 {
if s.playerLastDirection != direction { if s.playerLastDirection != direction {
log.Error("Changed directions!")
velocity.X = 0 velocity.X = 0
} }