Browse Source

use witch sprites by default, elide others

main
Colin McMillen 4 years ago
parent
commit
f9b11e5833
  1. 14
      main.js
  2. 8
      scripts/assets.py
  3. 2
      scripts/deploy.sh

14
main.js

@ -378,7 +378,7 @@ class Player {
for (const name in spritesheet_json) { for (const name in spritesheet_json) {
this.spriteNames_.push(name); this.spriteNames_.push(name);
} }
this.spriteNamesIdx_ = 8;
this.spriteNamesIdx_ = 0;
} }
get spriteName() { get spriteName() {
@ -395,24 +395,24 @@ class Player {
moveLeft() { moveLeft() {
this.orientation = Orientation.LEFT; this.orientation = Orientation.LEFT;
this.x -= 2; this.x -= 2;
if (this.x < -4) {
this.x = -4;
if (this.x < -2) {
this.x = -2;
} }
} }
moveRight() { moveRight() {
this.orientation = Orientation.RIGHT; this.orientation = Orientation.RIGHT;
this.x += 2; this.x += 2;
if (this.x > SNES_WIDTH - 21) {
this.x = SNES_WIDTH - 21;
if (this.x > SNES_WIDTH - 23) {
this.x = SNES_WIDTH - 23;
} }
} }
moveUp() { moveUp() {
this.orientation = Orientation.UP; this.orientation = Orientation.UP;
this.y -= 2; this.y -= 2;
if (this.y < -7) {
this.y = -7;
if (this.y < -2) {
this.y = -2;
} }
} }

8
scripts/assets.py

@ -274,8 +274,11 @@ def check_sprites(metadata):
json.dump(metadata, f, sort_keys=True, indent=2) json.dump(metadata, f, sort_keys=True, indent=2)
def stitch_sprites(metadata, filename_base):
def stitch_sprites(metadata, filename_base, sprite_names=None):
sprites = get_named_sprites(metadata) sprites = get_named_sprites(metadata)
if sprite_names:
sprites = dict([(x[0], x[1])
for x in sprites.items() if x[0] in sprite_names])
max_height = 0 max_height = 0
total_width = 0 total_width = 0
for sprite_name, sprite in sprites.items(): for sprite_name, sprite in sprites.items():
@ -343,7 +346,8 @@ def main(args):
print('need FILENAME_BASE') print('need FILENAME_BASE')
return return
filename_base = args[1] filename_base = args[1]
stitch_sprites(metadata, filename_base)
sprite_names = args[2:]
stitch_sprites(metadata, filename_base, sprite_names)
else: else:
print('unrecognized command "%s"' % command) print('unrecognized command "%s"' % command)

2
scripts/deploy.sh

@ -4,6 +4,6 @@ cd $SNEJ_ROOT
echo "deploying to $1" echo "deploying to $1"
mkdir -p bundle/ mkdir -p bundle/
python3 scripts/assets.py stitch-sprites $SNEJ_ROOT/bundle/spritesheet
python3 scripts/assets.py stitch-sprites $SNEJ_ROOT/bundle/spritesheet witch_gray witch_green
scp -r index.html main.js bundle/ $1 scp -r index.html main.js bundle/ $1
echo "success!" echo "success!"
Loading…
Cancel
Save