Skip to content

Commit

Permalink
umbrella sprite
Browse files Browse the repository at this point in the history
  • Loading branch information
paytontech committed Apr 15, 2024
1 parent 93f80c1 commit a6a19c9
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 2 deletions.
2 changes: 1 addition & 1 deletion TODO.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
- [ ] cleanup [WorldBackground.js](classes/WorldBackground.js)
- [ ] airborne swoop state
- [ ] implement snake
- [ ] add umbrella sprite
- [x] add umbrella sprite
- [ ] map obstacles
- [ ] collectables
- [ ] coins
Expand Down
Binary file added assets/sprites/umbrella/umbrella-idle.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
10 changes: 10 additions & 0 deletions classes/events/Rainfall.js
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,23 @@ class Umbrella extends DynamicCreature {
this.sprite.velocity.x = random([-1.2, 1.2]);
this.startTime = millis();
this.changedDirection = false;
this.lastRainCollision = millis() - 10000;
}
update(gameWorld, rain) {
// this.sprite.image = umbrellaIdleImg;
for (let rainEntity of rain) {
if (this.sprite.collides(rainEntity.sprite)) {
// this.sprite.image = umbrellaRainCollisionImg;
this.lastRainCollision = millis();
rainEntity.sprite.remove();
}
}
console.log(this.lastRainCollision - millis());
if (millis() - this.lastRainCollision < 250 && this.lastRainCollision >= 0) {
this.sprite.image = umbrellaRainCollisionImg;
} else {
this.sprite.image = umbrellaIdleImg;
}

if (millis() % 5000 < 50) {
console.log((millis() - this.startTime) % 1000);
Expand Down
6 changes: 5 additions & 1 deletion sketch.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ let score = 0;
let playerAnimations = {};
let joystick;
var usingController = false;
let umbrellaIdleImg;
let umbrellaRainCollisionImg;

function preload() {
window.addEventListener('keydown', function (e) {
Expand All @@ -31,6 +33,8 @@ function preload() {
playerAnimations.jump = loadImage("assets/sprites/player/player-jump.gif");
playerAnimations.fall = loadImage("assets/sprites/player/player-fall.gif");
playerAnimations.dying = loadImage("assets/sprites/player/player-dying.gif");
umbrellaIdleImg = loadImage("assets/sprites/umbrella/umbrella-idle.png");
umbrellaRainCollisionImg = loadImage("assets/sprites/umbrella/umbrella-raincollision.png");
}

function addBetaDisclaimer() {
Expand Down Expand Up @@ -58,7 +62,7 @@ function setup() {
gameWorld.registerEvent(new PongEvent());
gameWorld.registerEvent(new WPMEvent());
gameWorld.registerEvent(new CoinRushEvent());
// gameWorld.registerEvent(new Event());
gameWorld.registerEvent(new Event());
gameWorld.onEventChange = () => {
animStartTime = millis();
doingTextAnim = gameWorld.eventRunning;
Expand Down

0 comments on commit a6a19c9

Please sign in to comment.