EVERYBODY MAKE SOME NOISE

This commit is contained in:
Robbie Antenesse 2016-04-16 15:43:39 -06:00
parent 717c9e9213
commit 02285f1d8e
7 changed files with 71 additions and 32 deletions

View File

@ -14,9 +14,11 @@ function drawInventoryGUI() {
OS.context.drawImage(guiControl.background, 0, 0, 240, 240, pixel(2), pixel(2), 240, 240); OS.context.drawImage(guiControl.background, 0, 0, 240, 240, pixel(2), pixel(2), 240, 240);
if (ct_down().down) { if (ct_down().down) {
snd_cursordown.Play();
guiControl.inventory.cursorPosition++; guiControl.inventory.cursorPosition++;
} }
if (ct_up().down) { if (ct_up().down) {
snd_cursorup.Play();
guiControl.inventory.cursorPosition--; guiControl.inventory.cursorPosition--;
} }
@ -69,18 +71,22 @@ function drawInventoryGUI() {
break; break;
} }
snd_select.Play();
guiControl.inventory.cursorPosition = 0; guiControl.inventory.cursorPosition = 0;
guiControl.inventory.activateDelay = 5; guiControl.inventory.activateDelay = 5;
} }
if (ct_cancel().down) { if (ct_cancel().down) {
snd_select.Play();
guiControl.inventory.show = false; guiControl.inventory.show = false;
} }
if (ct_left().down) { if (ct_left().down) {
snd_cursorup.Play();
guiControl.inventory.show = false; guiControl.inventory.show = false;
guiControl.map.activateDelay = 5; guiControl.map.activateDelay = 5;
guiControl.map.show = true; guiControl.map.show = true;
} }
if (ct_right().down) { if (ct_right().down) {
snd_cursordown.Play();
guiControl.inventory.show = false; guiControl.inventory.show = false;
guiControl.map.activateDelay = 5; guiControl.map.activateDelay = 5;
guiControl.map.show = true; guiControl.map.show = true;
@ -113,6 +119,7 @@ function drawInventoryGUI() {
// Button Action // Button Action
if (guiControl.inventory.activateDelay <= 0) { if (guiControl.inventory.activateDelay <= 0) {
if (ct_confirm().down || ct_cancel().down) { if (ct_confirm().down || ct_cancel().down) {
snd_select.Play();
guiControl.inventory.screen = "main"; guiControl.inventory.screen = "main";
guiControl.inventory.activateDelay = 5; guiControl.inventory.activateDelay = 5;
guiControl.inventory.cursorPosition = 0; guiControl.inventory.cursorPosition = 0;
@ -147,6 +154,7 @@ function drawInventoryGUI() {
// Button Action // Button Action
if (guiControl.inventory.activateDelay <= 0) { if (guiControl.inventory.activateDelay <= 0) {
if (ct_confirm().down || ct_cancel().down) { if (ct_confirm().down || ct_cancel().down) {
snd_select.Play();
guiControl.inventory.screen = "main"; guiControl.inventory.screen = "main";
guiControl.inventory.activateDelay = 5; guiControl.inventory.activateDelay = 5;
guiControl.inventory.cursorPosition = 1; guiControl.inventory.cursorPosition = 1;
@ -193,6 +201,7 @@ function drawInventoryGUI() {
// Button Action // Button Action
if (guiControl.inventory.activateDelay <= 0) { if (guiControl.inventory.activateDelay <= 0) {
if (ct_confirm().down || ct_cancel().down) { if (ct_confirm().down || ct_cancel().down) {
snd_select.Play();
guiControl.inventory.screen = "main"; guiControl.inventory.screen = "main";
guiControl.inventory.activateDelay = 5; guiControl.inventory.activateDelay = 5;
guiControl.inventory.cursorPosition = 2; // The position where "Supplies" is on main screen. guiControl.inventory.cursorPosition = 2; // The position where "Supplies" is on main screen.

View File

@ -40,14 +40,17 @@ function drawMapGUI() {
// Button Action // Button Action
if (guiControl.map.activateDelay <= 0) { if (guiControl.map.activateDelay <= 0) {
if (ct_cancel().down) { if (ct_cancel().down) {
snd_select.Play();
guiControl.map.show = false; guiControl.map.show = false;
} }
if (ct_left().down) { if (ct_left().down) {
snd_cursorup.Play();
guiControl.map.show = false; guiControl.map.show = false;
guiControl.inventory.activateDelay = 5; guiControl.inventory.activateDelay = 5;
guiControl.inventory.show = true; guiControl.inventory.show = true;
} }
if (ct_right().down) { if (ct_right().down) {
snd_cursordown.Play();
guiControl.map.show = false; guiControl.map.show = false;
guiControl.inventory.activateDelay = 5; guiControl.inventory.activateDelay = 5;
guiControl.inventory.show = true; guiControl.inventory.show = true;

View File

@ -29,19 +29,19 @@ function drawTradeGUI() {
Oversimplified.context.fillStyle = tmp; Oversimplified.context.fillStyle = tmp;
if (ct_down().down) { if (ct_down().down) {
// Play Move_Cursor sound. snd_cursordown.Play();
guiControl.trade.cursorPosition++; guiControl.trade.cursorPosition++;
} }
if (ct_up().down) { if (ct_up().down) {
// Play Move_Cursor_Up sound. snd_cursorup.Play();
guiControl.trade.cursorPosition--; guiControl.trade.cursorPosition--;
} }
if (ct_right().down) { if (ct_right().down) {
// Play Move_Cursor sound. snd_cursordown.Play();
guiControl.trade.page++; guiControl.trade.page++;
} }
if (ct_left().down) { if (ct_left().down) {
// Play Move_Cursor_Up sound. snd_cursorup.Play();
guiControl.trade.page--; guiControl.trade.page--;
} }
@ -86,37 +86,45 @@ function drawTradeGUI() {
switch (guiControl.trade.cursorPosition) { switch (guiControl.trade.cursorPosition) {
case 0: case 0:
if (guiControl.trade.island.CheckInventory().length > 0) { if (guiControl.trade.island.CheckInventory().length > 0) {
snd_select.Play();
guiControl.trade.screen = "buy"; guiControl.trade.screen = "buy";
guiControl.trade.activateDelay = 5; guiControl.trade.activateDelay = 5;
} }
else { else {
// Play Cannot_Buy sound. snd_cannotbuy.Play();
} }
break; break;
case 1: case 1:
snd_select.Play();
if (G.inventory.CheckCargo().length > 0) { if (G.inventory.CheckCargo().length > 0) {
guiControl.trade.screen = "sell"; guiControl.trade.screen = "sell";
guiControl.trade.activateDelay = 5; guiControl.trade.activateDelay = 5;
} else { } else {
// Play Cannot_Buy sound. snd_cannotbuy.Play();
} }
break; break;
case 2: case 2:
snd_select.Play();
guiControl.trade.screen = "tavern"; guiControl.trade.screen = "tavern";
guiControl.trade.activateDelay = 5; guiControl.trade.activateDelay = 5;
break; break;
default: default:
// Change music to Sail. snd_select.Play();
mus_trade.Stop();
mus_sail.Play();
guiControl.trade.show = false; guiControl.trade.show = false;
break; break;
} }
// Play Select sound. // snd_select.Play();
guiControl.trade.cursorPosition = 0; guiControl.trade.cursorPosition = 0;
guiControl.trade.page = 0; guiControl.trade.page = 0;
// console.log(guiControl.trade.screen); // console.log(guiControl.trade.screen);
} }
if (ct_cancel().down) { if (ct_cancel().down) {
snd_select.Play();
mus_trade.Stop();
mus_sail.Play();
guiControl.trade.show = false; guiControl.trade.show = false;
} }
} }
@ -190,31 +198,34 @@ function drawTradeGUI() {
if (items.length > 0 && (guiControl.trade.island.timesHaggledToday <= G.stats.popularity) && // If there are items and you haven't haggled too much if (items.length > 0 && (guiControl.trade.island.timesHaggledToday <= G.stats.popularity) && // If there are items and you haven't haggled too much
guiControl.trade.island.haggleAmount == 0 && Math.floor(Math.randomRange(0, 100)) < G.stats.popularity) // Or you haven't haggled yet and get a random number less than your popularity, haggle successfully. guiControl.trade.island.haggleAmount == 0 && Math.floor(Math.randomRange(0, 100)) < G.stats.popularity) // Or you haven't haggled yet and get a random number less than your popularity, haggle successfully.
{ {
snd_sell.Play();
guiControl.trade.island.haggleAmount = G.stats.haggling; guiControl.trade.island.haggleAmount = G.stats.haggling;
// Play Sell sound.
} else { } else {
// Play Cannot_Buy sound. snd_cannotbuy.Play();
guiControl.trade.island.timesHaggledToday++; guiControl.trade.island.timesHaggledToday++;
} }
break; break;
case 1: // Buy case 1: // Buy
if (items.length > 0 && if (items.length > 0 &&
G.inventory.CanBuy(items[guiControl.trade.page], itemPrice)) { //If cursor is over yes and you can buy, buy it. G.inventory.CanBuy(items[guiControl.trade.page], itemPrice)) //If cursor is over yes and you can buy, buy it.
{
snd_buy.Play();
guiControl.trade.island.BuyFrom(items[guiControl.trade.page], itemPrice); guiControl.trade.island.BuyFrom(items[guiControl.trade.page], itemPrice);
} else { } else {
// Play Cannot_Buy sound. snd_cannotbuy.Play();
} }
break; break;
default: default:
snd_select.Play();
guiControl.trade.screen = "main"; guiControl.trade.screen = "main";
guiControl.trade.activateDelay = 5; guiControl.trade.activateDelay = 5;
guiControl.trade.cursorPosition = 0; // The position where "Buy" is on main screen. guiControl.trade.cursorPosition = 0; // The position where "Buy" is on main screen.
break; break;
} }
// Play Select sound.
// console.log(guiControl.trade.screen); // console.log(guiControl.trade.screen);
} }
if (ct_cancel().down) { if (ct_cancel().down) {
snd_select.Play();
guiControl.trade.screen = "main"; guiControl.trade.screen = "main";
guiControl.trade.activateDelay = 5; guiControl.trade.activateDelay = 5;
guiControl.trade.cursorPosition = 0; // The position where "Buy" is on main screen. guiControl.trade.cursorPosition = 0; // The position where "Buy" is on main screen.
@ -293,10 +304,10 @@ function drawTradeGUI() {
if (items.length > 0 && (guiControl.trade.island.timesHaggledToday <= G.stats.popularity) && if (items.length > 0 && (guiControl.trade.island.timesHaggledToday <= G.stats.popularity) &&
guiControl.trade.island.haggleAmount == 0 && Math.floor(Math.randomRange(0, 100)) < G.stats.popularity) // If you haven't haggled yet and get a random number less than your popularity, haggle successfully. guiControl.trade.island.haggleAmount == 0 && Math.floor(Math.randomRange(0, 100)) < G.stats.popularity) // If you haven't haggled yet and get a random number less than your popularity, haggle successfully.
{ {
// Play Sell sound. snd_sell.Play();
guiControl.trade.island.haggleAmount = G.stats.haggling; guiControl.trade.island.haggleAmount = G.stats.haggling;
} else { } else {
// Play Cannot_Buy sound. snd_cannotbuy.Play();
guiControl.trade.island.timesHaggledToday++; guiControl.trade.island.timesHaggledToday++;
} }
break; break;
@ -304,21 +315,23 @@ function drawTradeGUI() {
if (items.length > 0 && if (items.length > 0 &&
G.inventory.CanSell(items[guiControl.trade.page])) //If cursor is over yes and you can buy, buy it. G.inventory.CanSell(items[guiControl.trade.page])) //If cursor is over yes and you can buy, buy it.
{ {
snd_sell.Play();
guiControl.trade.island.SellTo(items[guiControl.trade.page], itemPrice); guiControl.trade.island.SellTo(items[guiControl.trade.page], itemPrice);
} else { } else {
// Play Cannot_Buy sound. snd_cannotbuy.Play();
} }
break; break;
default: default:
snd_select.Play();
guiControl.trade.screen = "main"; guiControl.trade.screen = "main";
guiControl.trade.activateDelay = 5; guiControl.trade.activateDelay = 5;
guiControl.trade.cursorPosition = 1; // The position where "Sell" is on main screen. guiControl.trade.cursorPosition = 1; // The position where "Sell" is on main screen.
break; break;
} }
// Play Select sound.
// console.log(guiControl.trade.screen); // console.log(guiControl.trade.screen);
} }
if (ct_cancel().down) { if (ct_cancel().down) {
snd_select.Play();
guiControl.trade.screen = "main"; guiControl.trade.screen = "main";
guiControl.trade.activateDelay = 5; guiControl.trade.activateDelay = 5;
guiControl.trade.cursorPosition = 1; // The position where "Sell" is on main screen. guiControl.trade.cursorPosition = 1; // The position where "Sell" is on main screen.
@ -363,18 +376,21 @@ function drawTradeGUI() {
if (ct_confirm().down) { if (ct_confirm().down) {
switch (guiControl.trade.cursorPosition) { switch (guiControl.trade.cursorPosition) {
case 0: case 0:
snd_select.Play();
guiControl.trade.screen = "gossip"; guiControl.trade.screen = "gossip";
guiControl.trade.activateDelay = 5; guiControl.trade.activateDelay = 5;
guiControl.trade.cursorPosition = 2; // The position where "Supplies" is on main screen. guiControl.trade.cursorPosition = 2; // The position where "Supplies" is on main screen.
break; break;
case 1: case 1:
if (G.stats.illness > 0 && G.inventory.money > innPrice) { //If cursor is over yes, heal illness with supplies. if (G.stats.illness > 0 && G.inventory.money > innPrice) { //If cursor is over yes, heal illness with supplies.
snd_heal.Play();
guiControl.trade.island.StayAtInn(); guiControl.trade.island.StayAtInn();
} else { } else {
// Play Cant_Buy sound. snd_cannotbuy.Play();
} }
break; break;
default: default:
snd_select.Play();
guiControl.trade.screen = "main"; guiControl.trade.screen = "main";
guiControl.trade.activateDelay = 5; guiControl.trade.activateDelay = 5;
guiControl.trade.cursorPosition = 2; // The position where "Supplies" is on main screen. guiControl.trade.cursorPosition = 2; // The position where "Supplies" is on main screen.
@ -386,6 +402,7 @@ function drawTradeGUI() {
} }
if (ct_cancel().down) { if (ct_cancel().down) {
snd_select.Play();
guiControl.trade.screen = "main"; guiControl.trade.screen = "main";
guiControl.trade.activateDelay = 5; guiControl.trade.activateDelay = 5;
guiControl.trade.cursorPosition = 2; // The position where "Supplies" is on main screen. guiControl.trade.cursorPosition = 2; // The position where "Supplies" is on main screen.
@ -416,7 +433,7 @@ function drawTradeGUI() {
// Button Action // Button Action
if (guiControl.trade.activateDelay <= 0) { if (guiControl.trade.activateDelay <= 0) {
if (ct_confirm().down || ct_cancel().down) { if (ct_confirm().down || ct_cancel().down) {
// Play Select sound. snd_select.Play();
guiControl.trade.screen = "tavern"; guiControl.trade.screen = "tavern";
guiControl.trade.activateDelay = 5; guiControl.trade.activateDelay = 5;
guiControl.trade.cursorPosition = 0; guiControl.trade.cursorPosition = 0;

View File

@ -117,6 +117,8 @@ pr_island.CheckInventory = function () { // Returns an array of indices that hav
pr_island.TradeWith = function () { pr_island.TradeWith = function () {
// Change music to Trade. // Change music to Trade.
// console.log(this.inventory); // console.log(this.inventory);
mus_sail.Stop();
mus_trade.Play();
guiControl.trade.island = this; guiControl.trade.island = this;
guiControl.trade.haggleAmount = 0; guiControl.trade.haggleAmount = 0;
guiControl.trade.activateDelay = 5; guiControl.trade.activateDelay = 5;

View File

@ -214,7 +214,7 @@ pr_ship.AdjustSpeedBasedOnEnergy = function () {
pr_ship.CheckIllnessIncrease = function () { pr_ship.CheckIllnessIncrease = function () {
var percentChance = G.stats.crew + ((this.currentSpeed / (G.stats.energy + 0.001)) * G.stats.illness); // +0.001 on the off-chance that energy reaches 0. var percentChance = G.stats.crew + ((this.currentSpeed / (G.stats.energy + 0.001)) * G.stats.illness); // +0.001 on the off-chance that energy reaches 0.
if (Math.randomRange(0, 100) < percentChance) { if (Math.randomRange(0, 100) < percentChance) {
// Play Illness sound. snd_illness.Play();
G.stats.illness++; G.stats.illness++;
this.drawSickIndicator += secondsWorthOfFrames(1.5); this.drawSickIndicator += secondsWorthOfFrames(1.5);
} }

View File

@ -10,6 +10,11 @@ var pr_wave = OS.P.Add("Wave Particle", {
lifeTimer: 100, lifeTimer: 100,
}); });
pr_wave.DoFirst = function () {
if (!snd_wave.IsPlaying()) {
snd_wave.Play();
}
}
pr_wave.Do = function () { pr_wave.Do = function () {
// Move around randomly. // Move around randomly.
this.lifeTimer--; this.lifeTimer--;

View File

@ -14,6 +14,8 @@ rm_Ocean.waveTimer = Math.round(Math.randomRange(30, 150));
rm_Ocean.clockTimerCount = 1; // Set it to 1 so it doesn't check for player illness immediately! rm_Ocean.clockTimerCount = 1; // Set it to 1 so it doesn't check for player illness immediately!
rm_Ocean.DoFirst = function () { rm_Ocean.DoFirst = function () {
mus_sail.Play();
G.player.x = (this.squareSize * (this.squaresX / 2)) - (this.squareSize / 2) - G.player.xBound; G.player.x = (this.squareSize * (this.squaresX / 2)) - (this.squareSize / 2) - G.player.xBound;
G.player.y = (this.squareSize * (this.squaresY / 2)); G.player.y = (this.squareSize * (this.squaresY / 2));
// console.log(G.player.name + " created at " + G.player.x + ", " + G.player.y); // console.log(G.player.name + " created at " + G.player.x + ", " + G.player.y);
@ -40,21 +42,22 @@ rm_Ocean.DoFirst = function () {
// G.economy.UpdateEconomy(); // G.economy.UpdateEconomy();
} }
rm_Ocean.Do = function () { rm_Ocean.Do = function () {
// Move G.oceanParticle around based on player's movement.
if (G.oceanParticle.CheckPosition) G.oceanParticle.CheckPosition(G.player.x, G.player.y, G.player.direction);
this.waveTimer--;
if (this.waveTimer <= 0) {
var wave = this.AddObject(OS.P["Wave Particle"]);
wave.x = G.player.x + (randomSmidge() * 4);
wave.y = G.player.y + (randomSmidge() * 4);
this.waveTimer = Math.round(Math.randomRange(30, 150));
}
if (guiControl && guiControl.inventory && guiControl.trade) { // Force it to wait until loaded. if (guiControl && guiControl.inventory && guiControl.trade) { // Force it to wait until loaded.
if (!guiControl.inventory.show && !guiControl.map.show && !guiControl.trade.show) { if (!guiControl.inventory.show && !guiControl.map.show && !guiControl.trade.show) {
// Move G.oceanParticle around based on player's movement.
if (G.oceanParticle.CheckPosition) G.oceanParticle.CheckPosition(G.player.x, G.player.y, G.player.direction);
this.waveTimer--;
if (this.waveTimer <= 0) {
var wave = this.AddObject(OS.P["Wave Particle"]);
wave.x = G.player.x + (randomSmidge() * 4);
wave.y = G.player.y + (randomSmidge() * 4);
this.waveTimer = Math.round(Math.randomRange(30, 150));
}
if (ct_cancel().down) { if (ct_cancel().down) {
snd_select.Play();
guiControl.inventory.activateDelay = 5; guiControl.inventory.activateDelay = 5;
guiControl.inventory.show = true; guiControl.inventory.show = true;
} }