Skip to content

Commit

Permalink
closes Gaweph#6
Browse files Browse the repository at this point in the history
  • Loading branch information
rodigu committed May 23, 2023
1 parent 76d897b commit 39fc981
Show file tree
Hide file tree
Showing 3 changed files with 52 additions and 1 deletion.
Binary file added assets/img/marmita.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
42 changes: 41 additions & 1 deletion sketch/game/entities/marmita.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,43 @@
class Marmitas {
static create(manager: GameManager) {}
static Behaviors = {
Show: "show",
Hide: "hide",
};

static AnimationCycles: { [key: string]: NewCycleInformation } = {
static: {
cycleName: "static",
frames: [0],
timing: 5,
},
};

static create(manager: GameManager) {
const marmita = new Entity(
"marmita",
1,
{ width: manager.UnitSize, height: manager.UnitSize * 2 },
{ x: 0, y: 0 }
);

const { Marmita } = AssetList;

const marmitaSpritesheet = manager.getAsset(Marmita.name) as p5.Image;

const marmitaTileset = new Tileset(
marmitaSpritesheet,
Marmita.originalTileSize,
Marmita.columns
);

const { newCycleFunction, setCurrentSpriteFunction } =
BaseBehaviors.addSpriteAnimation(marmita, marmitaTileset);

newCycleFunction(Marmitas.AnimationCycles.static);
setCurrentSpriteFunction(Marmitas.AnimationCycles.static.cycleName);

marmita.activateBehavior(BaseBehaviors.Names.SpriteAnimation);

manager.addEntity(marmita, marmita.layer);
}
}
11 changes: 11 additions & 0 deletions sketch/game/gameSetup/assetList.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,15 @@ const AssetList: { [key: string]: AssetSettings } = {
type: "image",
name: "PlayerSprite",
},

Marmita: {
columns: 1,
originalTileSize: {
width: 360,
height: 360,
},
path: "./assets/img/marmita.png",
type: "image",
name: "Marmita",
},
} as const;

0 comments on commit 39fc981

Please sign in to comment.