-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
85 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
// TODO: this is unfinished | ||
// Move over code from world.js to here | ||
|
||
// Background System | ||
|
||
// Background Sprite | ||
// An separate image that belongs to the background | ||
// Can be animated and/or interactable | ||
|
||
class BackgroundSprite { | ||
constructor(sprite, anim, x, y, worldy) { | ||
if (!BACKGROUNDIMG[this.area][img]) { | ||
BACKGROUNDIMG[this.area][img] = new RenderImage(`assets/areas/${img}`) | ||
} | ||
let sprite = new Sprite(BACKGROUNDIMG[this.area][img], s.framesx, s.framesy, s.qw, s.qh, s.ox, s.oy, s.sepx, s.sepy) | ||
BACKGROUNDSPRITE[this.area][name] = new DrawableSprite(sprite, null, s.x, s.y, s.worldy) | ||
// If defined, play animation | ||
if (s.anim) { | ||
BACKGROUNDANIM[this.area][name] = new Animation(sprite, 0, 0) | ||
BACKGROUNDANIM[this.area][name].playAnimation(s.anim.frames, s.anim.delay, null) | ||
BACKGROUNDSPRITE[this.area][name].anim = BACKGROUNDANIM[this.area][name] | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
// Notification | ||
// A little popup that appears at the top of the screen | ||
|
||
const Notify = (function() { | ||
let notifications = []; | ||
|
||
const notifyFunctions = { | ||
// Create new notification | ||
new: function(text, duration=3, color=[0,0,0]) { | ||
notifications.push({ | ||
text: text, | ||
timer: duration, // Duration in seconds | ||
duration: duration, | ||
color: color | ||
}) | ||
}, | ||
|
||
// Check if notification should expire | ||
update: function(dt) { | ||
for (let i = 0; i < notifications.length; i++) { | ||
const notification = notifications[i]; | ||
notification.timer -= dt | ||
if (notification.timer <= 0) { | ||
notifications.splice(i, 1) | ||
} | ||
} | ||
}, | ||
|
||
// Render all notifications | ||
draw: function() { | ||
if (notifications.length == 0) { | ||
return | ||
} | ||
// Border | ||
DRAW.setColor(255,255,255,0.8) | ||
DRAW.rectangle(700, 15, 300, 32*notifications.length, "fill") | ||
DRAW.setColor(0,0,0) | ||
DRAW.rectangle(700, 15, 300, 32*notifications.length, "line") | ||
DRAW.setFont(FONT.description) | ||
// Text | ||
for (let i = 0; i < notifications.length; i++) { | ||
const notification = notifications[i]; | ||
DRAW.setColor(...notification.color) | ||
DRAW.text(notification.text, 700 +3, 15+i*32 + 26, "left") | ||
} | ||
} | ||
} | ||
return notifyFunctions; })() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters