Add Player Character Sprites

* Added initial walking sprites for the player character, "Boy."
* Player doodad filename and title screen level are now configurable in
  the balance/numbers.go package.
This commit is contained in:
Noah 2020-09-18 22:35:43 -07:00
parent 6d8aa387d7
commit 71b3eafbe4
14 changed files with 60 additions and 2 deletions

View File

@ -0,0 +1,37 @@
function main() {
var playerSpeed = 12;
var gravity = 4;
var Vx = Vy = 0;
var animating = false;
var animStart = animEnd = 0;
var animFrame = animStart;
Self.SetMobile(true);
Self.SetGravity(true);
Self.SetHitbox(0, 0, 29, 52);
Self.AddAnimation("walk-left", 200, ["stand-left", "walk-left-1", "walk-left-2", "walk-left-3", "walk-left-2", "walk-left-1"]);
Self.AddAnimation("walk-right", 200, ["stand-right", "walk-right-1", "walk-right-2", "walk-right-3", "walk-right-2", "walk-right-1"]);
Events.OnKeypress(function(ev) {
Vx = 0;
Vy = 0;
if (ev.Right) {
if (!Self.IsAnimating()) {
Self.PlayAnimation("walk-right", null);
}
Vx = playerSpeed;
} else if (ev.Left) {
if (!Self.IsAnimating()) {
Self.PlayAnimation("walk-left", null);
}
Vx = -playerSpeed;
} else {
Self.StopAnimation();
animating = false;
}
// Self.SetVelocity(Point(Vx, Vy));
})
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

View File

@ -8,6 +8,19 @@ fi
mkdir -p ../../assets/doodads
boy() {
cd boy/
doodad convert -t "Boy" stand-right.png stand-left.png \
walk-right-1.png walk-right-2.png walk-right-3.png \
walk-left-1.png walk-left-2.png walk-left-3.png \
boy.doodad
doodad install-script boy.js boy.doodad
cp *.doodad ../../../assets/doodads/
cd ..
}
buttons() {
cd buttons/
@ -123,6 +136,7 @@ onoff() {
cd ..
}
boy
buttons
switches
doors
@ -132,3 +146,4 @@ objects
onoff
doodad edit-doodad -quiet -lock -author "Noah" ../../assets/doodads/*.doodad
doodad edit-doodad -hide ../../assets/doodads/azu-blu.doodad
doodad edit-doodad -hide ../../assets/doodads/boy.doodad

View File

@ -43,6 +43,12 @@ var (
}
DefaultEraserBrushSize = 8
MaxEraserBrushSize = 32 // the bigger, the slower
// Default player character doodad in Play Mode.
PlayerCharacterDoodad = "boy.doodad"
// Level name for the title screen.
DemoLevelName = "example 1.level"
)
// Edit Mode Values

View File

@ -171,7 +171,7 @@ func (s *MainScene) SetupDemoLevel(d *Doodle) error {
s.canvas.SetScriptSupervisor(s.scripting)
// Title screen level to load.
if lvl, err := level.LoadFile("example1.level"); err == nil {
if lvl, err := level.LoadFile(balance.DemoLevelName); err == nil {
s.canvas.LoadLevel(d.Engine, lvl)
s.canvas.InstallActors(lvl.Actors)

View File

@ -193,7 +193,7 @@ func (s *PlayScene) Setup(d *Doodle) error {
// setupPlayer creates and configures the Player Character in the level.
func (s *PlayScene) setupPlayer() {
// Load in the player character.
player, err := doodads.LoadFile("azu-blu.doodad")
player, err := doodads.LoadFile(balance.PlayerCharacterDoodad)
if err != nil {
log.Error("PlayScene.Setup: failed to load player doodad: %s", err)
player = doodads.NewDummy(32)