Skip to content

Commit

Permalink
Refactoring Images
Browse files Browse the repository at this point in the history
  • Loading branch information
VolatileCoder committed Sep 28, 2024
1 parent 9ecf7a8 commit 04100af
Show file tree
Hide file tree
Showing 16 changed files with 127 additions and 98 deletions.
4 changes: 2 additions & 2 deletions assets/js/goldruin/characters/Adventurer.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//REQUIRES Character, Direction, Team, State, SoundEffects
//REQUIRES Character, Direction, Team, State, SoundEffects, Images

class Adventurer extends Character{

Expand Down Expand Up @@ -52,7 +52,7 @@ class Adventurer extends Character{
render(deltaT, screen){
var framestart = Date.now()
if(!this.sprite){
this.sprite = new VC.Sprite(screen, images.adventurer, 800, 600, 100, 100, 0, 0);
this.sprite = new VC.Sprite(screen, Images.ADVENTURER, 800, 600, 100, 100, 0, 0);
}
if(DEBUG){
this.box.render(screen, "#FF0");
Expand Down
4 changes: 2 additions & 2 deletions assets/js/goldruin/characters/CaveSpider.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//REQUIRES Character, Team, Direction, State
//REQUIRES Character, Team, Direction, State, Images, SoundEffects

class CaveSpider extends Character {
constructor(room, controller){
Expand Down Expand Up @@ -62,7 +62,7 @@ class CaveSpider extends Character {

render(deltaT, screen){
if(!this.sprite){
this.sprite = new VC.Sprite(screen, images.caveSpider, 800, 500, 100, 100, 0, 0);
this.sprite = new VC.Sprite(screen, Images.CAVE_SPIDER, 800, 500, 100, 100, 0, 0);
}
if(DEBUG){
this.box.render(screen, "#FFF");
Expand Down
4 changes: 2 additions & 2 deletions assets/js/goldruin/characters/Snake.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//REQUIRES Character, Team, Direction, State
//REQUIRES Character, Team, Direction, State, Images, SoundEffects

class Snake extends Character {
sprite = null;
Expand All @@ -24,7 +24,7 @@ class Snake extends Character {
};
render(deltaT, screen){
if(!this.sprite){
this.sprite = new VC.Sprite(screen, images.kingCobra, 800, 500, 100, 100, 0, 0);
this.sprite = new VC.Sprite(screen, Images.KING_COBRA, 800, 500, 100, 100, 0, 0);
}
if(DEBUG){
this.box.render(screen, "#FFF");
Expand Down
4 changes: 2 additions & 2 deletions assets/js/goldruin/characters/SwordSkeleton.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//REQUIRES Character, Starburst, State, Team, Direction
//REQUIRES Character, Starburst, State, Team, Direction, Images, SoundEffects

class SwordSkeleton extends Character{
constructor(room, controller){
Expand Down Expand Up @@ -55,7 +55,7 @@ class SwordSkeleton extends Character{

render(deltaT, screen){
if(!this.sprite){
this.sprite = new VC.Sprite(screen, images.swordSkeleton, 1200, 750, 150, 150, this.box.x-50, this.box.y-59);
this.sprite = new VC.Sprite(screen, Images.SWORD_SKELETON, 1200, 750, 150, 150, this.box.x-50, this.box.y-59);
this.sprite.lastLocation.x = this.box.x-50;
this.sprite.lastLocation.y = this.box.y-59;
}
Expand Down
92 changes: 92 additions & 0 deletions assets/js/goldruin/embed/Images.js

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions assets/js/goldruin/game.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//REQUIRES main, Statistics, Direction, State, Team, Adventurer, InputController
//REQUIRES main, Statistics, Direction, State, Team, Adventurer, InputController, Images
//REQUIRES TitleScreen
class Game extends VC.Game {
infoScreen = new VC.Screen("info", 0, 0, dimensions.width, dimensions.height);
Expand Down Expand Up @@ -93,18 +93,18 @@ class Game extends VC.Game {
this.infoElements.hearts = [];
this.infoElements.keys = [];
for(var i=0; i<constants.maxHeartContainers; i++){
var heart = new VC.Sprite(this.infoScreen,images.heartContainer,32,128,32,32, i * 36 + 8, 8)
var heart = new VC.Sprite(this.infoScreen,Images.HEART_CONTAINER,32,128,32,32, i * 36 + 8, 8)
this.infoElements.hearts.push(heart);
}
for(var i=0; i<5; i++){
this.infoElements.keys.push(new VC.Sprite(this.infoScreen, images.keyIcons, 32, 192, 32, 32, i * 36 + 8, 48))
this.infoElements.keys.push(new VC.Sprite(this.infoScreen, Images.KEY_ICONS, 32, 192, 32, 32, i * 36 + 8, 48))
}
//this.screen.circle(dimensions.width-20,64,10).attr({"fill":"#ffd700", "stroke":"#FFF", "stroke-width": 3});

this.infoElements.coinSprite = new VC.Sprite(this.infoScreen, images.treasure, 36, 504, 36, 36, dimensions.width-36, 48);
this.infoElements.coinSprite = new VC.Sprite(this.infoScreen, Images.TREASURE, 36, 504, 36, 36, dimensions.width-36, 48);
this.infoElements.coinSprite.setFrame(0,Treasure.COIN,0);

this.infoElements.tntSprite = new VC.Sprite(this.infoScreen, images.treasure, 36, 504, 36, 36, dimensions.width-36, 10);
this.infoElements.tntSprite = new VC.Sprite(this.infoScreen, Images.TREASURE, 36, 504, 36, 36, dimensions.width-36, 10);
this.infoElements.tntSprite.scale=.8
this.infoElements.tntSprite.setFrame(0,Treasure.TNT,0);

Expand Down
67 changes: 2 additions & 65 deletions assets/js/goldruin/main.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions assets/js/goldruin/objects/Explosion.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//REQUIRES GameObject, Layer, Plane, State, ScorchMark, Direction
//REQUIRES GameObject, Layer, Plane, State, ScorchMark, Direction, Images, SoundEffects

class Explosion extends GameObject{

Expand Down Expand Up @@ -57,7 +57,7 @@ class Explosion extends GameObject{
return;
}
if(!this.#sprite){
this.#sprite = new VC.Sprite(screen, images.explosion, 1000, 200, 200, 200, this.box.x, this.box.y);
this.#sprite = new VC.Sprite(screen, Images.EXPLOSION, 1000, 200, 200, 200, this.box.x, this.box.y);
this.#sprite.setAnimation(0,0);
this.#sprite.location.r = Math.round(Math.random() * 360);
VC.VisualEffects.shake(screen,1, 200);
Expand Down
4 changes: 2 additions & 2 deletions assets/js/goldruin/objects/ScorchMark.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//REQUIRES GameObject Layer, Plane
//REQUIRES GameObject Layer, Plane, Images

class ScorchMark extends GameObject{
#sprite = null;
Expand All @@ -20,7 +20,7 @@ class ScorchMark extends GameObject{

render(deltaT, screen){
if(!this.#sprite){
this.#sprite = new VC.Sprite(screen, images.scorch, 75, 225, 75, 75, this.box.x, this.box.y);
this.#sprite = new VC.Sprite(screen, Images.SCORCH_MARK, 75, 225, 75, 75, this.box.x, this.box.y);
this.#sprite.setAnimation(0,this.style);
this.#sprite.location.r = this.rotation;
}
Expand Down
4 changes: 2 additions & 2 deletions assets/js/goldruin/objects/SpikeTrap.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//REQUIRES GameObject, Layer, State, Direction, Starburst
//REQUIRES GameObject, Layer, State, Direction, Starburst, Images, SoundEffects
class SpikeTrap extends GameObject{
#sprite = null;
constructor(room, offsetT){
Expand Down Expand Up @@ -44,7 +44,7 @@ class SpikeTrap extends GameObject{

render (deltaT, screen){
if(!this.#sprite){
this.#sprite = new VC.Sprite(screen,images.floorSpikes,496, 150, 62, 50,this.box.x, this.box.y);
this.#sprite = new VC.Sprite(screen,Images.FLOOR_SPIKES,496, 150, 62, 50,this.box.x, this.box.y);
screen.onClear(()=>{
this.#sprite = null;
})
Expand Down
4 changes: 2 additions & 2 deletions assets/js/goldruin/objects/Starburst.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//REQUIRES GameObject, Layer, Plane, State
//REQUIRES GameObject, Layer, Plane, State, Images

class Starburst extends GameObject{
#sprite = null;
Expand All @@ -15,7 +15,7 @@ class Starburst extends GameObject{
return;
}
if(!this.#sprite){
this.#sprite = new VC.Sprite(screen, images.starburst, 100, 25, 25, 25, this.box.center().x-12, this.box.center().y-12);
this.#sprite = new VC.Sprite(screen, Images.STARBURST, 100, 25, 25, 25, this.box.center().x-12, this.box.center().y-12);
this.#sprite.setAnimation(0,0);
this.#sprite.location.r = Math.round(Math.random() * 360);
}
Expand Down
4 changes: 2 additions & 2 deletions assets/js/goldruin/objects/TNT.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//REQUIRES GameObject, Explosion, Layer, Plane, State
//REQUIRES GameObject, Explosion, Layer, Plane, State, Images, SoundEffects

class TNT extends GameObject{
sprite = null;
Expand Down Expand Up @@ -100,7 +100,7 @@ class TNT extends GameObject{
}

if(!this.sprite){
this.sprite = new VC.Sprite(screen, images.dynamite, 384, 24, 24, 24, this.box.center().x-12, this.box.center().y-12);
this.sprite = new VC.Sprite(screen, Images.TNT, 384, 24, 24, 24, this.box.center().x-12, this.box.center().y-12);
this.sprite.setAnimation(0,0);
}

Expand Down
4 changes: 2 additions & 2 deletions assets/js/goldruin/objects/Torch.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//REQUIRES GameObject, Plane, Layer, Direction, State
//REQUIRES GameObject, Plane, Layer, Direction, State, Images
class Torch extends GameObject{
sprite = null;
#particles=[];
Expand Down Expand Up @@ -32,7 +32,7 @@ class Torch extends GameObject{
render(deltaT, screen){
this.box.render(screen, "#FFF");
if(this.sprite==null){
this.sprite = new VC.Sprite(screen, images.torch, 512,256, 64, 64,this.box.x-32, this.box.y-32);
this.sprite = new VC.Sprite(screen, Images.TORCH, 512,256, 64, 64,this.box.x-32, this.box.y-32);
this.sprite.lastLocation.r = this.sprite.location.r = this.wall * 90;
screen.onClear(()=>{
this.sprite = null;
Expand Down
8 changes: 4 additions & 4 deletions assets/js/goldruin/objects/TreasureChest.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//REQUIRES GameObject, Team, Treasure
//REQUIRES GameObject, Team, Treasure, Images, SoundEffects

class TreasureChest extends GameObject{
#elements=[]
Expand Down Expand Up @@ -86,12 +86,12 @@ class TreasureChest extends GameObject{

render(deltaT, screen){
if(this.#elements.length == 0){
this.#backgroundSprite = new VC.Sprite(screen,images.chest,64,256,64,64,this.box.x,this.box.y-32);
this.#backgroundSprite = new VC.Sprite(screen,Images.CHEST,64,256,64,64,this.box.x,this.box.y-32);
this.#elements.push(this.#backgroundSprite);
//TODO: Move to "pickup" object (animation?)
this.#contentSprite = new VC.Sprite(screen, images.treasure, 36, 504, 36, 36, this.box.x+14,this.box.y-18)
this.#contentSprite = new VC.Sprite(screen, Images.TREASURE, 36, 504, 36, 36, this.box.x+14,this.box.y-18)
this.#elements.push(this.#contentSprite);
this.#foregroundSprite = new VC.Sprite(screen,images.chest,64,256,64,64,this.box.x,this.box.y-32);
this.#foregroundSprite = new VC.Sprite(screen,Images.CHEST,64,256,64,64,this.box.x,this.box.y-32);
this.#elements.push(this.#foregroundSprite);
screen.onClear(()=>{this.#elements=[]});
}
Expand Down
8 changes: 4 additions & 4 deletions assets/js/goldruin/scenes/TitleScreen.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
//REQUIRES Torch, Direction, Music, SoundEffects
//REQUIRES Torch, Direction, Music, SoundEffects, Images

class TitleScreen extends VC.Scene {
#prompt = null;
Expand Down Expand Up @@ -101,16 +101,16 @@ class TitleScreen extends VC.Scene {
render(deltaT, screen){
if(this.#rendered == false){
screen.drawRect(0,0,dimensions.width, dimensions.width, SCREENBLACK, SCREENBLACK, 0);
screen.image(images.logo, 150, 150, 600, 320);
screen.image(Images.LOGO, 150, 150, 600, 320);
this.#prompt = screen.text(dimensions.width/2, dimensions.width-300, "PRESS " + (VC.Client.orientation == VC.Orientation.PORTRAIT ? "FIRE" : "SPACE BAR") + " TO BEGIN").attr({ "font-size": "48px", "font-family": "monospace", "fill": "#FFF", "text-anchor": "middle", "font-weight": "bold"});
screen.text(dimensions.width/2, dimensions.width-220, "In Stereo").attr({ "font-size": "22px", "font-family": "monospace", "fill": "#DDD", "text-anchor": "middle", "font-weight": "bold"});
screen.text(dimensions.width/2, dimensions.width-190, "Where Available").attr({ "font-size": "22px", "font-family": "monospace", "fill": "#DDD", "text-anchor": "middle", "font-weight": "bold"});
screen.text(dimensions.width/2, dimensions.width-133, VERSION).attr({ "font-size": "28px", "font-family": "monospace", "fill": "#888", "text-anchor": "middle", "font-weight": "bold"});
this.#rendered = true

this.#volume1 = new VC.Sprite(screen, images.volume, 500, 25, 50, 25, dimensions.width/2 + 65, dimensions.width-232);
this.#volume1 = new VC.Sprite(screen, Images.VOLUME, 500, 25, 50, 25, dimensions.width/2 + 65, dimensions.width-232);
this.#volume1.setAnimation(0, 0);
this.#volume2 = new VC.Sprite(screen, images.volume, 500, 25, 50, 25, dimensions.width/2 - 115, dimensions.width-233);
this.#volume2 = new VC.Sprite(screen, Images.VOLUME, 500, 25, 50, 25, dimensions.width/2 - 115, dimensions.width-233);
this.#volume2.setAnimation(0, 0);
this.#volume2.location.r = this.#volume2.lastLocation.r = 180;
}
Expand Down
Binary file modified docs/play/game.js
Binary file not shown.

0 comments on commit 04100af

Please sign in to comment.