Compare commits
44 commits
Apr-14-201
...
master
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6dad9281d7 | ||
|
|
7b8729d4e0 | ||
| 27e95d4011 | |||
| 2847374049 | |||
| d47671f95a | |||
| 00669ea907 | |||
| 17227e054a | |||
| 62524d8693 | |||
| 98a02a38ac | |||
| c81d094094 | |||
| d31c5eb855 | |||
| fd244f027b | |||
| 628fd925f0 | |||
| d62da3341f | |||
| 1b025e4fb8 | |||
| 6648720aee | |||
| 924a25c608 | |||
| 63ff3fd1a6 | |||
| 632257d5d8 | |||
| 80d8d50785 | |||
| e5353026e1 | |||
| 65d6722122 | |||
| 9d80d31647 | |||
| f5a40f0ebe | |||
| 7601a60842 | |||
| 9c63b8e4b0 | |||
| f63788a6c5 | |||
| 6b2302d52a | |||
| 3401cb3559 | |||
| c923b2b8ec | |||
| 41fa0610ed | |||
| 8369415812 | |||
| 16e27ec04c | |||
| f20065727f | |||
| 02285f1d8e | |||
| 717c9e9213 | |||
| 2dfd594cb0 | |||
| 5daacc2771 | |||
| 9acc3130e4 | |||
| 4388514610 | |||
| 69888da3c6 | |||
| 55ce2e7c1f | |||
| 8e09e8b2a0 | |||
| 34de633ef3 |
1932
Oversimplified.js
|
|
@ -1,2 +1,4 @@
|
|||
# LowRez-Jam-2016
|
||||
An OversimplifiedJS game for the 2016 LowRez Jam (https://itch.io/jam/lowrezjam2016)
|
||||
# Trade Winds
|
||||
An [OversimplifiedJS](https://github.com/Alamantus/OversimplifiedJS) game for [#LOWREZJAM 2016](https://itch.io/jam/lowrezjam2016).
|
||||
|
||||
Play the [official version on Itch.io](https://alamantus-gamedev.itch.io/trade-winds) or follow along with the exciting [development version where all the new features are being added](https://alamantusgamedev.github.io/Trade-Winds)!
|
||||
|
|
|
|||
BIN
audio/music/credits.mp3
Normal file
BIN
audio/music/credits.wav
Normal file
BIN
audio/music/ocean.mp3
Normal file
BIN
audio/music/ocean.wav
Normal file
BIN
audio/music/title.mp3
Normal file
BIN
audio/music/title.wav
Normal file
BIN
audio/music/trade.mp3
Normal file
BIN
audio/music/trade.wav
Normal file
BIN
audio/sounds/Buy.mp3
Normal file
BIN
audio/sounds/Cannot_Buy.mp3
Normal file
BIN
audio/sounds/Heal.mp3
Normal file
BIN
audio/sounds/Illness.mp3
Normal file
BIN
audio/sounds/Move_Cursor.mp3
Normal file
BIN
audio/sounds/Move_Cursor_Up.mp3
Normal file
BIN
audio/sounds/Sailing.mp3
Normal file
BIN
audio/sounds/Select.mp3
Normal file
BIN
audio/sounds/Sell.mp3
Normal file
BIN
audio/sounds/Wave_Crash.mp3
Normal file
BIN
audio/sounds/sources/Buy.wav
Normal file
BIN
audio/sounds/sources/Cannot_Buy.wav
Normal file
BIN
audio/sounds/sources/Heal.wav
Normal file
BIN
audio/sounds/sources/Illness.wav
Normal file
BIN
audio/sounds/sources/Move_Cursor.wav
Normal file
BIN
audio/sounds/sources/Move_Cursor_Up.wav
Normal file
BIN
audio/sounds/sources/Sailing.wav
Normal file
BIN
audio/sounds/sources/Select.wav
Normal file
BIN
audio/sounds/sources/Sell.wav
Normal file
BIN
audio/sounds/sources/Wave_Crash.wav
Normal file
|
|
@ -1,214 +1,221 @@
|
|||
function inventoryGUI() {
|
||||
guiControl.inventory = {
|
||||
screen: "main",
|
||||
cursorPosition: 0,
|
||||
show: false,
|
||||
activateDelay: 0
|
||||
}
|
||||
if (Oversimplified.DEBUG.showMessages) console.log("Ran inventoryGUI()");
|
||||
}
|
||||
|
||||
function drawInventoryGUI() {
|
||||
if (guiControl.inventory && guiControl.inventory.show) {
|
||||
guiControl.inventory.activateDelay -= (guiControl.inventory.activateDelay > 0) ? 1 : 0;
|
||||
|
||||
OS.context.drawImage(guiControl.background, 0, 0, 240, 240, pixel(2), pixel(2), 240, 240);
|
||||
|
||||
if (ct_down().down) {
|
||||
guiControl.inventory.cursorPosition++;
|
||||
}
|
||||
if (ct_up().down) {
|
||||
guiControl.inventory.cursorPosition--;
|
||||
}
|
||||
|
||||
if (guiControl.inventory.screen == "main") {
|
||||
// Limit Cursor
|
||||
if (guiControl.inventory.cursorPosition < 0) {
|
||||
guiControl.inventory.cursorPosition = 3;
|
||||
}
|
||||
if (guiControl.inventory.cursorPosition > 3) {
|
||||
guiControl.inventory.cursorPosition = 0;
|
||||
}
|
||||
|
||||
// Title
|
||||
guiControl.drawPixelText("Storage", guiControl.leftBorder - pixel(2), guiControl.topOfBackground, 8, "black", 6);
|
||||
|
||||
guiControl.drawPageArrow("left", pixel(4), guiControl.topOfBackground);
|
||||
guiControl.drawPageArrow("right", OS.camera.width - pixel(4) - pixel(4), guiControl.topOfBackground);
|
||||
|
||||
// Money icon
|
||||
guiControl.drawIcon(7, 2, guiControl.leftBorder, guiControl.rowTop(0));
|
||||
guiControl.drawPixelText(G.inventory.moneyDisplay(), guiControl.leftBorder + pixel(guiControl.iconSize + 4), guiControl.rowTop(0) + pixel(), 8, "black", 6);
|
||||
// Supplies icon
|
||||
guiControl.drawIcon(9, 2, guiControl.leftBorder, guiControl.rowTop(1));
|
||||
guiControl.drawPixelText(G.inventory.supplies.toString(), guiControl.leftBorder + pixel(guiControl.iconSize + 4), guiControl.rowTop(1) + pixel(), 8, "black", 6);
|
||||
// Cargo icon
|
||||
guiControl.drawIcon(1, 0, guiControl.leftBorder, guiControl.rowTop(2));
|
||||
guiControl.drawPixelText(G.inventory.CargoTotal().toString(), guiControl.leftBorder + pixel(guiControl.iconSize + 4), guiControl.rowTop(2) + pixel(), 8, "black", 6);
|
||||
|
||||
// Close Text
|
||||
guiControl.drawPixelText("Close", guiControl.leftBorder, guiControl.rowTop(3) + pixel(), 8, "black", 6);
|
||||
|
||||
// Draw cursor
|
||||
OS.context.drawImage(guiControl.cursor, guiControl.leftBorder - (guiControl.iconScaled), guiControl.rowTop(guiControl.inventory.cursorPosition));
|
||||
|
||||
// Button Action
|
||||
if (guiControl.inventory.activateDelay <= 0) {
|
||||
if (ct_confirm().down) {
|
||||
switch (guiControl.inventory.cursorPosition) {
|
||||
case 0:
|
||||
guiControl.inventory.screen = "money";
|
||||
break;
|
||||
case 1:
|
||||
guiControl.inventory.screen = "supplies";
|
||||
break;
|
||||
case 2:
|
||||
guiControl.inventory.screen = "cargo";
|
||||
break;
|
||||
default:
|
||||
guiControl.inventory.show = false;
|
||||
break;
|
||||
}
|
||||
|
||||
guiControl.inventory.cursorPosition = 0;
|
||||
guiControl.inventory.activateDelay = 5;
|
||||
}
|
||||
if (ct_cancel().down) {
|
||||
guiControl.inventory.show = false;
|
||||
}
|
||||
if (ct_left().down) {
|
||||
guiControl.inventory.show = false;
|
||||
guiControl.map.activateDelay = 5;
|
||||
guiControl.map.show = true;
|
||||
}
|
||||
if (ct_right().down) {
|
||||
guiControl.inventory.show = false;
|
||||
guiControl.map.activateDelay = 5;
|
||||
guiControl.map.show = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (guiControl.inventory.screen == "money") {
|
||||
// Limit Cursor
|
||||
if (guiControl.inventory.cursorPosition < 0) {
|
||||
guiControl.inventory.cursorPosition = 0;
|
||||
}
|
||||
if (guiControl.inventory.cursorPosition > 0) {
|
||||
guiControl.inventory.cursorPosition = 0;
|
||||
}
|
||||
|
||||
// Title
|
||||
guiControl.drawPixelText("Money", guiControl.leftBorder - pixel(2), guiControl.topOfBackground, 8, "black", 6);
|
||||
|
||||
guiControl.drawPixelText("Actual Amt", guiControl.leftBorder - pixel(5), guiControl.rowTop(0) + pixel(), 10, "black", 4);
|
||||
// Money icon
|
||||
guiControl.drawIcon(7, 2, guiControl.leftBorder - pixel(5), guiControl.rowTop(1) - pixel(3));
|
||||
guiControl.drawPixelText(G.inventory.money.toString(), guiControl.leftBorder - pixel(5) + pixel(guiControl.iconSize + 2), guiControl.rowTop(1) + pixel(2) - pixel(3), 10, "black", 4);
|
||||
|
||||
// Back Text
|
||||
guiControl.drawPixelText("Back", guiControl.leftBorder, guiControl.rowTop(4) - pixel(3), 8, "black", 6);
|
||||
|
||||
// Draw cursor
|
||||
OS.context.drawImage(guiControl.cursor, guiControl.leftBorder - (guiControl.iconScaled), guiControl.rowTop(4) - pixel(4));
|
||||
|
||||
// Button Action
|
||||
if (guiControl.inventory.activateDelay <= 0) {
|
||||
if (ct_confirm().down || ct_cancel().down) {
|
||||
guiControl.inventory.screen = "main";
|
||||
guiControl.inventory.activateDelay = 5;
|
||||
guiControl.inventory.cursorPosition = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (guiControl.inventory.screen == "supplies") {
|
||||
// Limit Cursor
|
||||
if (guiControl.inventory.cursorPosition < 0) {
|
||||
guiControl.inventory.cursorPosition = 2;
|
||||
}
|
||||
if (guiControl.inventory.cursorPosition > 2) {
|
||||
guiControl.inventory.cursorPosition = 0;
|
||||
}
|
||||
|
||||
// Title
|
||||
guiControl.drawPixelText("Supplies", guiControl.leftBorder - pixel(6), guiControl.topOfBackground, 8, "black", 6);
|
||||
|
||||
guiControl.drawPixelText("Heal Crew?", guiControl.leftBorder - pixel(5), guiControl.rowTop(0) + pixel(), 10, "black", 4);
|
||||
// Supplies icon
|
||||
guiControl.drawIcon(9, 2, guiControl.leftBorder - pixel(5), guiControl.rowTop(1) - pixel(3));
|
||||
guiControl.drawPixelText(G.inventory.supplies.toString(), guiControl.leftBorder - pixel(5) + pixel(guiControl.iconSize + 2), guiControl.rowTop(1) + pixel(2) - pixel(3), 2, "black", 4);
|
||||
// Illness icon
|
||||
guiControl.drawIcon(4, 1, guiControl.leftBorder - pixel(5) + pixel(24), guiControl.rowTop(1) - pixel(3));
|
||||
guiControl.drawPixelText(G.stats.illness.toString(), guiControl.leftBorder - pixel(5) + pixel(24) + pixel(guiControl.iconSize + 2), guiControl.rowTop(1) + pixel(2) - pixel(3), 2, "black", 4);
|
||||
|
||||
// Yes/No options
|
||||
guiControl.drawPixelText("No", guiControl.leftBorder, guiControl.rowTop(2) - pixel(3), 3, "black", 6);
|
||||
guiControl.drawPixelText("Yes", guiControl.leftBorder, guiControl.rowTop(3) - pixel(3), 3, (G.inventory.supplies > 0 && G.stats.illness > 0) ? "black" : "white", 6);
|
||||
|
||||
// Back Text
|
||||
guiControl.drawPixelText("Back", guiControl.leftBorder, guiControl.rowTop(4) - pixel(3), 8, "black", 6);
|
||||
|
||||
// Draw cursor
|
||||
guiControl.drawCursor(guiControl.leftBorder - (guiControl.iconScaled), guiControl.rowTop(guiControl.inventory.cursorPosition + 2) - pixel(4));
|
||||
|
||||
// Button Action
|
||||
if (guiControl.inventory.activateDelay <= 0) {
|
||||
if (ct_confirm().down) {
|
||||
switch (guiControl.inventory.cursorPosition) {
|
||||
case 1:
|
||||
if (G.inventory.supplies > 0 && G.stats.illness > 0) { //If cursor is over yes, heal illness with supplies.
|
||||
G.inventory.supplies--;
|
||||
G.stats.illness--;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
guiControl.inventory.screen = "main";
|
||||
guiControl.inventory.cursorPosition = 1; // The position where "Supplies" is on main screen.
|
||||
break;
|
||||
}
|
||||
|
||||
// Give a cooldown so you don't accidentally do something you don't want.
|
||||
guiControl.inventory.activateDelay = 5;
|
||||
}
|
||||
|
||||
if (ct_cancel().down) {
|
||||
guiControl.inventory.screen = "main";
|
||||
guiControl.inventory.activateDelay = 5;
|
||||
guiControl.inventory.cursorPosition = 1; // The position where "Supplies" is on main screen.
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (guiControl.inventory.screen == "cargo") {
|
||||
// Limit Cursor
|
||||
if (guiControl.inventory.cursorPosition < 0) {
|
||||
guiControl.inventory.cursorPosition = 0;
|
||||
}
|
||||
if (guiControl.inventory.cursorPosition > 0) {
|
||||
guiControl.inventory.cursorPosition = 0;
|
||||
}
|
||||
|
||||
// Title
|
||||
guiControl.drawPixelText("Cargo", guiControl.leftBorder - pixel(2), guiControl.topOfBackground, 8, "black", 6);
|
||||
|
||||
// Cargo icons
|
||||
var cargo = G.inventory.CheckCargo(); // Contains the item ids that have more than 1 item
|
||||
for (var i = 0; i < cargo.length; i++) {
|
||||
guiControl.drawItem(cargo[i], guiControl.leftBorder, guiControl.rowTop(i));
|
||||
guiControl.drawPixelText(G.inventory.cargo[cargo[i]], guiControl.leftBorder + pixel(guiControl.iconSize + 4), guiControl.rowTop(i) + pixel(), 8, "black", 6);
|
||||
}
|
||||
|
||||
// Back Text
|
||||
guiControl.drawPixelText("Back", guiControl.leftBorder, guiControl.rowTop(4) - pixel(3), 8, "black", 6);
|
||||
|
||||
// Draw cursor
|
||||
OS.context.drawImage(guiControl.cursor, guiControl.leftBorder - (guiControl.iconScaled), guiControl.rowTop(4) - pixel(4));
|
||||
|
||||
// Button Action
|
||||
if (guiControl.inventory.activateDelay <= 0) {
|
||||
if (ct_confirm().down || ct_cancel().down) {
|
||||
guiControl.inventory.screen = "main";
|
||||
guiControl.inventory.activateDelay = 5;
|
||||
guiControl.inventory.cursorPosition = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
guiControl.inventory = {
|
||||
screen: "main",
|
||||
cursorPosition: 0,
|
||||
show: false,
|
||||
activateDelay: 0,
|
||||
}
|
||||
|
||||
guiControl.inventory.Draw = function () {
|
||||
if (guiControl.inventory && guiControl.inventory.show) {
|
||||
guiControl.inventory.activateDelay -= (guiControl.inventory.activateDelay > 0) ? 1 : 0;
|
||||
|
||||
guiControl.drawGUIBackground();
|
||||
|
||||
if (ct_down().down) {
|
||||
snd_cursordown.Play();
|
||||
guiControl.inventory.cursorPosition++;
|
||||
}
|
||||
if (ct_up().down) {
|
||||
snd_cursordown.Play();
|
||||
guiControl.inventory.cursorPosition--;
|
||||
}
|
||||
|
||||
if (guiControl.inventory.screen == "main") {
|
||||
// Limit Cursor
|
||||
if (guiControl.inventory.cursorPosition < 0) {
|
||||
guiControl.inventory.cursorPosition = 3;
|
||||
}
|
||||
if (guiControl.inventory.cursorPosition > 3) {
|
||||
guiControl.inventory.cursorPosition = 0;
|
||||
}
|
||||
|
||||
// Title
|
||||
guiControl.drawPixelText("Storage", guiControl.leftBorder - pixel(2), guiControl.topOfBackground, 8, "black", 6);
|
||||
|
||||
guiControl.drawPageArrow("left", pixel(4), guiControl.topOfBackground);
|
||||
guiControl.drawPageArrow("right", pixel(4) + guiControl.gui_sheet.guiBackground.width - pixel(4) - pixel(4), guiControl.topOfBackground);
|
||||
|
||||
// Money icon
|
||||
guiControl.drawIcon(7, 2, guiControl.leftBorder, guiControl.rowTop(0));
|
||||
guiControl.drawPixelText(G.inventory.moneyDisplay(), guiControl.leftBorder + pixel(guiControl.iconSize + 4), guiControl.rowTop(0) + pixel(), 8, "black", 6);
|
||||
// Cargo icon
|
||||
guiControl.drawIcon(1, 0, guiControl.leftBorder, guiControl.rowTop(1));
|
||||
guiControl.drawPixelText(G.inventory.CargoTotal().toString(), guiControl.leftBorder + pixel(guiControl.iconSize + 4), guiControl.rowTop(1) + pixel(), 8, "black", 6);
|
||||
// Stats icon
|
||||
// guiControl.drawIcon(9, 2, guiControl.leftBorder, guiControl.rowTop(2));
|
||||
guiControl.drawPixelText("Status", guiControl.leftBorder, guiControl.rowTop(2) + pixel(), 8, "black", 6);
|
||||
|
||||
// Close Text
|
||||
guiControl.drawPixelText("Close", guiControl.leftBorder, guiControl.rowTop(3) + pixel(), 8, "black", 6);
|
||||
|
||||
// Draw cursor
|
||||
guiControl.drawCursor(guiControl.leftBorder - (guiControl.iconScaled), guiControl.rowTop(guiControl.inventory.cursorPosition));
|
||||
|
||||
// Button Action
|
||||
if (guiControl.inventory.activateDelay <= 0) {
|
||||
if (ct_confirm().down) {
|
||||
switch (guiControl.inventory.cursorPosition) {
|
||||
case 0: {
|
||||
snd_select.Play();
|
||||
guiControl.inventory.screen = "money";
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
snd_select.Play();
|
||||
guiControl.inventory.screen = "cargo";
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
snd_select.Play();
|
||||
guiControl.inventory.screen = "status";
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
snd_cursorup.Play();
|
||||
guiControl.inventory.show = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
guiControl.inventory.cursorPosition = 0;
|
||||
guiControl.inventory.activateDelay = 5;
|
||||
}
|
||||
if (ct_cancel().down) {
|
||||
snd_cursorup.Play();
|
||||
guiControl.inventory.show = false;
|
||||
}
|
||||
if (ct_left().down) {
|
||||
snd_cursordown.Play();
|
||||
guiControl.inventory.show = false;
|
||||
guiControl.map.activateDelay = 5;
|
||||
guiControl.map.show = true;
|
||||
}
|
||||
if (ct_right().down) {
|
||||
snd_cursordown.Play();
|
||||
guiControl.inventory.show = false;
|
||||
guiControl.map.activateDelay = 5;
|
||||
guiControl.map.show = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (guiControl.inventory.screen == "money") {
|
||||
// Limit Cursor
|
||||
if (guiControl.inventory.cursorPosition < 0) {
|
||||
guiControl.inventory.cursorPosition = 0;
|
||||
}
|
||||
if (guiControl.inventory.cursorPosition > 0) {
|
||||
guiControl.inventory.cursorPosition = 0;
|
||||
}
|
||||
|
||||
// Title
|
||||
guiControl.drawPixelText("Money", guiControl.leftBorder + pixel(3), guiControl.topOfBackground, 8, "black", 6);
|
||||
|
||||
guiControl.drawPixelText("Actual Amt", guiControl.leftBorder - pixel(5), guiControl.rowTop(0) + pixel(), 10, "black", 4);
|
||||
// Money icon
|
||||
guiControl.drawIcon(7, 2, guiControl.leftBorder - pixel(5), guiControl.rowTop(1) - pixel(3));
|
||||
guiControl.drawPixelText(G.inventory.money.toString(), guiControl.leftBorder - pixel(5) + pixel(guiControl.iconSize + 2), guiControl.rowTop(1) + pixel(2) - pixel(3), 10, "black", 4);
|
||||
|
||||
// Back Text
|
||||
guiControl.drawPixelText("Back", guiControl.leftBorder, guiControl.rowTop(4) - pixel(3), 8, "black", 6);
|
||||
|
||||
// Draw cursor
|
||||
guiControl.drawCursor(guiControl.leftBorder - (guiControl.iconScaled), guiControl.rowTop(4) - pixel(4));
|
||||
|
||||
// Button Action
|
||||
if (guiControl.inventory.activateDelay <= 0) {
|
||||
if (ct_confirm().down || ct_cancel().down) {
|
||||
snd_cursorup.Play();
|
||||
guiControl.inventory.screen = "main";
|
||||
guiControl.inventory.activateDelay = 5;
|
||||
guiControl.inventory.cursorPosition = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (guiControl.inventory.screen == "cargo") {
|
||||
// Limit Cursor
|
||||
if (guiControl.inventory.cursorPosition < 0) {
|
||||
guiControl.inventory.cursorPosition = 0;
|
||||
}
|
||||
if (guiControl.inventory.cursorPosition > 0) {
|
||||
guiControl.inventory.cursorPosition = 0;
|
||||
}
|
||||
|
||||
// Title
|
||||
guiControl.drawPixelText("Cargo", guiControl.leftBorder + pixel(3), guiControl.topOfBackground, 8, "black", 6);
|
||||
|
||||
// Cargo icons
|
||||
var cargo = G.inventory.CheckCargo(); // Contains the item ids that have more than 1 item
|
||||
for (var i = 0; i < cargo.length; i++) {
|
||||
guiControl.drawItem(cargo[i], guiControl.leftBorder, guiControl.rowTop(i));
|
||||
guiControl.drawPixelText(G.inventory.cargo[cargo[i]], guiControl.leftBorder + pixel(guiControl.iconSize + 4), guiControl.rowTop(i) + pixel(), 8, "black", 6);
|
||||
}
|
||||
|
||||
// Back Text
|
||||
guiControl.drawPixelText("Back", guiControl.leftBorder, guiControl.rowTop(4) - pixel(3), 8, "black", 6);
|
||||
|
||||
// Draw cursor
|
||||
guiControl.drawCursor(guiControl.leftBorder - (guiControl.iconScaled), guiControl.rowTop(4) - pixel(4));
|
||||
|
||||
// Button Action
|
||||
if (guiControl.inventory.activateDelay <= 0) {
|
||||
if (ct_confirm().down || ct_cancel().down) {
|
||||
snd_cursorup.Play();
|
||||
guiControl.inventory.screen = "main";
|
||||
guiControl.inventory.activateDelay = 5;
|
||||
guiControl.inventory.cursorPosition = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (guiControl.inventory.screen == "status") {
|
||||
// Limit Cursor
|
||||
if (guiControl.inventory.cursorPosition < 0) {
|
||||
guiControl.inventory.cursorPosition = 0;
|
||||
}
|
||||
if (guiControl.inventory.cursorPosition > 0) {
|
||||
guiControl.inventory.cursorPosition = 0;
|
||||
}
|
||||
|
||||
// guiControl.drawPageArrow("left", pixel(4), guiControl.topOfBackground);
|
||||
// guiControl.drawPageArrow("right", OS.camera.width - pixel(4) - pixel(4), guiControl.topOfBackground);
|
||||
|
||||
// Title
|
||||
guiControl.drawPixelText("Status", guiControl.leftBorder + pixel(), guiControl.topOfBackground, 8, "black", 6);
|
||||
|
||||
// Illness icon
|
||||
guiControl.drawIcon(4, 1, guiControl.leftBorder - pixel(6), guiControl.rowTop(0));
|
||||
guiControl.drawPixelText(G.stats.illness.toString(), guiControl.leftBorder - pixel(6) + (guiControl.iconScaled + pixel(2)), guiControl.rowTop(0) + pixel(2), 2, "black", 4);
|
||||
|
||||
guiControl.drawPixelText("This will show more data when stati can change.", guiControl.leftBorder - pixel(5), guiControl.rowTop(1), 10, "black", 4);
|
||||
/*// Energy icon
|
||||
guiControl.drawIcon(9, 2, guiControl.leftBorder - pixel(5), guiControl.rowTop(0) - pixel(3));
|
||||
guiControl.drawPixelText(G.stats.energy.toString(), guiControl.leftBorder - pixel(5) + pixel(guiControl.iconSize + 2), guiControl.rowTop(1) + pixel(2) - pixel(3), 2, "black", 4);
|
||||
// Illness icon
|
||||
guiControl.drawIcon(4, 1, guiControl.leftBorder - pixel(5) + pixel(24), guiControl.rowTop(1) - pixel(3));
|
||||
guiControl.drawPixelText(G.stats.illness.toString(), guiControl.leftBorder - pixel(5) + pixel(24) + pixel(guiControl.iconSize + 2), guiControl.rowTop(1) + pixel(2) - pixel(3), 2, "black", 4);
|
||||
|
||||
// Yes/No options
|
||||
guiControl.drawPixelText("No", guiControl.leftBorder, guiControl.rowTop(2) - pixel(3), 3, "black", 6);
|
||||
guiControl.drawPixelText("Yes", guiControl.leftBorder, guiControl.rowTop(3) - pixel(3), 3, (G.inventory.supplies > 0 && G.stats.illness > 0) ? "black" : "white", 6);
|
||||
*/
|
||||
// Back Text
|
||||
guiControl.drawPixelText("Back", guiControl.leftBorder, guiControl.rowTop(4) - pixel(3), 8, "black", 6);
|
||||
|
||||
// Draw cursor
|
||||
guiControl.drawCursor(guiControl.leftBorder - (guiControl.iconScaled), guiControl.rowTop(4) - pixel(3));
|
||||
|
||||
// Button Action
|
||||
if (guiControl.inventory.activateDelay <= 0) {
|
||||
if (ct_confirm().down || ct_cancel().down) {
|
||||
snd_cursorup.Play();
|
||||
guiControl.inventory.screen = "main";
|
||||
guiControl.inventory.activateDelay = 5;
|
||||
guiControl.inventory.cursorPosition = 2; // The position where "Supplies" is on main screen.
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
111
gui/mapGUI.js
|
|
@ -1,57 +1,62 @@
|
|||
function mapGUI() {
|
||||
guiControl.map = {
|
||||
show: false,
|
||||
activateDelay: 0
|
||||
}
|
||||
if (Oversimplified.DEBUG.showMessages) console.log("Ran mapGUI()");
|
||||
}
|
||||
|
||||
function drawMapGUI() {
|
||||
if (guiControl.map && guiControl.map.show) {
|
||||
guiControl.map.activateDelay -= (guiControl.map.activateDelay > 0) ? 1 : 0;
|
||||
|
||||
OS.context.drawImage(guiControl.background, 0, 0, 240, 240, pixel(2), pixel(2), 240, 240);
|
||||
|
||||
// Title
|
||||
guiControl.drawPixelText("Map", guiControl.leftBorder + pixel(10), guiControl.topOfBackground, 8, "black", 6);
|
||||
|
||||
guiControl.drawPageArrow("left", pixel(4), guiControl.topOfBackground);
|
||||
guiControl.drawPageArrow("right", OS.camera.width - pixel(4) - pixel(4), guiControl.topOfBackground);
|
||||
|
||||
var saveFillStyle = OS.context.fillStyle;
|
||||
|
||||
var mapLeft = guiControl.leftBorder - pixel(5);
|
||||
var mapTop = guiControl.upperBorder;
|
||||
|
||||
OS.context.fillStyle = "#0000CC";
|
||||
OS.context.fillRect(mapLeft, mapTop, pixel(50), pixel(45));
|
||||
|
||||
OS.context.fillStyle = "#00FF00";
|
||||
for (var m = 0; m < G.map.length; m++) {
|
||||
var pixelLeft = mapLeft + pixel(G.map[m].drawX);
|
||||
var pixelTop = mapTop + pixel(G.map[m].drawY);
|
||||
OS.context.fillRect(pixelLeft, pixelTop, pixel(), pixel());
|
||||
}
|
||||
|
||||
OS.context.fillStyle = "#FF0000";
|
||||
OS.context.fillRect(mapLeft + G.player.mapX, mapTop + G.player.mapY, pixel(), pixel());
|
||||
|
||||
OS.context.fillStyle = saveFillStyle;
|
||||
|
||||
// Button Action
|
||||
if (guiControl.map.activateDelay <= 0) {
|
||||
if (ct_cancel().down) {
|
||||
guiControl.map.show = false;
|
||||
}
|
||||
if (ct_left().down) {
|
||||
guiControl.map.show = false;
|
||||
guiControl.inventory.activateDelay = 5;
|
||||
guiControl.inventory.show = true;
|
||||
}
|
||||
if (ct_right().down) {
|
||||
guiControl.map.show = false;
|
||||
guiControl.inventory.activateDelay = 5;
|
||||
guiControl.inventory.show = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
guiControl.map = {
|
||||
show: false,
|
||||
activateDelay: 0,
|
||||
}
|
||||
|
||||
guiControl.map.Draw = function () {
|
||||
if (guiControl.map && guiControl.map.show) {
|
||||
guiControl.map.activateDelay -= (guiControl.map.activateDelay > 0) ? 1 : 0;
|
||||
|
||||
guiControl.drawGUIBackground();
|
||||
|
||||
// Title
|
||||
guiControl.drawPixelText("Map", guiControl.leftBorder + pixel(10), guiControl.topOfBackground, 8, "black", 6);
|
||||
|
||||
guiControl.drawPageArrow("left", pixel(4), guiControl.topOfBackground);
|
||||
guiControl.drawPageArrow("right", pixel(4) + guiControl.gui_sheet.guiBackground.width - pixel(4) - pixel(4), guiControl.topOfBackground);
|
||||
|
||||
var saveFillStyle = OS.context.fillStyle;
|
||||
|
||||
var mapLeft = guiControl.leftBorder - pixel(5);
|
||||
var mapTop = guiControl.upperBorder;
|
||||
|
||||
OS.context.fillStyle = "#0000CC";
|
||||
OS.context.fillRect(mapLeft, mapTop, pixel(50), pixel(45));
|
||||
|
||||
OS.context.fillStyle = "#00FF00";
|
||||
for (var m = 0; m < G.map.length; m++) {
|
||||
var pixelLeft = mapLeft + pixel(G.map[m].drawX);
|
||||
var pixelTop = mapTop + pixel(G.map[m].drawY);
|
||||
OS.context.fillRect(pixelLeft, pixelTop, pixel(), pixel());
|
||||
}
|
||||
|
||||
OS.context.fillStyle = "#FF0000";
|
||||
OS.context.fillRect(mapLeft + G.player.mapX, mapTop + G.player.mapY, pixel(), pixel());
|
||||
|
||||
OS.context.fillStyle = saveFillStyle;
|
||||
|
||||
// Button Action
|
||||
if (guiControl.map.activateDelay <= 0) {
|
||||
if (ct_confirm().down || ct_cancel().down || ct_m.down) {
|
||||
snd_cursorup.Play();
|
||||
guiControl.map.show = false;
|
||||
}
|
||||
if (ct_left().down) {
|
||||
snd_cursordown.Play();
|
||||
guiControl.map.show = false;
|
||||
guiControl.inventory.activateDelay = 5;
|
||||
guiControl.inventory.show = true;
|
||||
}
|
||||
if (ct_right().down) {
|
||||
snd_cursordown.Play();
|
||||
guiControl.map.show = false;
|
||||
guiControl.inventory.activateDelay = 5;
|
||||
guiControl.inventory.show = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
116
gui/titleScreen.js
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
function titleScreen () {
|
||||
if (Oversimplified.DEBUG.showMessages) console.log("Ran titleScreen()");
|
||||
}
|
||||
|
||||
guiControl.title = {
|
||||
screen: "main",
|
||||
show: true,
|
||||
cursorPosition: 0,
|
||||
activateDelay: 0,
|
||||
|
||||
padding: pixel(2),
|
||||
leftBorder: pixel(12),
|
||||
|
||||
rowTop: function (rowNumber) {
|
||||
return pixel(32) + pixel(2) + pixel((guiControl.iconSize + 2) * rowNumber);
|
||||
},
|
||||
}
|
||||
|
||||
guiControl.title.Draw = function () {
|
||||
if (guiControl.title && guiControl.title.show) {
|
||||
guiControl.title.activateDelay -= (guiControl.title.activateDelay > 0) ? 1 : 0;
|
||||
|
||||
if (guiControl.title.screen == "main") {
|
||||
if (ct_down().down) {
|
||||
snd_cursordown.Play();
|
||||
guiControl.title.cursorPosition++;
|
||||
}
|
||||
if (ct_up().down) {
|
||||
snd_cursordown.Play();
|
||||
guiControl.title.cursorPosition--;
|
||||
}
|
||||
|
||||
// console.log(guiControl.title.screen);
|
||||
// Limit Cursor
|
||||
if (guiControl.title.cursorPosition < 0) {
|
||||
guiControl.title.cursorPosition = 2;
|
||||
}
|
||||
if (guiControl.title.cursorPosition > 2) {
|
||||
guiControl.title.cursorPosition = 0;
|
||||
}
|
||||
|
||||
// Title
|
||||
guiControl.drawTitleImage();
|
||||
|
||||
// New Game
|
||||
guiControl.drawPixelText("New Game", guiControl.title.leftBorder, guiControl.title.rowTop(0), 10, "white", 6);
|
||||
// Load Game
|
||||
guiControl.drawPixelText("Continue", guiControl.title.leftBorder, guiControl.title.rowTop(1), 10, (G.savedGameExists) ? "white" : "black", 6);
|
||||
// Options
|
||||
guiControl.drawPixelText("Options", guiControl.title.leftBorder, guiControl.title.rowTop(2) + pixel(), 8, (guiControl.optionsScreen) ? "white" : "black", 6);
|
||||
|
||||
// Draw cursor
|
||||
guiControl.drawCursor(guiControl.title.leftBorder - (guiControl.iconScaled), guiControl.title.rowTop(guiControl.title.cursorPosition));
|
||||
|
||||
// Button Action
|
||||
if (guiControl.title.activateDelay <= 0) {
|
||||
if (ct_confirm().down) {
|
||||
switch (guiControl.title.cursorPosition) {
|
||||
case 0: {
|
||||
snd_select.Play();
|
||||
mus_title.Stop();
|
||||
mus_sail.Play();
|
||||
guiControl.title.show = false;
|
||||
G.gameStarted = true;
|
||||
G.SaveGame();
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
if (G.savedGameExists) { // once loading is in, allow this.
|
||||
G.LoadGame();
|
||||
snd_select.Play();
|
||||
mus_title.Stop();
|
||||
mus_sail.Play();
|
||||
guiControl.title.show = false;
|
||||
G.gameStarted = true;
|
||||
} else {
|
||||
snd_cannotbuy.Play();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
if (false) { // once loading is in, allow this.
|
||||
snd_select.Play();
|
||||
guiControl.title.show = false;
|
||||
guiControl.options.show = true;
|
||||
break;
|
||||
} else {
|
||||
snd_cannotbuy.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
guiControl.title.cursorPosition = 0;
|
||||
// console.log(guiControl.title.screen);
|
||||
}
|
||||
|
||||
if (ct_cancel().down) {
|
||||
guiControl.title.screen = "credits";
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (guiControl.title.screen == "credits") {
|
||||
guiControl.drawPixelText("Credits", guiControl.title.leftBorder - pixel(), pixel(2), 0, "white", 6);
|
||||
guiControl.drawPixelText("Music, Icons", pixel(), pixel(11), 0, "white", 4);
|
||||
guiControl.drawPixelText("Paws Menu", pixel(2), pixel(17), 0, "yellow", 6);
|
||||
guiControl.drawPixelText("paws.bandcamp.com", pixel(2), pixel(25), 0, "yellow", 4);
|
||||
guiControl.drawPixelText("Evrthng Else", pixel(), pixel(39), 0, "white", 4);
|
||||
guiControl.drawPixelText("Alamantus", pixel(2), pixel(45), 0, "yellow", 6);
|
||||
guiControl.drawPixelText("alamantus.com", pixel(2), pixel(53), 0, "yellow", 4);
|
||||
|
||||
if (ct_confirm().down || ct_cancel().down || ct_esc.down) {
|
||||
guiControl.title.screen = "main";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
808
gui/tradeGUI.js
|
|
@ -1,361 +1,461 @@
|
|||
function tradeGUI() {
|
||||
guiControl.trade = {
|
||||
screen: "main", // "main", "buy", "sell", "gossip"
|
||||
cursorPosition: 0,
|
||||
page: 0, // horizontal page on item lists. Base 1 to match number of pages var "pages" within the gui.
|
||||
itemsPerPage: 3,
|
||||
show: false,
|
||||
activateDelay: 0,
|
||||
|
||||
island: null,
|
||||
|
||||
padding: pixel(2),
|
||||
leftBorder: pixel(12),
|
||||
|
||||
rowTop: function (rowNumber) {
|
||||
return (guiControl.trade.padding + pixel(6) + (guiControl.trade.padding * 3)) + pixel((guiControl.iconSize + 3) * rowNumber);
|
||||
}
|
||||
}
|
||||
if (Oversimplified.DEBUG.showMessages) console.log("Ran tradeGUI()");
|
||||
}
|
||||
|
||||
function drawTradeGUI() {
|
||||
if (guiControl.trade && guiControl.trade.show) {
|
||||
guiControl.trade.activateDelay -= (guiControl.trade.activateDelay > 0) ? 1 : 0;
|
||||
// console.log("trade screen island: " + guiControl.trade.island.name);
|
||||
// Draw background color.
|
||||
var tmp = Oversimplified.context.fillStyle;
|
||||
Oversimplified.context.fillStyle = "#D9BEA5";
|
||||
Oversimplified.context.fillRect(0, 0, Oversimplified.camera.width, Oversimplified.camera.height);
|
||||
Oversimplified.context.fillStyle = tmp;
|
||||
guiControl.trade = {
|
||||
screen: "main", // "main", "buy", "sell", "gossip"
|
||||
cursorPosition: 0,
|
||||
page: 0, // horizontal page on item lists. Base 1 to match number of pages var "pages" within the gui.
|
||||
itemsPerPage: 3,
|
||||
show: false,
|
||||
activateDelay: 0,
|
||||
|
||||
if (ct_down().down) {
|
||||
// Play Move_Cursor sound.
|
||||
guiControl.trade.cursorPosition++;
|
||||
}
|
||||
if (ct_up().down) {
|
||||
// Play Move_Cursor_Up sound.
|
||||
guiControl.trade.cursorPosition--;
|
||||
}
|
||||
if (ct_right().down) {
|
||||
// Play Move_Cursor sound.
|
||||
guiControl.trade.page++;
|
||||
}
|
||||
if (ct_left().down) {
|
||||
// Play Move_Cursor_Up sound.
|
||||
guiControl.trade.page--;
|
||||
}
|
||||
|
||||
if (guiControl.trade.screen == "main") {
|
||||
// console.log(guiControl.trade.screen);
|
||||
// Limit Cursor
|
||||
if (guiControl.trade.cursorPosition < 0) {
|
||||
guiControl.trade.cursorPosition = 3;
|
||||
}
|
||||
if (guiControl.trade.cursorPosition > 3) {
|
||||
guiControl.trade.cursorPosition = 0;
|
||||
}
|
||||
// Limit page
|
||||
if (guiControl.trade.page < 0) {
|
||||
guiControl.trade.page = 0;
|
||||
}
|
||||
if (guiControl.trade.page > 0) {
|
||||
guiControl.trade.page = 0;
|
||||
}
|
||||
island: null,
|
||||
|
||||
// Title
|
||||
guiControl.drawPixelText("On Island", (guiControl.trade.padding * 2), guiControl.trade.padding, 10, "black", 6);
|
||||
// Money icon
|
||||
// guiControl.drawIcon(7, 2, guiControl.trade.leftBorder, guiControl.trade.rowTop(0));
|
||||
guiControl.drawPixelText((guiControl.trade.island.CheckInventory().length > 0) ? "Buy" : "Sold Out!", guiControl.trade.leftBorder, guiControl.trade.rowTop(0) + pixel(), 10, (guiControl.trade.island.CheckInventory().length > 0) ? "black" : "white", 6);
|
||||
// Supplies icon
|
||||
// guiControl.drawIcon(9, 2, guiControl.trade.leftBorder, guiControl.trade.rowTop(1));
|
||||
guiControl.drawPixelText((G.inventory.CheckCargo().length > 0) ? "Sell" : "No Cargo!", guiControl.trade.leftBorder, guiControl.trade.rowTop(1) + pixel(), 10, (G.inventory.CheckCargo().length > 0) ? "black" : "white", 6);
|
||||
// Cargo icon
|
||||
// guiControl.drawIcon(1, 0, guiControl.trade.leftBorder, guiControl.trade.rowTop(2));
|
||||
guiControl.drawPixelText("Gossip", guiControl.trade.leftBorder, guiControl.trade.rowTop(2) + pixel(), 8, "black", 6);
|
||||
|
||||
// Close Text
|
||||
guiControl.drawPixelText("Leave", guiControl.trade.leftBorder, guiControl.trade.rowTop(3) + pixel(), 8, "black", 6);
|
||||
|
||||
// Draw cursor
|
||||
OS.context.drawImage(guiControl.cursor, guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(guiControl.trade.cursorPosition));
|
||||
padding: pixel(2),
|
||||
leftBorder: pixel(12),
|
||||
|
||||
// Button Action
|
||||
if (guiControl.trade.activateDelay <= 0) {
|
||||
if (ct_confirm().down) {
|
||||
switch (guiControl.trade.cursorPosition) {
|
||||
case 0:
|
||||
if (guiControl.trade.island.CheckInventory().length > 0) {
|
||||
guiControl.trade.screen = "buy";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
}
|
||||
else {
|
||||
// Play Cannot_Buy sound.
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
if (G.inventory.CheckCargo().length > 0) {
|
||||
guiControl.trade.screen = "sell";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
} else {
|
||||
// Play Cannot_Buy sound.
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
guiControl.trade.screen = "gossip";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
break;
|
||||
default:
|
||||
// Change music to Sail.
|
||||
guiControl.trade.show = false;
|
||||
break;
|
||||
}
|
||||
|
||||
// Play Select sound.
|
||||
guiControl.trade.cursorPosition = 0;
|
||||
guiControl.trade.page = 0;
|
||||
// console.log(guiControl.trade.screen);
|
||||
}
|
||||
if (ct_cancel().down) {
|
||||
guiControl.trade.show = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (guiControl.trade.screen == "buy") {
|
||||
// console.log(guiControl.trade.screen);
|
||||
// Limit Cursor
|
||||
if (guiControl.trade.cursorPosition < 0) {
|
||||
guiControl.trade.cursorPosition = 2;
|
||||
}
|
||||
if (guiControl.trade.cursorPosition > 2) {
|
||||
guiControl.trade.cursorPosition = 0;
|
||||
}
|
||||
|
||||
// Title
|
||||
guiControl.drawPixelText("Buy", guiControl.trade.leftBorder - pixel(2), guiControl.topOfBackground, 10, "black", 6);
|
||||
|
||||
// Money icon
|
||||
guiControl.drawIcon(7, 2, guiControl.trade.padding, guiControl.trade.rowTop(0) - pixel(3));
|
||||
guiControl.drawPixelText(G.inventory.moneyDisplay(), guiControl.trade.padding + pixel(guiControl.iconSize + 2), guiControl.trade.rowTop(0) + pixel(2) - pixel(3), 10, "black", 4);
|
||||
|
||||
// Cargo icons
|
||||
var items = guiControl.trade.island.CheckInventory(); // Contains the item ids that have more than 1 item
|
||||
|
||||
// Limit page
|
||||
if (guiControl.trade.page < 0) {
|
||||
guiControl.trade.page = items.length - 1;
|
||||
}
|
||||
if (guiControl.trade.page > items.length - 1) {
|
||||
guiControl.trade.page = 0;
|
||||
}
|
||||
|
||||
if (items.length > 0) {
|
||||
var itemPrice = G.economy.cargoItemWorth[items[guiControl.trade.page]] + guiControl.trade.island.priceDifferences[items[guiControl.trade.page]] - guiControl.trade.island.haggleAmount;
|
||||
if (itemPrice < 1) itemPrice = 1;
|
||||
var itemPriceDisplay = itemPrice.toString() + " c";
|
||||
guiControl.drawItem(items[guiControl.trade.page], guiControl.trade.leftBorder, guiControl.trade.rowTop(1) - pixel(5));
|
||||
guiControl.drawPixelText(itemPriceDisplay, guiControl.trade.leftBorder + pixel(guiControl.iconSize + 4), guiControl.trade.rowTop(1) - pixel(5) + pixel(), 8, "black", 6);
|
||||
|
||||
if (items.length > 1) {
|
||||
guiControl.drawPageArrow("left", guiControl.trade.padding, guiControl.trade.rowTop(1) - pixel(5));
|
||||
guiControl.drawPageArrow("right", OS.camera.width - pixel(4) - guiControl.trade.padding, guiControl.trade.rowTop(1) - pixel(5));
|
||||
}
|
||||
|
||||
// Amounts
|
||||
guiControl.drawPixelText("Shop" + guiControl.trade.island.inventory[items[guiControl.trade.page]].toString(), OS.camera.width - pixel(20), guiControl.trade.rowTop(2) - pixel(6) + pixel(), 4, "black", 4);
|
||||
guiControl.drawPixelText("Own " + G.inventory.cargo[items[guiControl.trade.page]].toString(), OS.camera.width - pixel(20), guiControl.trade.rowTop(3) - pixel(6) + pixel(), 4, (G.inventory.cargo[items[guiControl.trade.page]] < G.stats.hold) ? "black" : "yellow", 4);
|
||||
} else {
|
||||
guiControl.drawPixelText("Sold Out!", guiControl.trade.leftBorder, guiControl.trade.rowTop(1) - pixel(5) + pixel(), 10, "black", 6);
|
||||
}
|
||||
|
||||
// Draw Amount of Cargo
|
||||
guiControl.drawIcon(1, 1, OS.camera.width - pixel(20), guiControl.trade.rowTop(4) - pixel(5));
|
||||
guiControl.drawPixelText(G.inventory.CheckCargo().length.toString(), OS.camera.width - pixel(20) + (guiControl.iconScaled + pixel()), guiControl.trade.rowTop(4) - pixel(4), 4, (G.inventory.CheckCargo().length < G.stats.inventory) ? "black" : "yellow", 6);
|
||||
|
||||
// Yes/No Options
|
||||
guiControl.drawPixelText("Hagl?", guiControl.trade.leftBorder, guiControl.trade.rowTop(2) - pixel(2), 8, (guiControl.trade.island.timesHaggledToday >= G.stats.popularity) ? "yellow" : ((items.length > 0 && guiControl.trade.island.haggleAmount == 0) ? "black" : "white"), 6);
|
||||
guiControl.drawPixelText("Yes", guiControl.trade.leftBorder, guiControl.trade.rowTop(3) - pixel(2), 8, (items.length > 0 && G.inventory.CanBuy(items[guiControl.trade.page], itemPrice)) ? "black" : "white", 6);
|
||||
|
||||
// Back Text
|
||||
guiControl.drawPixelText("Back", guiControl.trade.leftBorder, guiControl.trade.rowTop(4) - pixel(2), 8, "black", 6);
|
||||
|
||||
// Draw cursor
|
||||
OS.context.drawImage(guiControl.cursor, guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(guiControl.trade.cursorPosition + 2) - pixel(3));
|
||||
|
||||
// Button Action
|
||||
if (guiControl.trade.activateDelay <= 0) {
|
||||
if (ct_confirm().down) {
|
||||
switch (guiControl.trade.cursorPosition) {
|
||||
case 0: // Haggle
|
||||
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 = G.stats.haggling;
|
||||
// Play Sell sound.
|
||||
} else {
|
||||
// Play Cannot_Buy sound.
|
||||
guiControl.trade.island.timesHaggledToday++;
|
||||
}
|
||||
break;
|
||||
case 1: // Buy
|
||||
if (items.length > 0 &&
|
||||
G.inventory.CanBuy(items[guiControl.trade.page], itemPrice)) { //If cursor is over yes and you can buy, buy it.
|
||||
guiControl.trade.island.BuyFrom(items[guiControl.trade.page], itemPrice);
|
||||
} else {
|
||||
// Play Cannot_Buy sound.
|
||||
}
|
||||
break;
|
||||
default:
|
||||
guiControl.trade.screen = "main";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
guiControl.trade.cursorPosition = 0; // The position where "Buy" is on main screen.
|
||||
break;
|
||||
}
|
||||
// Play Select sound.
|
||||
// console.log(guiControl.trade.screen);
|
||||
}
|
||||
if (ct_cancel().down) {
|
||||
guiControl.trade.screen = "main";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
guiControl.trade.cursorPosition = 0; // The position where "Buy" is on main screen.
|
||||
// console.log(guiControl.trade.screen);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (guiControl.trade.screen == "sell") {
|
||||
// console.log(guiControl.trade.screen);
|
||||
// Limit Cursor
|
||||
if (guiControl.trade.cursorPosition < 0) {
|
||||
guiControl.trade.cursorPosition = 2;
|
||||
}
|
||||
if (guiControl.trade.cursorPosition > 2) {
|
||||
guiControl.trade.cursorPosition = 0;
|
||||
}
|
||||
|
||||
// Title
|
||||
guiControl.drawPixelText("Sell", guiControl.trade.leftBorder - pixel(2), guiControl.topOfBackground, 10, "black", 6);
|
||||
|
||||
// Money icon
|
||||
guiControl.drawIcon(7, 2, guiControl.trade.padding, guiControl.trade.rowTop(0) - pixel(3));
|
||||
guiControl.drawPixelText(G.inventory.moneyDisplay(), guiControl.trade.padding + pixel(guiControl.iconSize + 2), guiControl.trade.rowTop(0) + pixel(2) - pixel(3), 10, "black", 4);
|
||||
|
||||
// Cargo icons
|
||||
var items = G.inventory.CheckCargo(); // Contains the item ids that have more than 1 item
|
||||
|
||||
// Limit page
|
||||
if (guiControl.trade.page < 0) {
|
||||
guiControl.trade.page = items.length - 1;
|
||||
}
|
||||
if (guiControl.trade.page > items.length - 1) {
|
||||
guiControl.trade.page = 0;
|
||||
}
|
||||
|
||||
if (items.length > 0) {
|
||||
var itemPrice = G.economy.cargoItemWorth[items[guiControl.trade.page]] + guiControl.trade.island.priceDifferences[items[guiControl.trade.page]];
|
||||
var priceCut = 0.5 + ((guiControl.trade.island.haggleAmount == 0) ? 0 : (G.stats.popularity * 0.01 * 0.5)); // If haggled successfully, lessen the price cut by half of your popularity's percent worth.
|
||||
itemPrice = Math.round(itemPrice * priceCut);
|
||||
if (itemPrice < 1) itemPrice = 1;
|
||||
var itemPriceDisplay = itemPrice.toString() + " c";
|
||||
guiControl.drawItem(items[guiControl.trade.page], guiControl.trade.leftBorder, guiControl.trade.rowTop(1) - pixel(5));
|
||||
guiControl.drawPixelText(itemPriceDisplay, guiControl.trade.leftBorder + pixel(guiControl.iconSize + 4), guiControl.trade.rowTop(1) - pixel(5) + pixel(), 8, "black", 6);
|
||||
|
||||
if (items.length > 1) {
|
||||
guiControl.drawPageArrow("left", guiControl.trade.padding, guiControl.trade.rowTop(1) - pixel(5));
|
||||
guiControl.drawPageArrow("right", OS.camera.width - pixel(4) - guiControl.trade.padding, guiControl.trade.rowTop(1) - pixel(5));
|
||||
}
|
||||
|
||||
// Amounts
|
||||
guiControl.drawPixelText("Shop" + guiControl.trade.island.inventory[items[guiControl.trade.page]].toString(), OS.camera.width - pixel(20), guiControl.trade.rowTop(2) - pixel(6) + pixel(), 4, "black", 4);
|
||||
guiControl.drawPixelText("Own " + G.inventory.cargo[items[guiControl.trade.page]].toString(), OS.camera.width - pixel(20), guiControl.trade.rowTop(3) - pixel(6) + pixel(), 4, (G.inventory.cargo[items[guiControl.trade.page]] > 0) ? "black" : "yellow", 4);
|
||||
} else {
|
||||
guiControl.drawPixelText("No Cargo!", guiControl.trade.padding, guiControl.trade.rowTop(1) - pixel(5) + pixel(), 10, "black", 6);
|
||||
}
|
||||
|
||||
// Draw Amount of Cargo
|
||||
guiControl.drawIcon(1, 1, OS.camera.width - pixel(20), guiControl.trade.rowTop(4) - pixel(5));
|
||||
guiControl.drawPixelText(G.inventory.CheckCargo().length.toString(), OS.camera.width - pixel(20) + (guiControl.iconScaled + pixel()), guiControl.trade.rowTop(4) - pixel(4), 4, (G.inventory.CheckCargo().length > 0) ? "black" : "yellow", 6);
|
||||
|
||||
// Yes/No Options
|
||||
guiControl.drawPixelText("Hagl?", guiControl.trade.leftBorder, guiControl.trade.rowTop(2) - pixel(2), 8, (guiControl.trade.island.timesHaggledToday >= G.stats.popularity) ? "yellow" : ((items.length > 0 && guiControl.trade.island.haggleAmount == 0) ? "black" : "white"), 6);
|
||||
guiControl.drawPixelText("Yes", guiControl.trade.leftBorder, guiControl.trade.rowTop(3) - pixel(2), 8, (items.length > 0 && G.inventory.CanSell(items[guiControl.trade.page])) ? "black" : "white", 6);
|
||||
|
||||
// Back Text
|
||||
guiControl.drawPixelText("Back", guiControl.trade.leftBorder, guiControl.trade.rowTop(4) - pixel(2), 8, "black", 6);
|
||||
|
||||
// Draw cursor
|
||||
OS.context.drawImage(guiControl.cursor, guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(guiControl.trade.cursorPosition + 2) - pixel(3));
|
||||
|
||||
// Button Action
|
||||
if (guiControl.trade.activateDelay <= 0) {
|
||||
if (ct_confirm().down) {
|
||||
switch (guiControl.trade.cursorPosition) {
|
||||
case 0: // Haggle
|
||||
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.
|
||||
{
|
||||
// Play Sell sound.
|
||||
guiControl.trade.island.haggleAmount = G.stats.haggling;
|
||||
} else {
|
||||
// Play Cannot_Buy sound.
|
||||
guiControl.trade.island.timesHaggledToday++;
|
||||
}
|
||||
break;
|
||||
case 1: // Sell
|
||||
if (items.length > 0 &&
|
||||
G.inventory.CanSell(items[guiControl.trade.page])) //If cursor is over yes and you can buy, buy it.
|
||||
{
|
||||
guiControl.trade.island.SellTo(items[guiControl.trade.page], itemPrice);
|
||||
} else {
|
||||
// Play Cannot_Buy sound.
|
||||
}
|
||||
break;
|
||||
default:
|
||||
guiControl.trade.screen = "main";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
guiControl.trade.cursorPosition = 1; // The position where "Sell" is on main screen.
|
||||
break;
|
||||
}
|
||||
// Play Select sound.
|
||||
// console.log(guiControl.trade.screen);
|
||||
}
|
||||
if (ct_cancel().down) {
|
||||
guiControl.trade.screen = "main";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
guiControl.trade.cursorPosition = 1; // The position where "Sell" is on main screen.
|
||||
// console.log(guiControl.trade.screen);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (guiControl.trade.screen == "gossip") {
|
||||
// console.log(guiControl.trade.screen);
|
||||
// Limit Cursor
|
||||
if (guiControl.trade.cursorPosition < 0) {
|
||||
guiControl.trade.cursorPosition = 0;
|
||||
}
|
||||
if (guiControl.trade.cursorPosition > 0) {
|
||||
guiControl.trade.cursorPosition = 0;
|
||||
}
|
||||
|
||||
// Title
|
||||
guiControl.drawPixelText("Gossip", guiControl.trade.padding, guiControl.topOfBackground, 10, "black", 6);
|
||||
|
||||
guiControl.drawPixelText("Nothing interesting to report! / / / / / -Actually, this isnt in the game yet-", guiControl.trade.padding, guiControl.trade.rowTop(0) - pixel(2), 0, "black", 4);
|
||||
|
||||
// Back Text
|
||||
guiControl.drawPixelText("Back", guiControl.trade.leftBorder, guiControl.trade.rowTop(4) - pixel(2), 8, "black", 6);
|
||||
|
||||
// Draw cursor
|
||||
OS.context.drawImage(guiControl.cursor, guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(4) - pixel(3));
|
||||
|
||||
// Button Action
|
||||
if (guiControl.trade.activateDelay <= 0) {
|
||||
if (ct_confirm().down || ct_cancel().down) {
|
||||
// Play Select sound.
|
||||
guiControl.trade.screen = "main";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
guiControl.trade.cursorPosition = 2;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
rowTop: function (rowNumber) {
|
||||
return (guiControl.trade.padding + pixel(6) + (guiControl.trade.padding * 3)) + pixel((guiControl.iconSize + 3) * rowNumber);
|
||||
},
|
||||
}
|
||||
|
||||
guiControl.trade.Draw = function () {
|
||||
if (guiControl.trade && guiControl.trade.show) {
|
||||
guiControl.trade.activateDelay -= (guiControl.trade.activateDelay > 0) ? 1 : 0;
|
||||
// console.log("trade screen island: " + guiControl.trade.island.name);
|
||||
// Draw background color.
|
||||
var tmp = Oversimplified.context.fillStyle;
|
||||
Oversimplified.context.fillStyle = "#D9BEA5";
|
||||
Oversimplified.context.fillRect(0, 0, Oversimplified.camera.width, Oversimplified.camera.height);
|
||||
Oversimplified.context.fillStyle = tmp;
|
||||
|
||||
if (ct_down().down) {
|
||||
snd_cursordown.Play();
|
||||
guiControl.trade.cursorPosition++;
|
||||
}
|
||||
if (ct_up().down) {
|
||||
snd_cursordown.Play();
|
||||
guiControl.trade.cursorPosition--;
|
||||
}
|
||||
if (ct_right().down) {
|
||||
snd_cursordown.Play();
|
||||
guiControl.trade.page++;
|
||||
}
|
||||
if (ct_left().down) {
|
||||
snd_cursordown.Play();
|
||||
guiControl.trade.page--;
|
||||
}
|
||||
|
||||
if (guiControl.trade.screen == "main") {
|
||||
// console.log(guiControl.trade.screen);
|
||||
// Limit Cursor
|
||||
if (guiControl.trade.cursorPosition < 0) {
|
||||
guiControl.trade.cursorPosition = 3;
|
||||
}
|
||||
if (guiControl.trade.cursorPosition > 3) {
|
||||
guiControl.trade.cursorPosition = 0;
|
||||
}
|
||||
// Limit page
|
||||
if (guiControl.trade.page < 0) {
|
||||
guiControl.trade.page = 0;
|
||||
}
|
||||
if (guiControl.trade.page > 0) {
|
||||
guiControl.trade.page = 0;
|
||||
}
|
||||
|
||||
// Title
|
||||
guiControl.drawPixelText("On Island", (guiControl.trade.padding * 2), guiControl.trade.padding, 10, "black", 6);
|
||||
// Money icon
|
||||
// guiControl.drawIcon(7, 2, guiControl.trade.leftBorder, guiControl.trade.rowTop(0));
|
||||
guiControl.drawPixelText((guiControl.trade.island.CheckInventory().length > 0) ? "Buy" : "Sold Out!", guiControl.trade.leftBorder, guiControl.trade.rowTop(0) + pixel(), 10, (guiControl.trade.island.CheckInventory().length > 0) ? "black" : "white", 6);
|
||||
// Supplies icon
|
||||
// guiControl.drawIcon(9, 2, guiControl.trade.leftBorder, guiControl.trade.rowTop(1));
|
||||
guiControl.drawPixelText((G.inventory.CheckCargo().length > 0) ? "Sell" : "No Cargo!", guiControl.trade.leftBorder, guiControl.trade.rowTop(1) + pixel(), 10, (G.inventory.CheckCargo().length > 0) ? "black" : "white", 6);
|
||||
// Cargo icon
|
||||
// guiControl.drawIcon(1, 0, guiControl.trade.leftBorder, guiControl.trade.rowTop(2));
|
||||
guiControl.drawPixelText("Tavern", guiControl.trade.leftBorder, guiControl.trade.rowTop(2) + pixel(), 8, "black", 6);
|
||||
|
||||
// Close Text
|
||||
guiControl.drawPixelText("Leave", guiControl.trade.leftBorder, guiControl.trade.rowTop(3) + pixel(), 8, "black", 6);
|
||||
|
||||
// Draw cursor
|
||||
guiControl.drawCursor(guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(guiControl.trade.cursorPosition));
|
||||
|
||||
// Button Action
|
||||
if (guiControl.trade.activateDelay <= 0) {
|
||||
if (ct_confirm().down) {
|
||||
switch (guiControl.trade.cursorPosition) {
|
||||
case 0: {
|
||||
if (guiControl.trade.island.CheckInventory().length > 0) {
|
||||
snd_select.Play();
|
||||
guiControl.trade.screen = "buy";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
}
|
||||
else {
|
||||
snd_cannotbuy.Play();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
if (G.inventory.CheckCargo().length > 0) {
|
||||
snd_select.Play();
|
||||
guiControl.trade.screen = "sell";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
} else {
|
||||
snd_cannotbuy.Play();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
snd_select.Play();
|
||||
guiControl.trade.screen = "tavern";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
snd_cursorup.Play();
|
||||
mus_trade.Stop();
|
||||
mus_sail.Play();
|
||||
guiControl.trade.show = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// snd_select.Play();
|
||||
guiControl.trade.cursorPosition = 0;
|
||||
guiControl.trade.page = 0;
|
||||
// console.log(guiControl.trade.screen);
|
||||
}
|
||||
if (ct_cancel().down) {
|
||||
snd_cursorup.Play();
|
||||
mus_trade.Stop();
|
||||
mus_sail.Play();
|
||||
guiControl.trade.show = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (guiControl.trade.screen == "buy") {
|
||||
// console.log(guiControl.trade.screen);
|
||||
// Limit Cursor
|
||||
if (guiControl.trade.cursorPosition < 0) {
|
||||
guiControl.trade.cursorPosition = 2;
|
||||
}
|
||||
if (guiControl.trade.cursorPosition > 2) {
|
||||
guiControl.trade.cursorPosition = 0;
|
||||
}
|
||||
|
||||
// Title
|
||||
guiControl.drawPixelText("Buy", guiControl.trade.leftBorder - pixel(2), guiControl.topOfBackground, 10, "black", 6);
|
||||
|
||||
// Money icon
|
||||
guiControl.drawIcon(7, 2, guiControl.trade.padding, guiControl.trade.rowTop(0) - pixel(3));
|
||||
guiControl.drawPixelText(G.inventory.moneyDisplay(), guiControl.trade.padding + pixel(guiControl.iconSize + 2), guiControl.trade.rowTop(0) + pixel(2) - pixel(3), 10, "black", 4);
|
||||
|
||||
// Cargo icons
|
||||
var items = guiControl.trade.island.CheckInventory(); // Contains the item ids that have more than 1 item
|
||||
|
||||
// Limit page
|
||||
if (guiControl.trade.page < 0) {
|
||||
guiControl.trade.page = items.length - 1;
|
||||
}
|
||||
if (guiControl.trade.page > items.length - 1) {
|
||||
guiControl.trade.page = 0;
|
||||
}
|
||||
|
||||
if (items.length > 0) {
|
||||
var itemPrice = G.economy.cargoItemWorth[items[guiControl.trade.page]] + guiControl.trade.island.priceDifferences[items[guiControl.trade.page]] - guiControl.trade.island.haggleAmount;
|
||||
if (itemPrice < 1) itemPrice = 1;
|
||||
var itemPriceDisplay = itemPrice.toString() + " c";
|
||||
guiControl.drawItem(items[guiControl.trade.page], guiControl.trade.leftBorder + pixel(40), guiControl.trade.rowTop(1) - pixel(5));
|
||||
guiControl.drawPixelText(itemPriceDisplay, guiControl.trade.leftBorder + pixel(40) + pixel(guiControl.iconSize + 4), guiControl.trade.rowTop(1) - pixel(5) + pixel(), 8, "black", 6);
|
||||
|
||||
if (items.length > 1) {
|
||||
guiControl.drawPageArrow("left", guiControl.trade.padding + pixel(30), guiControl.trade.rowTop(1) - pixel(5));
|
||||
guiControl.drawPageArrow("right", OS.camera.width - pixel(4) - guiControl.trade.padding - pixel(50), guiControl.trade.rowTop(1) - pixel(5));
|
||||
}
|
||||
|
||||
// Amounts
|
||||
guiControl.drawPixelText("Shop Has " + guiControl.trade.island.inventory[items[guiControl.trade.page]].toString(), OS.camera.width - pixel(50), guiControl.trade.rowTop(2) - pixel(6) + pixel(), 9, (guiControl.trade.island.CanBuyFrom(items[guiControl.trade.page], itemPrice)) ? "black" : "yellow", 4);
|
||||
guiControl.drawPixelText("You Have " + G.inventory.cargo[items[guiControl.trade.page]].toString(), OS.camera.width - pixel(50), guiControl.trade.rowTop(3) - pixel(6) + pixel(), 9, (G.inventory.cargo[items[guiControl.trade.page]] < G.stats.hold) ? "black" : "yellow", 4);
|
||||
} else {
|
||||
guiControl.drawPixelText("Sold Out!", guiControl.trade.leftBorder, guiControl.trade.rowTop(1) - pixel(5) + pixel(), 10, "black", 6);
|
||||
}
|
||||
|
||||
// Draw Amount of Cargo
|
||||
guiControl.drawIcon(1, 1, OS.camera.width - pixel(50), guiControl.trade.rowTop(4) - pixel(5));
|
||||
guiControl.drawPixelText(G.inventory.CheckCargo().length.toString(), OS.camera.width - pixel(50) + (guiControl.iconScaled + pixel()), guiControl.trade.rowTop(4) - pixel(4), 4, (G.inventory.CheckCargo().length < G.stats.inventory) ? "black" : "yellow", 6);
|
||||
|
||||
// Yes/No Options
|
||||
guiControl.drawPixelText("Haggle", guiControl.trade.leftBorder, guiControl.trade.rowTop(2) - pixel(2), 8, (guiControl.trade.island.timesHaggledToday >= G.stats.popularity) ? "yellow" : ((items.length > 0 && guiControl.trade.island.haggleAmount == 0) ? "black" : "white"), 6);
|
||||
guiControl.drawPixelText((guiControl.trade.island.CanBuyFrom(items[guiControl.trade.page], itemPrice)) ? "Yes" : "Nothing to Buy!", guiControl.trade.leftBorder, guiControl.trade.rowTop(3) - pixel(2), 20, (items.length > 0 && G.inventory.CanBuy(items[guiControl.trade.page], itemPrice)) ? ((guiControl.trade.island.CanBuyFrom(items[guiControl.trade.page], itemPrice)) ? "black" : "yellow") : "white", 6);
|
||||
|
||||
// Back Text
|
||||
guiControl.drawPixelText("Back", guiControl.trade.leftBorder, guiControl.trade.rowTop(4) - pixel(2), 8, "black", 6);
|
||||
|
||||
// Draw cursor
|
||||
guiControl.drawCursor(guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(guiControl.trade.cursorPosition + 2) - pixel(3));
|
||||
|
||||
// Button Action
|
||||
if (guiControl.trade.activateDelay <= 0) {
|
||||
if (ct_confirm().down) {
|
||||
switch (guiControl.trade.cursorPosition) {
|
||||
case 0: { // Haggle
|
||||
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.
|
||||
{
|
||||
snd_sell.Play();
|
||||
guiControl.trade.island.haggleAmount = G.stats.haggling;
|
||||
} else {
|
||||
snd_cannotbuy.Play();
|
||||
guiControl.trade.island.timesHaggledToday++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1: { // Buy
|
||||
if (items.length > 0 &&
|
||||
G.inventory.CanBuy(items[guiControl.trade.page], itemPrice) &&
|
||||
guiControl.trade.island.CanBuyFrom(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);
|
||||
} else {
|
||||
snd_cannotbuy.Play();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
snd_cursorup.Play();
|
||||
guiControl.trade.screen = "main";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
guiControl.trade.cursorPosition = 0; // The position where "Buy" is on main screen.
|
||||
break;
|
||||
}
|
||||
}
|
||||
// console.log(guiControl.trade.screen);
|
||||
}
|
||||
if (ct_cancel().down) {
|
||||
snd_cursorup.Play();
|
||||
guiControl.trade.screen = "main";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
guiControl.trade.cursorPosition = 0; // The position where "Buy" is on main screen.
|
||||
// console.log(guiControl.trade.screen);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (guiControl.trade.screen == "sell") {
|
||||
// console.log(guiControl.trade.screen);
|
||||
// Limit Cursor
|
||||
if (guiControl.trade.cursorPosition < 0) {
|
||||
guiControl.trade.cursorPosition = 2;
|
||||
}
|
||||
if (guiControl.trade.cursorPosition > 2) {
|
||||
guiControl.trade.cursorPosition = 0;
|
||||
}
|
||||
|
||||
// Title
|
||||
guiControl.drawPixelText("Sell", guiControl.trade.leftBorder - pixel(2), guiControl.topOfBackground, 10, "black", 6);
|
||||
|
||||
// Money icon
|
||||
guiControl.drawIcon(7, 2, guiControl.trade.padding, guiControl.trade.rowTop(0) - pixel(3));
|
||||
guiControl.drawPixelText(G.inventory.moneyDisplay(), guiControl.trade.padding + pixel(guiControl.iconSize + 2), guiControl.trade.rowTop(0) + pixel(2) - pixel(3), 10, "black", 4);
|
||||
|
||||
// Cargo icons
|
||||
var items = G.inventory.CheckCargo(); // Contains the item ids that have more than 1 item
|
||||
|
||||
// Limit page
|
||||
if (guiControl.trade.page < 0) {
|
||||
guiControl.trade.page = items.length - 1;
|
||||
}
|
||||
if (guiControl.trade.page > items.length - 1) {
|
||||
guiControl.trade.page = 0;
|
||||
}
|
||||
|
||||
if (items.length > 0) {
|
||||
var itemPrice = G.economy.cargoItemWorth[items[guiControl.trade.page]] + guiControl.trade.island.priceDifferences[items[guiControl.trade.page]];
|
||||
var priceCut = 0.5 + ((guiControl.trade.island.haggleAmount == 0) ? 0 : (G.stats.popularity * 0.01 * 0.5)); // If haggled successfully, lessen the price cut by half of your popularity's percent worth.
|
||||
itemPrice = Math.round(itemPrice * priceCut);
|
||||
if (itemPrice < 1) itemPrice = 1;
|
||||
var itemPriceDisplay = itemPrice.toString() + " c";
|
||||
guiControl.drawItem(items[guiControl.trade.page], guiControl.trade.leftBorder + pixel(40), guiControl.trade.rowTop(1) - pixel(5));
|
||||
guiControl.drawPixelText(itemPriceDisplay, guiControl.trade.leftBorder + pixel(40) + pixel(guiControl.iconSize + 4), guiControl.trade.rowTop(1) - pixel(5) + pixel(), 8, "black", 6);
|
||||
|
||||
if (items.length > 1) {
|
||||
guiControl.drawPageArrow("left", guiControl.trade.padding + pixel(30), guiControl.trade.rowTop(1) - pixel(5));
|
||||
guiControl.drawPageArrow("right", OS.camera.width - pixel(4) - guiControl.trade.padding - pixel(50), guiControl.trade.rowTop(1) - pixel(5));
|
||||
}
|
||||
|
||||
// Amounts
|
||||
guiControl.drawPixelText("Shop Has " + guiControl.trade.island.inventory[items[guiControl.trade.page]].toString(), OS.camera.width - pixel(50), guiControl.trade.rowTop(2) - pixel(6) + pixel(), 9, (guiControl.trade.island.CanBuyFrom(items[guiControl.trade.page], itemPrice)) ? "black" : "yellow", 4);
|
||||
guiControl.drawPixelText("You Have " + G.inventory.cargo[items[guiControl.trade.page]].toString(), OS.camera.width - pixel(50), guiControl.trade.rowTop(3) - pixel(6) + pixel(), 9, (G.inventory.cargo[items[guiControl.trade.page]] < G.stats.hold) ? "black" : "yellow", 4);
|
||||
} else {
|
||||
guiControl.drawPixelText("No Cargo!", guiControl.trade.padding, guiControl.trade.rowTop(1) - pixel(5) + pixel(), 10, "black", 6);
|
||||
}
|
||||
|
||||
// Draw Amount of Cargo
|
||||
guiControl.drawIcon(1, 1, OS.camera.width - pixel(20), guiControl.trade.rowTop(4) - pixel(5));
|
||||
guiControl.drawPixelText(G.inventory.CheckCargo().length.toString(), OS.camera.width - pixel(20) + (guiControl.iconScaled + pixel()), guiControl.trade.rowTop(4) - pixel(4), 4, (G.inventory.CheckCargo().length > 0) ? "black" : "yellow", 6);
|
||||
|
||||
// Yes/No Options
|
||||
guiControl.drawPixelText("Haggle?", guiControl.trade.leftBorder, guiControl.trade.rowTop(2) - pixel(2), 8, (guiControl.trade.island.timesHaggledToday >= G.stats.popularity) ? "yellow" : ((items.length > 0 && guiControl.trade.island.haggleAmount == 0) ? "black" : "white"), 6);
|
||||
guiControl.drawPixelText((guiControl.trade.island.CanSellTo(items[guiControl.trade.page], itemPrice)) ? "Yes" : "Nothing to Sell!", guiControl.trade.leftBorder, guiControl.trade.rowTop(3) - pixel(2), 20, (items.length > 0 && G.inventory.CanSell(items[guiControl.trade.page])) ? ((guiControl.trade.island.CanSellTo(items[guiControl.trade.page], itemPrice)) ? "black" : "yellow") : "white", 6);
|
||||
|
||||
// Back Text
|
||||
guiControl.drawPixelText("Back", guiControl.trade.leftBorder, guiControl.trade.rowTop(4) - pixel(2), 8, "black", 6);
|
||||
|
||||
// Draw cursor
|
||||
guiControl.drawCursor(guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(guiControl.trade.cursorPosition + 2) - pixel(3));
|
||||
|
||||
// Button Action
|
||||
if (guiControl.trade.activateDelay <= 0) {
|
||||
if (ct_confirm().down) {
|
||||
switch (guiControl.trade.cursorPosition) {
|
||||
case 0: { // Haggle
|
||||
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.
|
||||
{
|
||||
snd_sell.Play();
|
||||
guiControl.trade.island.haggleAmount = G.stats.haggling;
|
||||
} else {
|
||||
snd_cannotbuy.Play();
|
||||
guiControl.trade.island.timesHaggledToday++;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1: { // Sell
|
||||
if (items.length > 0 &&
|
||||
G.inventory.CanSell(items[guiControl.trade.page]) &&
|
||||
guiControl.trade.island.CanSellTo(items[guiControl.trade.page], itemPrice)) //If cursor is over yes and you can buy, buy it.
|
||||
{
|
||||
snd_sell.Play();
|
||||
guiControl.trade.island.SellTo(items[guiControl.trade.page], itemPrice);
|
||||
} else {
|
||||
snd_cannotbuy.Play();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
snd_cursorup.Play();
|
||||
guiControl.trade.screen = "main";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
guiControl.trade.cursorPosition = 1; // The position where "Sell" is on main screen.
|
||||
break;
|
||||
}
|
||||
}
|
||||
// console.log(guiControl.trade.screen);
|
||||
}
|
||||
if (ct_cancel().down) {
|
||||
snd_cursorup.Play();
|
||||
guiControl.trade.screen = "main";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
guiControl.trade.cursorPosition = 1; // The position where "Sell" is on main screen.
|
||||
// console.log(guiControl.trade.screen);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (guiControl.trade.screen == "tavern") {
|
||||
// Limit Cursor
|
||||
if (guiControl.trade.cursorPosition < 0) {
|
||||
guiControl.trade.cursorPosition = 2;
|
||||
}
|
||||
if (guiControl.trade.cursorPosition > 2) {
|
||||
guiControl.trade.cursorPosition = 0;
|
||||
}
|
||||
|
||||
// Title
|
||||
guiControl.drawPixelText("Tavern", guiControl.leftBorder - pixel(6), guiControl.topOfBackground, 8, "black", 6);
|
||||
|
||||
var innPrice = G.economy.innCost + guiControl.trade.island.innPriceDifference;
|
||||
guiControl.drawPixelText("Heal costs " + innPrice.toString() + " C", guiControl.leftBorder - pixel(5), guiControl.trade.rowTop(0) - pixel(), 10, "black", 4);
|
||||
|
||||
// Money icon
|
||||
guiControl.drawIcon(7, 2, guiControl.trade.padding, guiControl.trade.rowTop(1) - pixel());
|
||||
guiControl.drawPixelText(G.inventory.moneyDisplay(), guiControl.trade.padding + pixel(guiControl.iconSize + 2), guiControl.trade.rowTop(1) + pixel(), 10, "black", 4);
|
||||
|
||||
// Options
|
||||
guiControl.drawPixelText("Gossip", guiControl.leftBorder, guiControl.trade.rowTop(2) - pixel(), 0, "black", 6);
|
||||
guiControl.drawPixelText("Heal", guiControl.leftBorder, guiControl.trade.rowTop(3) - pixel(), 4, (G.inventory.money > innPrice && G.stats.illness > 0) ? "black" : "white", 6);
|
||||
// Illness icon
|
||||
guiControl.drawIcon(4, 1, guiControl.leftBorder + pixel(30), guiControl.trade.rowTop(3) - pixel(2));
|
||||
guiControl.drawPixelText(G.stats.illness.toString(), guiControl.leftBorder + pixel(30) + pixel(guiControl.iconSize + 2), guiControl.trade.rowTop(3), 2, (G.stats.illness == 0) ? "yellow" : "black", 4);
|
||||
|
||||
// Back Text
|
||||
guiControl.drawPixelText("Back", guiControl.leftBorder, guiControl.trade.rowTop(4) - pixel(), 8, "black", 6);
|
||||
|
||||
// Draw cursor
|
||||
guiControl.drawCursor(guiControl.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(guiControl.trade.cursorPosition + 2) - pixel(2));
|
||||
|
||||
// Button Action
|
||||
if (guiControl.trade.activateDelay <= 0) {
|
||||
if (ct_confirm().down) {
|
||||
switch (guiControl.trade.cursorPosition) {
|
||||
case 0: {
|
||||
snd_select.Play();
|
||||
guiControl.trade.screen = "gossip";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
guiControl.trade.cursorPosition = 2; // The position where "Supplies" is on main screen.
|
||||
break;
|
||||
}
|
||||
case 1: {
|
||||
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();
|
||||
} else {
|
||||
snd_cannotbuy.Play();
|
||||
}
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
snd_cursorup.Play();
|
||||
guiControl.trade.screen = "main";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
guiControl.trade.cursorPosition = 2; // The position where "Supplies" is on main screen.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// Give a cooldown so you don't accidentally do something you don't want.
|
||||
guiControl.trade.activateDelay = 5;
|
||||
}
|
||||
|
||||
if (ct_cancel().down) {
|
||||
snd_cursorup.Play();
|
||||
guiControl.trade.screen = "main";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
guiControl.trade.cursorPosition = 2; // The position where "Supplies" is on main screen.
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (guiControl.trade.screen == "gossip") {
|
||||
// console.log(guiControl.trade.screen);
|
||||
// Limit Cursor
|
||||
if (guiControl.trade.cursorPosition < 0) {
|
||||
guiControl.trade.cursorPosition = 0;
|
||||
}
|
||||
if (guiControl.trade.cursorPosition > 0) {
|
||||
guiControl.trade.cursorPosition = 0;
|
||||
}
|
||||
|
||||
// Title
|
||||
guiControl.drawPixelText("Gossip", guiControl.trade.padding, guiControl.topOfBackground, 10, "black", 6);
|
||||
|
||||
guiControl.drawPixelText("Use the map with M to find new islands to trade with!", guiControl.trade.padding, guiControl.trade.rowTop(0) - pixel(2), 0, "black", 4);
|
||||
|
||||
// Back Text
|
||||
guiControl.drawPixelText("Back", guiControl.trade.leftBorder, guiControl.trade.rowTop(4) - pixel(2), 8, "black", 6);
|
||||
|
||||
// Draw cursor
|
||||
guiControl.drawCursor(guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(4) - pixel(3));
|
||||
|
||||
// Button Action
|
||||
if (guiControl.trade.activateDelay <= 0) {
|
||||
if (ct_confirm().down || ct_cancel().down) {
|
||||
snd_cursorup.Play();
|
||||
guiControl.trade.screen = "tavern";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
guiControl.trade.cursorPosition = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
Before Width: | Height: | Size: 476 B |
|
Before Width: | Height: | Size: 776 B |
|
Before Width: | Height: | Size: 475 B |
|
Before Width: | Height: | Size: 755 B |
|
Before Width: | Height: | Size: 486 B |
|
Before Width: | Height: | Size: 778 B |
BIN
images/alphabets_sheet.png
Normal file
|
After Width: | Height: | Size: 3.4 KiB |
|
Before Width: | Height: | Size: 159 B |
|
Before Width: | Height: | Size: 749 B |
|
Before Width: | Height: | Size: 811 B |
|
Before Width: | Height: | Size: 151 B |
BIN
images/gui_sheet.png
Normal file
|
After Width: | Height: | Size: 8.3 KiB |
|
Before Width: | Height: | Size: 1.9 KiB |
|
Before Width: | Height: | Size: 1,002 B |
BIN
images/screenshots/gamejolt-banner.png
Normal file
|
After Width: | Height: | Size: 4.6 KiB |
BIN
images/screenshots/gamejolt-banner.xcf
Normal file
|
Before Width: | Height: | Size: 534 KiB After Width: | Height: | Size: 534 KiB |
|
Before Width: | Height: | Size: 201 KiB After Width: | Height: | Size: 201 KiB |
|
Before Width: | Height: | Size: 43 KiB After Width: | Height: | Size: 43 KiB |
|
Before Width: | Height: | Size: 162 KiB After Width: | Height: | Size: 162 KiB |
|
Before Width: | Height: | Size: 254 KiB After Width: | Height: | Size: 254 KiB |
BIN
images/screenshots/screenshot_4-17-2016.gif
Normal file
|
After Width: | Height: | Size: 21 KiB |
BIN
images/screenshots/screenshot_4-17-2016_itch-cropped.gif
Normal file
|
After Width: | Height: | Size: 16 KiB |
BIN
images/screenshots/screenshot_4-18-2016_jam-final.gif
Normal file
|
After Width: | Height: | Size: 220 KiB |
|
Before Width: | Height: | Size: 136 KiB After Width: | Height: | Size: 136 KiB |
|
Before Width: | Height: | Size: 4.3 KiB After Width: | Height: | Size: 4.3 KiB |
|
Before Width: | Height: | Size: 1.1 KiB After Width: | Height: | Size: 1.1 KiB |
|
Before Width: | Height: | Size: 160 KiB After Width: | Height: | Size: 160 KiB |
BIN
images/screenshots/ship_comparison.png
Normal file
|
After Width: | Height: | Size: 13 KiB |
BIN
images/screenshots/trade-winds_gamejolt.png
Normal file
|
After Width: | Height: | Size: 4 KiB |
BIN
images/sources/alphabets_sheet.xcf
Normal file
BIN
images/sources/gui_sheet.xcf
Normal file
BIN
images/sources/title.pyxel
Normal file
|
Before Width: | Height: | Size: 283 B |
82
index.html
|
|
@ -3,7 +3,7 @@
|
|||
<head>
|
||||
<meta charset="utf-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="chrome=1">
|
||||
<title>Lowrez-jam-2016 by AlamantusGameDev</title>
|
||||
<title>Trade Winds by AlamantusGameDev</title>
|
||||
|
||||
<link rel="stylesheet" href="stylesheets/styles.css">
|
||||
<link rel="stylesheet" href="stylesheets/github-light.css">
|
||||
|
|
@ -15,38 +15,41 @@
|
|||
<![endif]-->
|
||||
</head>
|
||||
<body>
|
||||
<div class="wrapper">
|
||||
<header>
|
||||
<h1 class="header">Lowrez-jam-2016</h1>
|
||||
<p class="header">An OversimplifiedJS game for the 2016 LowRez Jam (https://itch.io/jam/lowrezjam2016)</p>
|
||||
<div class="wrapper">
|
||||
<header>
|
||||
<h1 class="header">Trade Winds</h1>
|
||||
<p class="header">An exploration and trade game built with <a href="https://github.com/Alamantus/OversimplifiedJS" target="_blank">OversimplifiedJS</a></p>
|
||||
|
||||
<ul>
|
||||
<li class="download"><a class="buttons" href="https://github.com/AlamantusGameDev/LowRez-Jam-2016/zipball/master">Download ZIP</a></li>
|
||||
<li class="download"><a class="buttons" href="https://github.com/AlamantusGameDev/LowRez-Jam-2016/tarball/master">Download TAR</a></li>
|
||||
<li><a class="buttons github" href="https://github.com/AlamantusGameDev/LowRez-Jam-2016">View On GitHub</a></li>
|
||||
</ul>
|
||||
<ul>
|
||||
<li class="download"><a class="buttons" href="https://github.com/AlamantusGameDev/Trade-Winds/zipball/master">Download ZIP</a></li>
|
||||
<li class="download"><a class="buttons" href="https://github.com/AlamantusGameDev/Trade-Winds/tarball/master">Download TAR</a></li>
|
||||
<li><a class="buttons github" href="https://github.com/AlamantusGameDev/Trade-Winds">View On GitHub</a></li>
|
||||
</ul>
|
||||
|
||||
<p class="header">This project is maintained by <a class="header name" href="https://github.com/AlamantusGameDev">AlamantusGameDev</a></p>
|
||||
<p class="header">This project is maintained by <a class="header name" href="http://www.alamantus.com">Alamantus GameDev</a></p>
|
||||
|
||||
|
||||
</header>
|
||||
<section>
|
||||
<h2>Play</h2>
|
||||
<p><i>If the box is empty, just refresh the page until it loads. It's a bug with the engine that comes up during development. It'll be fine when it's all finished!</i></p>
|
||||
<canvas style="border:solid 1px black;" id="game">
|
||||
Your browser is really old, dude - no canvas support! Update this thing!
|
||||
</canvas>
|
||||
<div id="audio"></div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>
|
||||
<a id="about" class="anchor" href="#about" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>About</h2>
|
||||
</header>
|
||||
<section>
|
||||
<h2>Play</h2>
|
||||
<p><i>You may need to refresh the page if all of the assets do not load.</i></p>
|
||||
<canvas style="border:solid 1px black;" id="game">
|
||||
Your browser is really old, dude - no canvas support! Update this thing!
|
||||
</canvas>
|
||||
<div id="audio"></div>
|
||||
</section>
|
||||
|
||||
<section>
|
||||
<h2>
|
||||
<a id="about" class="anchor" href="#about" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>
|
||||
About
|
||||
</h2>
|
||||
|
||||
<p>This is a work in progress for the <a href="https://itch.io/jam/lowrezjam2016">2016 LowRez Jam</a>. Its official name will probably be <em>Trade Winds</em>, and the final version will be <a href="https://alamantus-gamedev.itch.io/trade-winds">on Itch.io</a>.</p>
|
||||
<p>This page contains the in-dev version of the game, and the most recent stable version will be <a href="https://alamantus-gamedev.itch.io/trade-winds">on Itch.io</a>.</p>
|
||||
|
||||
<h2>
|
||||
<a id="controls" class="anchor" href="#controls" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Controls</h2>
|
||||
<a id="controls" class="anchor" href="#controls" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>Controls
|
||||
</h2>
|
||||
|
||||
<strong>In-Game Controls</strong>
|
||||
<ul>
|
||||
|
|
@ -62,6 +65,8 @@
|
|||
</li>
|
||||
<li>Interact with Island: <code>Z</code> or <code>Space</code>
|
||||
</li>
|
||||
<li>Show Map: <code>M</code>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<strong>Menu Controls</strong>
|
||||
|
|
@ -80,6 +85,12 @@
|
|||
</li>
|
||||
</ul>
|
||||
|
||||
<strong>On Title Screen</strong>
|
||||
<ul>
|
||||
<li>Show Credits: <code>X</code> or <code>Shift</code>
|
||||
</li>
|
||||
</ul>
|
||||
|
||||
<h2>
|
||||
<a id="how-to-play" class="anchor" href="#how-to-play" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>How to Play</h2>
|
||||
|
||||
|
|
@ -87,15 +98,16 @@
|
|||
<p>The bottom right side shows the clock. When the dial rotates back around to the top, the prices of items are all refactored. Time doesn't move when you're on a trade screen.</p>
|
||||
<p>You can only buy 20 of one item and you can only hold 3 different kinds of items. Choose wisely!</p>
|
||||
<p>You can haggle on an island with a 5% success rate. You can only haggle 5 times per island before they won't let you haggle anymore. If you haggle successfully, buying prices decrease and selling prices increase for the day.</p>
|
||||
<p>Throughout the day as you sail, your crew has a small chance of getting ill, which will negatively affect your ship's energy. You can pay to heal at an island's Tavern.</p>
|
||||
<p>Press right or left on the Storage screen to show the Map. Green pixels are islands and the red pixel is your current position. You can continue moving forward while the map is pulled up, but you can't control your ship. You have to exit the menu screen to control your ship.</p>
|
||||
<p>The game saves at the start of each day. If you stop in the middle of the day, you will lose your progress for that day.</p>
|
||||
|
||||
<p>There's no end game yet, but you can sail around and trade as long as you want!</p>
|
||||
</section>
|
||||
<footer>
|
||||
<p><small>Hosted on <a href="https://pages.github.com">GitHub Pages</a> using the Dinky theme</small></p>
|
||||
</footer>
|
||||
</div>
|
||||
<!--[if !IE]><script>fixScale(document);</script><![endif]-->
|
||||
|
||||
</body>
|
||||
<p>There's no end game yet, but you can sail around and trade as long as you want. Try to make as much money as you can!</p>
|
||||
</section>
|
||||
<footer>
|
||||
<p><small>Hosted on <a href="https://pages.github.com">GitHub Pages</a> using the Dinky theme</small></p>
|
||||
</footer>
|
||||
</div>
|
||||
<!--[if !IE]><script>fixScale(document);</script><![endif]-->
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -1,20 +1,19 @@
|
|||
fixScale = function(doc) {
|
||||
|
||||
var addEvent = 'addEventListener',
|
||||
type = 'gesturestart',
|
||||
qsa = 'querySelectorAll',
|
||||
scales = [1, 1],
|
||||
meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];
|
||||
var addEvent = 'addEventListener',
|
||||
type = 'gesturestart',
|
||||
qsa = 'querySelectorAll',
|
||||
scales = [1, 1],
|
||||
meta = qsa in doc ? doc[qsa]('meta[name=viewport]') : [];
|
||||
|
||||
function fix() {
|
||||
meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];
|
||||
doc.removeEventListener(type, fix, true);
|
||||
}
|
||||
|
||||
if ((meta = meta[meta.length - 1]) && addEvent in doc) {
|
||||
fix();
|
||||
scales = [.25, 1.6];
|
||||
doc[addEvent](type, fix, true);
|
||||
}
|
||||
function fix() {
|
||||
meta.content = 'width=device-width,minimum-scale=' + scales[0] + ',maximum-scale=' + scales[1];
|
||||
doc.removeEventListener(type, fix, true);
|
||||
}
|
||||
|
||||
if ((meta = meta[meta.length - 1]) && addEvent in doc) {
|
||||
fix();
|
||||
scales = [.25, 1.6];
|
||||
doc[addEvent](type, fix, true);
|
||||
}
|
||||
};
|
||||
19
loadAudio.js
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
var mus_title = new OS.E.AddTune("Title", {mp3: "audio/music/title.mp3", wav: "audio/music/title.wav"});
|
||||
var mus_sail = new OS.E.AddTune("Sailing", {mp3: "audio/music/ocean.mp3", wav: "audio/music/ocean.wav"});
|
||||
var mus_trade = new OS.E.AddTune("Trade", {mp3: "audio/music/trade.mp3", wav: "audio/music/trade.wav"});
|
||||
var mus_credits = new OS.E.AddTune("Credits", {mp3: "audio/music/credits.mp3", wav: "audio/music/credits.wav"});
|
||||
|
||||
var snd_buy = new OS.E.AddSound("Buy", {wav: "audio/sounds/Buy.wav", mp3: "audio/sounds/Buy.mp3"});
|
||||
var snd_cannotbuy = new OS.E.AddSound("Cannot Buy", {wav: "audio/sounds/Cannot_Buy.wav", mp3: "audio/sounds/Cannot_Buy.mp3"});
|
||||
var snd_heal = new OS.E.AddSound("Heal", {wav: "audio/sounds/Heal.wav", mp3: "audio/sounds/Heal.mp3"});
|
||||
var snd_illness = new OS.E.AddSound("Illness", {wav: "audio/sounds/Illness.wav", mp3: "audio/sounds/Illness.mp3"});
|
||||
var snd_cursordown = new OS.E.AddSound("Move Cursor Down", {wav: "audio/sounds/Move_Cursor.wav", mp3: "audio/sounds/Move_Cursor.mp3"});
|
||||
var snd_cursorup = new OS.E.AddSound("Move Cursor Up", {wav: "audio/sounds/Move_Cursor_Up.wav", mp3: "audio/sounds/Move_Cursor_Up.mp3"});
|
||||
var snd_sailing = new OS.E.AddSound("Sailing", {wav: "audio/sounds/Sailing.wav", mp3: "audio/sounds/Sailing.mp3"});
|
||||
var snd_select = new OS.E.AddSound("Select", {wav: "audio/sounds/Select.wav", mp3: "audio/sounds/Select.mp3"});
|
||||
var snd_sell = new OS.E.AddSound("Sell", {wav: "audio/sounds/Sell.wav", mp3: "audio/sounds/Sell.mp3"});
|
||||
var snd_wave = new OS.E.AddSound("Wave Crash", {wav: "audio/sounds/Wave_Crash.wav", mp3: "audio/sounds/Wave_Crash.mp3"});
|
||||
|
||||
function loadAudio() {
|
||||
if (Oversimplified.DEBUG.showMessages) console.log("Ran loadAudio()");
|
||||
}
|
||||
|
|
@ -11,54 +11,57 @@ var ct_shift = OS.C.Add("Shift", OS.Keycode.shift);
|
|||
var ct_space = OS.C.Add("Space", OS.Keycode.space);
|
||||
var ct_z = OS.C.Add("Z", OS.Keycode.z);
|
||||
var ct_x = OS.C.Add("X", OS.Keycode.x);
|
||||
var ct_m = OS.C.Add("M", OS.Keycode.m);
|
||||
var ct_esc = OS.C.Add("Cancel", OS.Keycode.escape);
|
||||
|
||||
function loadControls () {}
|
||||
function loadControls () {
|
||||
if (Oversimplified.DEBUG.showMessages) console.log("Ran loadControls()");
|
||||
}
|
||||
|
||||
function ct_up () {
|
||||
return {
|
||||
held : ct_wasd_up.held || ct_arrow_up.held,
|
||||
down : ct_wasd_up.down || ct_arrow_up.down,
|
||||
up : ct_wasd_up.up || ct_arrow_up.up
|
||||
}
|
||||
return {
|
||||
held : ct_wasd_up.held || ct_arrow_up.held,
|
||||
down : ct_wasd_up.down || ct_arrow_up.down,
|
||||
up : ct_wasd_up.up || ct_arrow_up.up,
|
||||
}
|
||||
}
|
||||
|
||||
function ct_left () {
|
||||
return {
|
||||
held : ct_wasd_left.held || ct_arrow_left.held,
|
||||
down : ct_wasd_left.down || ct_arrow_left.down,
|
||||
up : ct_wasd_left.up || ct_arrow_left.up
|
||||
}
|
||||
return {
|
||||
held : ct_wasd_left.held || ct_arrow_left.held,
|
||||
down : ct_wasd_left.down || ct_arrow_left.down,
|
||||
up : ct_wasd_left.up || ct_arrow_left.up,
|
||||
}
|
||||
}
|
||||
|
||||
function ct_down () {
|
||||
return {
|
||||
held : ct_wasd_down.held || ct_arrow_down.held,
|
||||
down : ct_wasd_down.down || ct_arrow_down.down,
|
||||
up : ct_wasd_down.up || ct_arrow_down.up
|
||||
}
|
||||
return {
|
||||
held : ct_wasd_down.held || ct_arrow_down.held,
|
||||
down : ct_wasd_down.down || ct_arrow_down.down,
|
||||
up : ct_wasd_down.up || ct_arrow_down.up,
|
||||
}
|
||||
}
|
||||
|
||||
function ct_right () {
|
||||
return {
|
||||
held : ct_wasd_right.held || ct_arrow_right.held,
|
||||
down : ct_wasd_right.down || ct_arrow_right.down,
|
||||
up : ct_wasd_right.up || ct_arrow_right.up
|
||||
}
|
||||
return {
|
||||
held : ct_wasd_right.held || ct_arrow_right.held,
|
||||
down : ct_wasd_right.down || ct_arrow_right.down,
|
||||
up : ct_wasd_right.up || ct_arrow_right.up,
|
||||
}
|
||||
}
|
||||
|
||||
function ct_confirm () {
|
||||
return {
|
||||
held : ct_space.held || ct_z.held,
|
||||
down : ct_space.down || ct_z.down,
|
||||
up : ct_space.up || ct_z.up
|
||||
}
|
||||
return {
|
||||
held : ct_space.held || ct_z.held,
|
||||
down : ct_space.down || ct_z.down,
|
||||
up : ct_space.up || ct_z.up,
|
||||
}
|
||||
}
|
||||
|
||||
function ct_cancel () {
|
||||
return {
|
||||
held : ct_shift.held || ct_x.held,
|
||||
down : ct_shift.down || ct_x.down,
|
||||
up : ct_shift.up || ct_x.up
|
||||
}
|
||||
return {
|
||||
held : ct_shift.held || ct_x.held,
|
||||
down : ct_shift.down || ct_x.down,
|
||||
up : ct_shift.up || ct_x.up,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
649
loadGUIs.js
|
|
@ -1,299 +1,388 @@
|
|||
function loadGUIs() {
|
||||
OS.AddScript("gui/inventoryGUI.js");
|
||||
OS.AddScript("gui/mapGUI.js");
|
||||
OS.AddScript("gui/tradeGUI.js");
|
||||
OS.AddScript("gui/titleScreen.js");
|
||||
OS.AddScript("gui/inventoryGUI.js");
|
||||
OS.AddScript("gui/mapGUI.js");
|
||||
OS.AddScript("gui/tradeGUI.js");
|
||||
|
||||
if (Oversimplified.DEBUG.showMessages) console.log("Ran loadGUIs()");
|
||||
}
|
||||
|
||||
var guiControl = {
|
||||
topOfBackground: pixel(2 + 2),
|
||||
upperBorder: pixel(13 + 2),
|
||||
lowerBorder: pixel(3 + 2),
|
||||
leftBorder: pixel(10 + 2),
|
||||
rightBorder: pixel(5 + 2),
|
||||
iconSize: 8,
|
||||
iconScaled: pixel(8),
|
||||
topOfBackground: pixel(2 + 2),
|
||||
upperBorder: pixel(13 + 2),
|
||||
lowerBorder: pixel(3 + 2),
|
||||
leftBorder: pixel(10 + 2),
|
||||
rightBorder: pixel(5 + 2),
|
||||
iconSize: 8,
|
||||
iconScaled: pixel(8),
|
||||
|
||||
iconPosition: function (cellPosition) {
|
||||
return (guiControl.iconScaled * cellPosition);
|
||||
},
|
||||
rowTop: function (rowNumber) {
|
||||
return guiControl.upperBorder + pixel((guiControl.iconSize + 2) * rowNumber);
|
||||
},
|
||||
drawEnergyBar: function () {
|
||||
var percentage = G.stats.energy / G.stats.maxEnergy;
|
||||
var barHeight = pixel(2);
|
||||
var maxBarWidth = 32;
|
||||
var barWidth = pixel(Math.round(maxBarWidth * percentage));
|
||||
|
||||
drawIcon: function (cellX, cellY, xPosition, yPosition) {
|
||||
OS.context.drawImage(guiControl.icons, guiControl.iconPosition(cellX), guiControl.iconPosition(cellY), guiControl.iconScaled, guiControl.iconScaled, xPosition, yPosition, guiControl.iconScaled, guiControl.iconScaled);
|
||||
},
|
||||
drawItem: function (itemId, xPosition, yPosition) {
|
||||
var cellX = itemId % 4;
|
||||
var cellY = Math.floor(itemId / 4);
|
||||
OS.context.drawImage(guiControl.itemSheet, guiControl.iconPosition(cellX), guiControl.iconPosition(cellY), guiControl.iconScaled, guiControl.iconScaled, xPosition, yPosition, guiControl.iconScaled, guiControl.iconScaled);
|
||||
},
|
||||
drawCursor: function (xPosition, yPosition) {
|
||||
OS.context.drawImage(guiControl.cursor, xPosition, yPosition);
|
||||
},
|
||||
drawPageArrow: function (direction, xPosition, yPosition) {
|
||||
OS.context.drawImage(guiControl.arrows, (direction == "left") ? 0 : pixel(4), 0, pixel(4), pixel(7), xPosition, yPosition, pixel(4), pixel(7));
|
||||
}
|
||||
var saveFillStyle = OS.context.fillStyle;
|
||||
OS.context.fillStyle = "#0055FF";
|
||||
OS.context.fillRect(64, OS.camera.height - barHeight - pixel(4), barWidth, barHeight);
|
||||
OS.context.fillStyle = saveFillStyle;
|
||||
},
|
||||
drawClock: function () {
|
||||
var screenX = OS.camera.width - pixel(9) - pixel(2);
|
||||
var screenY = OS.camera.height - pixel(9) - pixel(2);
|
||||
var percentOfClock = guiControl.clockTimerCount / guiControl.clockTimerCutoff;
|
||||
var clockFrameX = guiControl.gui_sheet.clock.x + (Math.floor(pixel(4) * percentOfClock) * pixel(9));
|
||||
OS.context.drawImage(guiControl.gui_sheet, clockFrameX, guiControl.gui_sheet.clock.y, pixel(9), pixel(9), screenX, screenY, pixel(9), pixel(9));
|
||||
},
|
||||
drawSpeedGauge: function () {
|
||||
var screenX = pixel(4);
|
||||
var screenY = OS.camera.height - guiControl.iconScaled - pixel(4);
|
||||
var sheetX = guiControl.gui_sheet.gauge.x + (G.player.currentSpeed * guiControl.iconScaled);
|
||||
var sheetY = guiControl.gui_sheet.gauge.y;
|
||||
OS.context.drawImage(guiControl.gui_sheet, sheetX, sheetY, guiControl.iconScaled, guiControl.iconScaled, screenX, screenY, guiControl.iconScaled, guiControl.iconScaled);
|
||||
},
|
||||
|
||||
iconPosition: function (cellPosition) {
|
||||
return (guiControl.iconScaled * cellPosition);
|
||||
},
|
||||
rowTop: function (rowNumber) {
|
||||
return guiControl.upperBorder + pixel((guiControl.iconSize + 2) * rowNumber);
|
||||
},
|
||||
|
||||
drawIcon: function (cellX, cellY, xPosition, yPosition) {
|
||||
var iconSheetX = guiControl.gui_sheet.icons.x + guiControl.iconPosition(cellX);
|
||||
var iconSheetY = guiControl.gui_sheet.icons.y + guiControl.iconPosition(cellY);
|
||||
OS.context.drawImage(guiControl.gui_sheet, iconSheetX, iconSheetY, guiControl.iconScaled, guiControl.iconScaled, xPosition, yPosition, guiControl.iconScaled, guiControl.iconScaled);
|
||||
},
|
||||
drawItem: function (itemId, xPosition, yPosition) {
|
||||
var cellX = itemId % 4;
|
||||
var cellY = Math.floor(itemId / 4);
|
||||
var itemSheetX = guiControl.gui_sheet.items.x + guiControl.iconPosition(cellX);
|
||||
var itemSheetY = guiControl.gui_sheet.items.y + guiControl.iconPosition(cellY);
|
||||
OS.context.drawImage(guiControl.gui_sheet, itemSheetX, itemSheetY, guiControl.iconScaled, guiControl.iconScaled, xPosition, yPosition, guiControl.iconScaled, guiControl.iconScaled);
|
||||
},
|
||||
drawTitleImage: function () {
|
||||
OS.context.drawImage(guiControl.gui_sheet, guiControl.gui_sheet.titleImage.x, guiControl.gui_sheet.titleImage.y, guiControl.gui_sheet.titleImage.width, guiControl.gui_sheet.titleImage.height, 0, 0, guiControl.gui_sheet.titleImage.width, guiControl.gui_sheet.titleImage.height);
|
||||
},
|
||||
drawGUIBackground: function () {
|
||||
OS.context.drawImage(guiControl.gui_sheet, guiControl.gui_sheet.guiBackground.x, guiControl.gui_sheet.guiBackground.y, guiControl.gui_sheet.guiBackground.width, guiControl.gui_sheet.guiBackground.height, pixel(2), pixel(2), guiControl.gui_sheet.guiBackground.width, guiControl.gui_sheet.guiBackground.height);
|
||||
},
|
||||
drawCursor: function (xPosition, yPosition) {
|
||||
OS.context.drawImage(guiControl.gui_sheet, guiControl.gui_sheet.guiCursor.x, guiControl.gui_sheet.guiCursor.y, guiControl.iconScaled, guiControl.iconScaled, xPosition, yPosition, guiControl.iconScaled, guiControl.iconScaled);
|
||||
},
|
||||
drawPageArrow: function (direction, xPosition, yPosition) {
|
||||
var arrowSheetX = guiControl.gui_sheet.arrows.x + ((direction == "left") ? 0 : pixel(4));
|
||||
OS.context.drawImage(guiControl.gui_sheet, arrowSheetX, guiControl.gui_sheet.arrows.y, pixel(4), pixel(7), xPosition, yPosition, pixel(4), pixel(7));
|
||||
}
|
||||
}
|
||||
guiControl.background = new Image();
|
||||
guiControl.background.src = "images/guiBackground.png";
|
||||
guiControl.cursor = new Image();
|
||||
guiControl.cursor.src = "images/guiCursor.png";
|
||||
guiControl.arrows = new Image();
|
||||
guiControl.arrows.src = "images/arrows.png";
|
||||
guiControl.gui_sheet = new Image();
|
||||
guiControl.gui_sheet.src = "images/gui_sheet.png";
|
||||
guiControl.gui_sheet.clock = { x: 0, y: 0 };
|
||||
guiControl.gui_sheet.gauge = { x: 288, y: 132 };
|
||||
guiControl.gui_sheet.arrows = { x: 256, y: 134 };
|
||||
guiControl.gui_sheet.guiCursor = { x: 256, y: 164 };
|
||||
guiControl.gui_sheet.guiBackground = { x: 0, y: 36, width: pixel(61), height: pixel(61) };
|
||||
guiControl.gui_sheet.titleImage = { x: 0, y: 276, width: pixel(64), height: pixel(33) };
|
||||
guiControl.gui_sheet.icons = { x: 256, y: 36 };
|
||||
guiControl.gui_sheet.items = { x: 448, y: 132 };
|
||||
|
||||
guiControl.itemSheet = new Image();
|
||||
guiControl.itemSheet.src = "images/items_sheet.png";
|
||||
guiControl.icons = new Image();
|
||||
guiControl.icons.src = "images/icons_sheet.png";
|
||||
guiControl.alphabet_sheet = new Image();
|
||||
guiControl.alphabet_sheet.src = "images/alphabets_sheet.png";
|
||||
guiControl.alphabet_sheet.black4 = { x: 0, y: 0 };
|
||||
guiControl.alphabet_sheet.black6 = { x: 0, y: 112 };
|
||||
guiControl.alphabet_sheet.white4 = { x: 96, y: 0 };
|
||||
guiControl.alphabet_sheet.white6 = { x: 120, y: 112 };
|
||||
guiControl.alphabet_sheet.yellow4 = { x: 192, y: 0 };
|
||||
guiControl.alphabet_sheet.yellow6 = { x: 240, y: 112 };
|
||||
|
||||
guiControl.drawPixelText = function (text, x, y, wrapWidth, color, size) {
|
||||
// Draw the text at the given x and y on the canvas using the alphabet images.
|
||||
// Remember to set the pixel scale for x and y when you call the function!
|
||||
// 4x4 font modified from http://pixeljoint.com/forum/forum_posts.asp?TID=18755&PID=185995#185995
|
||||
// 5x6 font modified from http://atariage.com/forums/topic/165697-fonts/page-4#entry2081600
|
||||
text = text.toString().toUpperCase();
|
||||
|
||||
var letterSizeX = pixel((size == 6) ? size - 1 : size);
|
||||
var letterSizeY = pixel(size);
|
||||
var maxWrapWidth = Math.floor(OS.camera.width / (letterSizeX + pixel(1)));
|
||||
|
||||
wrapWidth = (wrapWidth <= 0 || wrapWidth > maxWrapWidth) ? maxWrapWidth : wrapWidth;
|
||||
|
||||
var alphabet = new Image();
|
||||
alphabet.src = "images/alphabet_" + color + "_" + size.toString() + "px.png";
|
||||
text = text.toString().toUpperCase();
|
||||
|
||||
var letterSizeX = pixel((size == 6) ? size - 1 : size);
|
||||
var letterSizeY = pixel(size);
|
||||
var maxWrapWidth = Math.floor(OS.camera.width / (letterSizeX + pixel(1)));
|
||||
|
||||
wrapWidth = (wrapWidth <= 0 || wrapWidth > maxWrapWidth) ? maxWrapWidth : wrapWidth;
|
||||
|
||||
// var alphabet = guiControl.alphabet_sheet[color + size.toString()];
|
||||
|
||||
// Make words wrap nicely, but let punctuation wrap.
|
||||
var wordsInText = text.split(" ");
|
||||
if (wordsInText.length > 1) {
|
||||
var indexToBreak = 0;
|
||||
var replacementText = "";
|
||||
var punctuation = [".", ",", "-", "?", "!"];
|
||||
for (var w = 0; w < wordsInText.length; w++) {
|
||||
// console.log("\"" + wordsInText[w].charAt(wordsInText[w].length - 1) + "\"");
|
||||
|
||||
if (punctuation.indexOf(wordsInText[w]) == -1 && punctuation.indexOf(wordsInText[w].charAt(wordsInText[w].length - 1)) != -1) {
|
||||
// If the last character of a word is punctuation, separate it out
|
||||
wordsInText.splice(w + 1, 0, wordsInText[w].charAt(wordsInText[w].length - 1));
|
||||
// console.log("punctuation:" + wordsInText[w].charAt(wordsInText[w].length - 1));
|
||||
wordsInText[w] = wordsInText[w].substr(0, wordsInText[w].length - 1);
|
||||
// console.log("Turns to:" + wordsInText[w]);
|
||||
w--;
|
||||
} else if (replacementText.substr(indexToBreak).length + wordsInText[w].length + 1 <= wrapWidth) {
|
||||
// console.log("Adding: \"" + wordsInText[w] + " \" to \"" + replacementText.substr(indexToBreak) + "\"");
|
||||
// console.log(replacementText.substr(indexToBreak).length + wordsInText[w].length + " < " + wrapWidth);
|
||||
// console.log("\"" + replacementText.substr(indexToBreak) + "\"");
|
||||
replacementText += wordsInText[w];
|
||||
// Make words wrap nicely, but let punctuation wrap.
|
||||
var wordsInText = text.split(" ");
|
||||
if (wordsInText.length > 1) {
|
||||
var indexToBreak = 0;
|
||||
var replacementText = "";
|
||||
var punctuation = [".", ",", "-", "?", "!"];
|
||||
for (var w = 0; w < wordsInText.length; w++) {
|
||||
// console.log("\"" + wordsInText[w].charAt(wordsInText[w].length - 1) + "\"");
|
||||
|
||||
if (punctuation.indexOf(wordsInText[w]) == -1 && punctuation.indexOf(wordsInText[w].charAt(wordsInText[w].length - 1)) != -1) {
|
||||
// If the last character of a word is punctuation, separate it out
|
||||
wordsInText.splice(w + 1, 0, wordsInText[w].charAt(wordsInText[w].length - 1));
|
||||
// console.log("punctuation:" + wordsInText[w].charAt(wordsInText[w].length - 1));
|
||||
wordsInText[w] = wordsInText[w].substr(0, wordsInText[w].length - 1);
|
||||
// console.log("Turns to:" + wordsInText[w]);
|
||||
w--;
|
||||
} else if (replacementText.substr(indexToBreak).length + wordsInText[w].length + 1 <= wrapWidth) {
|
||||
// console.log("Adding: \"" + wordsInText[w] + " \" to \"" + replacementText.substr(indexToBreak) + "\"");
|
||||
// console.log(replacementText.substr(indexToBreak).length + wordsInText[w].length + " < " + wrapWidth);
|
||||
// console.log("\"" + replacementText.substr(indexToBreak) + "\"");
|
||||
replacementText += wordsInText[w];
|
||||
|
||||
if (punctuation.indexOf(wordsInText[w + 1]) == -1) { // If the next word in the array is not punctuation,
|
||||
replacementText += " "; // Then add a space after.
|
||||
}
|
||||
// console.log("Turns to: \"" + replacementText.substr(indexToBreak) + "\"");
|
||||
} else if (replacementText.substr(indexToBreak).length + wordsInText[w].length <= wrapWidth) {
|
||||
// console.log("Adding: \"" + wordsInText[w] + "\" to \"" + replacementText.substr(indexToBreak) + "\"");
|
||||
// console.log(replacementText.substr(indexToBreak).length + wordsInText[w].length + " < " + wrapWidth);
|
||||
// console.log("\"" + replacementText.substr(indexToBreak) + "\"");
|
||||
replacementText += wordsInText[w];
|
||||
// console.log("Turns to: \"" + replacementText.substr(indexToBreak) + "\"");
|
||||
indexToBreak = replacementText.length;
|
||||
} else {
|
||||
// console.log("Checking: \"" + replacementText.substr(indexToBreak) + wordsInText[w] + "\"");
|
||||
// console.log(replacementText.substr(indexToBreak).length + wordsInText[w].length + " > " + wrapWidth);
|
||||
// console.log("\"" + replacementText.substr(indexToBreak) + "\"");
|
||||
// indexToBreak = replacementText.length - 1;
|
||||
var numberOfSpaces = wrapWidth - replacementText.substr(indexToBreak).length;
|
||||
for (var s = 0; s < numberOfSpaces; s++) {
|
||||
replacementText += " ";
|
||||
}
|
||||
// console.log("Turns to: \"" + replacementText.substr(indexToBreak) + "\"");
|
||||
indexToBreak = replacementText.length;
|
||||
w--;
|
||||
// replacementText += wordsInText[w];
|
||||
if (punctuation.indexOf(wordsInText[w + 1]) == -1) { // If the next word in the array is not punctuation,
|
||||
replacementText += " "; // Then add a space after.
|
||||
}
|
||||
// console.log("Turns to: \"" + replacementText.substr(indexToBreak) + "\"");
|
||||
} else if (replacementText.substr(indexToBreak).length + wordsInText[w].length <= wrapWidth) {
|
||||
// console.log("Adding: \"" + wordsInText[w] + "\" to \"" + replacementText.substr(indexToBreak) + "\"");
|
||||
// console.log(replacementText.substr(indexToBreak).length + wordsInText[w].length + " < " + wrapWidth);
|
||||
// console.log("\"" + replacementText.substr(indexToBreak) + "\"");
|
||||
replacementText += wordsInText[w];
|
||||
// console.log("Turns to: \"" + replacementText.substr(indexToBreak) + "\"");
|
||||
indexToBreak = replacementText.length;
|
||||
} else {
|
||||
// console.log("Checking: \"" + replacementText.substr(indexToBreak) + wordsInText[w] + "\"");
|
||||
// console.log(replacementText.substr(indexToBreak).length + wordsInText[w].length + " > " + wrapWidth);
|
||||
// console.log("\"" + replacementText.substr(indexToBreak) + "\"");
|
||||
// indexToBreak = replacementText.length - 1;
|
||||
var numberOfSpaces = wrapWidth - replacementText.substr(indexToBreak).length;
|
||||
for (var s = 0; s < numberOfSpaces; s++) {
|
||||
replacementText += " ";
|
||||
}
|
||||
// console.log("Turns to: \"" + replacementText.substr(indexToBreak) + "\"");
|
||||
indexToBreak = replacementText.length;
|
||||
w--;
|
||||
// replacementText += wordsInText[w];
|
||||
}
|
||||
// console.log("----");
|
||||
}
|
||||
text = replacementText;
|
||||
}
|
||||
|
||||
for (var i = 0; i < text.length; i++) {
|
||||
var letterCellX, letterCellY;
|
||||
switch (text.charAt(i)) {
|
||||
case "A": {
|
||||
letterCellX = 0;
|
||||
letterCellY = 0;
|
||||
break;
|
||||
}
|
||||
// console.log("----");
|
||||
}
|
||||
text = replacementText;
|
||||
}
|
||||
case "B": {
|
||||
letterCellX = 1;
|
||||
letterCellY = 0;
|
||||
break;
|
||||
}
|
||||
case "C": {
|
||||
letterCellX = 2;
|
||||
letterCellY = 0;
|
||||
break;
|
||||
}
|
||||
case "D": {
|
||||
letterCellX = 3;
|
||||
letterCellY = 0;
|
||||
break;
|
||||
}
|
||||
case "E": {
|
||||
letterCellX = 4;
|
||||
letterCellY = 0;
|
||||
break;
|
||||
}
|
||||
case "F": {
|
||||
letterCellX = 5;
|
||||
letterCellY = 0;
|
||||
break;
|
||||
}
|
||||
case "G": {
|
||||
letterCellX = 0;
|
||||
letterCellY = 1;
|
||||
break;
|
||||
}
|
||||
case "H": {
|
||||
letterCellX = 1;
|
||||
letterCellY = 1;
|
||||
break;
|
||||
}
|
||||
case "I": {
|
||||
letterCellX = 2;
|
||||
letterCellY = 1;
|
||||
break;
|
||||
}
|
||||
case "J": {
|
||||
letterCellX = 3;
|
||||
letterCellY = 1;
|
||||
break;
|
||||
}
|
||||
case "K": {
|
||||
letterCellX = 4;
|
||||
letterCellY = 1;
|
||||
break;
|
||||
}
|
||||
case "L": {
|
||||
letterCellX = 5;
|
||||
letterCellY = 1;
|
||||
break;
|
||||
}
|
||||
case "M": {
|
||||
letterCellX = 0;
|
||||
letterCellY = 2;
|
||||
break;
|
||||
}
|
||||
case "N": {
|
||||
letterCellX = 1;
|
||||
letterCellY = 2;
|
||||
break;
|
||||
}
|
||||
case "O": {
|
||||
letterCellX = 2;
|
||||
letterCellY = 2;
|
||||
break;
|
||||
}
|
||||
case "P": {
|
||||
letterCellX = 3;
|
||||
letterCellY = 2;
|
||||
break;
|
||||
}
|
||||
case "Q": {
|
||||
letterCellX = 4;
|
||||
letterCellY = 2;
|
||||
break;
|
||||
}
|
||||
case "R": {
|
||||
letterCellX = 5;
|
||||
letterCellY = 2;
|
||||
break;
|
||||
}
|
||||
case "S": {
|
||||
letterCellX = 0;
|
||||
letterCellY = 3;
|
||||
break;
|
||||
}
|
||||
case "T": {
|
||||
letterCellX = 1;
|
||||
letterCellY = 3;
|
||||
break;
|
||||
}
|
||||
case "U": {
|
||||
letterCellX = 2;
|
||||
letterCellY = 3;
|
||||
break;
|
||||
}
|
||||
case "V": {
|
||||
letterCellX = 3;
|
||||
letterCellY = 3;
|
||||
break;
|
||||
}
|
||||
case "W": {
|
||||
letterCellX = 4;
|
||||
letterCellY = 3;
|
||||
break;
|
||||
}
|
||||
case "X": {
|
||||
letterCellX = 5;
|
||||
letterCellY = 3;
|
||||
break;
|
||||
}
|
||||
case "Y": {
|
||||
letterCellX = 0;
|
||||
letterCellY = 4;
|
||||
break;
|
||||
}
|
||||
case "Z": {
|
||||
letterCellX = 1;
|
||||
letterCellY = 4;
|
||||
break;
|
||||
}
|
||||
case "1": {
|
||||
letterCellX = 2;
|
||||
letterCellY = 4;
|
||||
break;
|
||||
}
|
||||
case "2": {
|
||||
letterCellX = 3;
|
||||
letterCellY = 4;
|
||||
break;
|
||||
}
|
||||
case "3": {
|
||||
letterCellX = 4;
|
||||
letterCellY = 4;
|
||||
break;
|
||||
}
|
||||
case "4": {
|
||||
letterCellX = 5;
|
||||
letterCellY = 4;
|
||||
break;
|
||||
}
|
||||
case "5": {
|
||||
letterCellX = 0;
|
||||
letterCellY = 5;
|
||||
break;
|
||||
}
|
||||
case "6": {
|
||||
letterCellX = 1;
|
||||
letterCellY = 5;
|
||||
break;
|
||||
}
|
||||
case "7": {
|
||||
letterCellX = 2;
|
||||
letterCellY = 5;
|
||||
break;
|
||||
}
|
||||
case "8": {
|
||||
letterCellX = 3;
|
||||
letterCellY = 5;
|
||||
break;
|
||||
}
|
||||
case "9": {
|
||||
letterCellX = 4;
|
||||
letterCellY = 5;
|
||||
break;
|
||||
}
|
||||
case "0": {
|
||||
letterCellX = 5;
|
||||
letterCellY = 5;
|
||||
break;
|
||||
}
|
||||
case ".": {
|
||||
letterCellX = 0;
|
||||
letterCellY = 6;
|
||||
break;
|
||||
}
|
||||
case ",": {
|
||||
letterCellX = 1;
|
||||
letterCellY = 6;
|
||||
break;
|
||||
}
|
||||
case "-": {
|
||||
letterCellX = 2;
|
||||
letterCellY = 6;
|
||||
break;
|
||||
}
|
||||
case "?": {
|
||||
letterCellX = 3;
|
||||
letterCellY = 6;
|
||||
break;
|
||||
}
|
||||
case "!": {
|
||||
letterCellX = 4;
|
||||
letterCellY = 6;
|
||||
break;
|
||||
}
|
||||
default: {// Default to Space
|
||||
letterCellX = 5;
|
||||
letterCellY = 6;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
for (var i = 0; i < text.length; i++) {
|
||||
var letterCellX, letterCellY;
|
||||
switch (text.charAt(i)) {
|
||||
case "A":
|
||||
letterCellX = 0;
|
||||
letterCellY = 0;
|
||||
break;
|
||||
case "B":
|
||||
letterCellX = 1;
|
||||
letterCellY = 0;
|
||||
break;
|
||||
case "C":
|
||||
letterCellX = 2;
|
||||
letterCellY = 0;
|
||||
break;
|
||||
case "D":
|
||||
letterCellX = 3;
|
||||
letterCellY = 0;
|
||||
break;
|
||||
case "E":
|
||||
letterCellX = 4;
|
||||
letterCellY = 0;
|
||||
break;
|
||||
case "F":
|
||||
letterCellX = 5;
|
||||
letterCellY = 0;
|
||||
break;
|
||||
case "G":
|
||||
letterCellX = 0;
|
||||
letterCellY = 1;
|
||||
break;
|
||||
case "H":
|
||||
letterCellX = 1;
|
||||
letterCellY = 1;
|
||||
break;
|
||||
case "I":
|
||||
letterCellX = 2;
|
||||
letterCellY = 1;
|
||||
break;
|
||||
case "J":
|
||||
letterCellX = 3;
|
||||
letterCellY = 1;
|
||||
break;
|
||||
case "K":
|
||||
letterCellX = 4;
|
||||
letterCellY = 1;
|
||||
break;
|
||||
case "L":
|
||||
letterCellX = 5;
|
||||
letterCellY = 1;
|
||||
break;
|
||||
case "M":
|
||||
letterCellX = 0;
|
||||
letterCellY = 2;
|
||||
break;
|
||||
case "N":
|
||||
letterCellX = 1;
|
||||
letterCellY = 2;
|
||||
break;
|
||||
case "O":
|
||||
letterCellX = 2;
|
||||
letterCellY = 2;
|
||||
break;
|
||||
case "P":
|
||||
letterCellX = 3;
|
||||
letterCellY = 2;
|
||||
break;
|
||||
case "Q":
|
||||
letterCellX = 4;
|
||||
letterCellY = 2;
|
||||
break;
|
||||
case "R":
|
||||
letterCellX = 5;
|
||||
letterCellY = 2;
|
||||
break;
|
||||
case "S":
|
||||
letterCellX = 0;
|
||||
letterCellY = 3;
|
||||
break;
|
||||
case "T":
|
||||
letterCellX = 1;
|
||||
letterCellY = 3;
|
||||
break;
|
||||
case "U":
|
||||
letterCellX = 2;
|
||||
letterCellY = 3;
|
||||
break;
|
||||
case "V":
|
||||
letterCellX = 3;
|
||||
letterCellY = 3;
|
||||
break;
|
||||
case "W":
|
||||
letterCellX = 4;
|
||||
letterCellY = 3;
|
||||
break;
|
||||
case "X":
|
||||
letterCellX = 5;
|
||||
letterCellY = 3;
|
||||
break;
|
||||
case "Y":
|
||||
letterCellX = 0;
|
||||
letterCellY = 4;
|
||||
break;
|
||||
case "Z":
|
||||
letterCellX = 1;
|
||||
letterCellY = 4;
|
||||
break;
|
||||
case "1":
|
||||
letterCellX = 2;
|
||||
letterCellY = 4;
|
||||
break;
|
||||
case "2":
|
||||
letterCellX = 3;
|
||||
letterCellY = 4;
|
||||
break;
|
||||
case "3":
|
||||
letterCellX = 4;
|
||||
letterCellY = 4;
|
||||
break;
|
||||
case "4":
|
||||
letterCellX = 5;
|
||||
letterCellY = 4;
|
||||
break;
|
||||
case "5":
|
||||
letterCellX = 0;
|
||||
letterCellY = 5;
|
||||
break;
|
||||
case "6":
|
||||
letterCellX = 1;
|
||||
letterCellY = 5;
|
||||
break;
|
||||
case "7":
|
||||
letterCellX = 2;
|
||||
letterCellY = 5;
|
||||
break;
|
||||
case "8":
|
||||
letterCellX = 3;
|
||||
letterCellY = 5;
|
||||
break;
|
||||
case "9":
|
||||
letterCellX = 4;
|
||||
letterCellY = 5;
|
||||
break;
|
||||
case "0":
|
||||
letterCellX = 5;
|
||||
letterCellY = 5;
|
||||
break;
|
||||
case ".":
|
||||
letterCellX = 0;
|
||||
letterCellY = 6;
|
||||
break;
|
||||
case ",":
|
||||
letterCellX = 1;
|
||||
letterCellY = 6;
|
||||
break;
|
||||
case "-":
|
||||
letterCellX = 2;
|
||||
letterCellY = 6;
|
||||
break;
|
||||
case "?":
|
||||
letterCellX = 3;
|
||||
letterCellY = 6;
|
||||
break;
|
||||
case "!":
|
||||
letterCellX = 4;
|
||||
letterCellY = 6;
|
||||
break;
|
||||
default: // Default to Space
|
||||
letterCellX = 5;
|
||||
letterCellY = 6;
|
||||
break;
|
||||
}
|
||||
|
||||
var lineNumber = Math.floor(i/wrapWidth);
|
||||
var horizontal = i - (wrapWidth * lineNumber);
|
||||
var letterSheetX = letterSizeX * letterCellX;
|
||||
var letterSheetY = letterSizeY * letterCellY;
|
||||
var letterX = x + (letterSizeX * horizontal) + pixel(horizontal); //Places a space between characters horizontally
|
||||
var letterY = y + (letterSizeY * lineNumber) + pixel(lineNumber); //Places a space between characters vertically
|
||||
OS.context.drawImage(alphabet, letterSheetX, letterSheetY, letterSizeX, letterSizeY, letterX, letterY, letterSizeX, letterSizeY);
|
||||
}
|
||||
var lineNumber = Math.floor(i/wrapWidth);
|
||||
var horizontal = i - (wrapWidth * lineNumber);
|
||||
var letterSheetX = guiControl.alphabet_sheet[color + size.toString()].x + (letterSizeX * letterCellX);
|
||||
var letterSheetY = guiControl.alphabet_sheet[color + size.toString()].y + (letterSizeY * letterCellY);
|
||||
var letterX = x + (letterSizeX * horizontal) + pixel(horizontal); //Places a space between characters horizontally
|
||||
var letterY = y + (letterSizeY * lineNumber) + pixel(lineNumber); //Places a space between characters vertically
|
||||
OS.context.drawImage(guiControl.alphabet_sheet, letterSheetX, letterSheetY, letterSizeX, letterSizeY, letterX, letterY, letterSizeX, letterSizeY);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,113 +1,222 @@
|
|||
var Game = {};
|
||||
G = Game;
|
||||
|
||||
G.player = {}; // Just a reference until G.player is created at rm_Ocean's load time.
|
||||
G.oceanParticle = {}; // One ocean particle will exist at any time and move around the boat.
|
||||
G.map = []; // List of island objects, generated/loaded and saved at game start, loaded on room start.
|
||||
G.currentScreen = ""; // For pause screen, stats screen, inventory screen
|
||||
G.gameStarted = false;
|
||||
G.savedGameExists = (OS.Load("TradeWindsSave")) ? true : false;
|
||||
G.player = {}; // Just a reference until G.player is created at rm_Ocean's load time.
|
||||
G.oceanParticle = {}; // One ocean particle will exist at any time and move around the boat.
|
||||
G.map = []; // List of island objects, generated/loaded and saved at game start, loaded on room start.
|
||||
G.currentScreen = ""; // For pause screen, stats screen, inventory screen
|
||||
G.inventory = {
|
||||
money: 100,
|
||||
supplies: 20, // How much stuff you have to maintain your crew's illness with.
|
||||
cargo: [0, 0, 0, 0, // Keeps track of how much of each item you have.
|
||||
0, 0, 0, 0, // Requires a check to make sure you can't buy more different kinds than you can hold.
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0],
|
||||
moneyDisplay: function () {
|
||||
var moneyString = "";
|
||||
if (G.inventory.money >= 1000000) {
|
||||
moneyString = G.inventory.money.toString().substr(0, 1);
|
||||
if (parseInt(G.inventory.money.toString().substr(1, 1)) > 0) {
|
||||
moneyString += "." + G.inventory.money.toString().substr(1, 1);
|
||||
}
|
||||
}
|
||||
if (G.inventory.money >= 1000000000000) {
|
||||
moneyString += "T";
|
||||
} else if (G.inventory.money >= 1000000000) {
|
||||
moneyString += "B";
|
||||
} else if (G.inventory.money >= 1000000) {
|
||||
moneyString += "M";
|
||||
} else {
|
||||
moneyString = G.inventory.money.toString();
|
||||
}
|
||||
money: 100,
|
||||
supplies: 20, // How much stuff you have to maintain your crew's illness with.
|
||||
cargo: [0, 0, 0, 0, // Keeps track of how much of each item you have.
|
||||
0, 0, 0, 0, // Requires a check to make sure you can't buy more different kinds than you can hold.
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0],
|
||||
moneyDisplay: function () {
|
||||
var moneyString = "";
|
||||
if (G.inventory.money >= 1000000) {
|
||||
moneyString = G.inventory.money.toString().substr(0, 1);
|
||||
if (parseInt(G.inventory.money.toString().substr(1, 1)) > 0) {
|
||||
moneyString += "." + G.inventory.money.toString().substr(1, 1);
|
||||
}
|
||||
}
|
||||
if (G.inventory.money >= 1000000000000) {
|
||||
moneyString += "T";
|
||||
} else if (G.inventory.money >= 1000000000) {
|
||||
moneyString += "B";
|
||||
} else if (G.inventory.money >= 1000000) {
|
||||
moneyString += "M";
|
||||
} else {
|
||||
moneyString = G.inventory.money.toString();
|
||||
}
|
||||
|
||||
return moneyString;
|
||||
},
|
||||
CheckCargo: function () { // Returns an array of indices that have cargo
|
||||
var indicesWithCargo = [];
|
||||
for (var i = 0; i < G.inventory.cargo.length; i++) {
|
||||
if (G.inventory.cargo[i] > 0) {
|
||||
indicesWithCargo.push(i);
|
||||
}
|
||||
}
|
||||
return indicesWithCargo;
|
||||
},
|
||||
CargoTotal: function () {
|
||||
var cargo = G.inventory.CheckCargo();
|
||||
var cargoTotal = 0;
|
||||
for (var i = 0; i < cargo.length; i++) {
|
||||
cargoTotal += G.inventory.cargo[cargo[i]];
|
||||
}
|
||||
return cargoTotal;
|
||||
},
|
||||
CanBuy: function (itemIndex, price) {
|
||||
if (G.inventory.cargo[itemIndex] < G.stats.hold && G.inventory.money > price &&
|
||||
(G.inventory.cargo[itemIndex] > 0 || G.inventory.CheckCargo().length < G.stats.inventory))
|
||||
{
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
CanSell: function (itemIndex) {
|
||||
return G.inventory.cargo[itemIndex] > 0;
|
||||
}
|
||||
return moneyString;
|
||||
},
|
||||
CheckCargo: function () { // Returns an array of indices that have cargo
|
||||
var indicesWithCargo = [];
|
||||
for (var i = 0; i < G.inventory.cargo.length; i++) {
|
||||
if (G.inventory.cargo[i] > 0) {
|
||||
indicesWithCargo.push(i);
|
||||
}
|
||||
}
|
||||
return indicesWithCargo;
|
||||
},
|
||||
CargoTotal: function () {
|
||||
var cargo = G.inventory.CheckCargo();
|
||||
var cargoTotal = 0;
|
||||
for (var i = 0; i < cargo.length; i++) {
|
||||
cargoTotal += G.inventory.cargo[cargo[i]];
|
||||
}
|
||||
return cargoTotal;
|
||||
},
|
||||
CanBuy: function (itemIndex, price) {
|
||||
if (G.inventory.cargo[itemIndex] < G.stats.hold && G.inventory.money > price &&
|
||||
(G.inventory.cargo[itemIndex] > 0 || G.inventory.CheckCargo().length < G.stats.inventory))
|
||||
{
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
},
|
||||
CanSell: function (itemIndex) {
|
||||
return G.inventory.cargo[itemIndex] > 0;
|
||||
}
|
||||
};
|
||||
G.stats = {
|
||||
inventory: 3, // Maximum number of different things the cargo can hold.
|
||||
hold: 20, // Maximum number of each individual kind of thing in the inventory.
|
||||
speed: 1, // How many pixels you move.
|
||||
hull: 3, // Your HP, pretty much. How many times you can crash without exploding.
|
||||
maxHull: 3, // How much your hull can refill to.
|
||||
popularity: 5, // Haggle success rate in percentage.
|
||||
haggling: 10, // How much you can increase the asking price by.
|
||||
crew: 2, // How many crew members you have. Influences how fast your energy recovers.
|
||||
energy: 25, // Drains rate determined by current speed. When drained, currentSpeed reduces until you have enough energy to continue.
|
||||
maxEnergy: 50, // How much to refill your energy to. Can increase with upgrades.
|
||||
illness: 0 // Your crew's overall health. When this is low, your ship slows down.
|
||||
inventory: 3, // Maximum number of different things the cargo can hold.
|
||||
hold: 20, // Maximum number of each individual kind of thing in the inventory.
|
||||
speed: 1, // How many pixels you move.
|
||||
hull: 3, // Your HP, pretty much. How many times you can crash without exploding.
|
||||
maxHull: 3, // How much your hull can refill to.
|
||||
popularity: 5, // Haggle success rate in percentage.
|
||||
haggling: 10, // How much you can increase the asking price by.
|
||||
crew: 2, // How many crew members you have. Influences how fast your energy recovers.
|
||||
energy: 25, // Drains rate determined by current speed. When drained, currentSpeed reduces until you have enough energy to continue.
|
||||
maxEnergy: 50, // How much to refill your energy to. Can increase with upgrades.
|
||||
illness: 0, // Your crew's overall health. When this is low, your ship slows down.
|
||||
};
|
||||
|
||||
G.economy = { // Aww yea, supply and demand.
|
||||
G.economy = { // Aww yea, supply and demand.
|
||||
// Items are determined by their index, and their position on the sheet determines their index.
|
||||
// So the second item on the top row is index 1, and to get its value, you get `G.economy.cargoItemWorth[1]`
|
||||
cargoItemWorth: [10, 20, 30, 30, //Can be adjusted based on sales.
|
||||
40, 20, 50, 80,
|
||||
65, 20, 20, 30,
|
||||
30, 60, 45, 70],
|
||||
cargoSold: [0, 0, 0, 0, // The more you sell, the lower the price gets
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0],
|
||||
cargoBought: [0, 0, 0, 0, // The more you buy, the higher the price gets
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0],
|
||||
UpdateEconomy: function () {
|
||||
// console.log(G.economy.cargoItemWorth);
|
||||
for (var i = 0; i < G.economy.cargoItemWorth.length; i++) {
|
||||
var totalPriceDifference = 0;
|
||||
for (var m = 0; m < G.map.length; m++) {
|
||||
// console.log("map: " + G.map[m].island);
|
||||
totalPriceDifference += G.map[m].island.priceDifferences[i];
|
||||
// console.log(G.map[m].island.priceDifferences[i]);
|
||||
}
|
||||
G.economy.cargoItemWorth[i] += Math.round(totalPriceDifference / G.map.length); // Apply the average price difference for the item.
|
||||
}
|
||||
// console.log(G.economy.cargoItemWorth);
|
||||
}
|
||||
innCost: 50,
|
||||
innStays: 0,
|
||||
cargoItemWorth: [10, 20, 30, 30, //Can be adjusted based on sales.
|
||||
40, 20, 50, 80,
|
||||
65, 20, 20, 30,
|
||||
30, 60, 45, 70],
|
||||
maxPriceChange: 10,
|
||||
cargoSold: [0, 0, 0, 0, // The more you sell, the lower the price gets
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0],
|
||||
cargoBought: [0, 0, 0, 0, // The more you buy, the higher the price gets
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0],
|
||||
UpdateEconomy: function () {
|
||||
// console.log(G.economy.cargoItemWorth);
|
||||
for (var i = 0; i < G.economy.cargoItemWorth.length; i++) {
|
||||
var totalPriceDifference = 0;
|
||||
for (var m = 0; m < G.map.length; m++) {
|
||||
// console.log("map: " + G.map[m].island);
|
||||
totalPriceDifference += G.map[m].island.priceDifferences[i];
|
||||
// console.log(G.map[m].island.priceDifferences[i]);
|
||||
}
|
||||
G.economy.cargoItemWorth[i] += Math.round(totalPriceDifference / G.map.length); // Apply the average price difference for the item.
|
||||
}
|
||||
var totalInnCost = 0;
|
||||
for (var m = 0; m < G.map.length; m++) {
|
||||
totalInnCost += G.map[m].island.innPriceDifference;
|
||||
}
|
||||
G.economy.innCost += Math.round(totalInnCost / G.map.length); // Apply the average inn price.
|
||||
// console.log(G.economy.cargoItemWorth);
|
||||
},
|
||||
};
|
||||
|
||||
function loadGameManager () {
|
||||
for (var i = 0; i < G.economy.cargoItemWorth.length; i++) {
|
||||
G.economy.cargoItemWorth[i] += Math.round(Math.randomRange(-5, 5));
|
||||
}
|
||||
G.SaveGame = function () {
|
||||
var saveObject = {
|
||||
playerX: G.player.x,
|
||||
playerY: G.player.y,
|
||||
money: G.inventory.money,
|
||||
supplies: G.inventory.supplies,
|
||||
cargo: G.inventory.cargo.slice(),
|
||||
stats: {
|
||||
inventory: G.stats.inventory,
|
||||
hold: G.stats.hold,
|
||||
speed: G.stats.speed,
|
||||
hull: G.stats.hull,
|
||||
maxHull: G.stats.maxHull,
|
||||
popularity: G.stats.popularity,
|
||||
haggling: G.stats.haggling,
|
||||
crew: G.stats.crew,
|
||||
energy: G.stats.energy,
|
||||
maxEnergy: G.stats.maxEnergy,
|
||||
illness: G.stats.illness,
|
||||
},
|
||||
economy: {
|
||||
innCost: G.economy.innCost,
|
||||
innStays: G.economy.innStays,
|
||||
itemWorth: G.economy.cargoItemWorth.slice(),
|
||||
cargoSold: G.economy.cargoSold.slice(),
|
||||
cargoBought: G.economy.cargoBought.slice(),
|
||||
},
|
||||
map: [],
|
||||
};
|
||||
for (var i = 0; i < G.map.length; i++) {
|
||||
saveObject.map.push({
|
||||
drawX: G.map[i].drawX,
|
||||
drawY: G.map[i].drawY,
|
||||
drawWidth: G.map[i].drawWidth,
|
||||
drawHeight: G.map[i].drawHeight,
|
||||
inventory: G.map[i].island.inventory.slice(),
|
||||
innPriceDifference: G.map[i].island.innPriceDifference,
|
||||
innStays: G.map[i].island.innStays,
|
||||
priceDifferences: G.map[i].island.priceDifferences.slice(),
|
||||
itemsSold: G.map[i].island.itemsSold.slice(),
|
||||
itemsBought: G.map[i].island.itemsBought.slice(),
|
||||
});
|
||||
}
|
||||
|
||||
if (OS.Save("TradeWindsSave", JSON.stringify(saveObject))) {
|
||||
console.log("Game Saved!");
|
||||
}
|
||||
}
|
||||
|
||||
G.LoadGame = function () {
|
||||
var loadObject = OS.Load("TradeWindsSave");
|
||||
if (loadObject) {
|
||||
loadObject = JSON.parse(loadObject);
|
||||
G.player.x = loadObject.playerX;
|
||||
G.player.y = loadObject.playerY;
|
||||
G.inventory.money = loadObject.money;
|
||||
G.inventory.supplies = loadObject.supplies;
|
||||
G.inventory.cargo = loadObject.cargo.slice();
|
||||
G.stats.inventory = loadObject.stats.inventory;
|
||||
G.stats.hold = loadObject.stats.hold;
|
||||
G.stats.speed = loadObject.stats.speed;
|
||||
G.stats.hull = loadObject.stats.hull;
|
||||
G.stats.maxHull = loadObject.stats.maxHull;
|
||||
G.stats.popularity = loadObject.stats.popularity;
|
||||
G.stats.haggling = loadObject.stats.haggling;
|
||||
G.stats.crew = loadObject.stats.crew;
|
||||
G.stats.energy = loadObject.stats.energy;
|
||||
G.stats.maxEnergy = loadObject.stats.maxEnergy;
|
||||
G.stats.illness = loadObject.stats.illness;
|
||||
G.economy.innCost = loadObject.economy.innCost;
|
||||
G.economy.innStays = loadObject.economy.innStays;
|
||||
G.economy.cargoItemWorth = loadObject.economy.itemWorth.slice();
|
||||
G.economy.cargoSold = loadObject.economy.cargoSold.slice();
|
||||
G.economy.cargoBought = loadObject.economy.cargoBought.slice();
|
||||
|
||||
for (var i = 0; i < loadObject.map.length; i++) {
|
||||
G.map[i].drawX = loadObject.map[i].drawX;
|
||||
G.map[i].drawY = loadObject.map[i].drawY;
|
||||
G.map[i].drawWidth = loadObject.map[i].drawWidth;
|
||||
G.map[i].drawHeight = loadObject.map[i].drawHeight;
|
||||
G.map[i].island.x = rm_Ocean.squareSize * loadObject.map[i].drawX;
|
||||
G.map[i].island.y = rm_Ocean.squareSize * loadObject.map[i].drawY;
|
||||
G.map[i].island.inventory = loadObject.map[i].inventory.slice();
|
||||
G.map[i].island.innPriceDifference = loadObject.map[i].innPriceDifference;
|
||||
G.map[i].island.innStays = loadObject.map[i].innStays;
|
||||
G.map[i].island.priceDifferences = loadObject.map[i].priceDifferences.slice();
|
||||
G.map[i].island.itemsSold = loadObject.map[i].itemsSold.slice();
|
||||
G.map[i].island.itemsBought = loadObject.map[i].itemsBought.slice();
|
||||
}
|
||||
loadObject = null;
|
||||
console.log("Game Loaded!");
|
||||
} else {
|
||||
console.log("Could not load game!");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
function loadGameManager () {
|
||||
for (var i = 0; i < G.economy.cargoItemWorth.length; i++) {
|
||||
G.economy.cargoItemWorth[i] += Math.round(Math.randomRange(-5, 5));
|
||||
}
|
||||
|
||||
if (Oversimplified.DEBUG.showMessages) console.log("Ran loadGameManager()");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,32 @@
|
|||
var prefabsLoaded = 0;
|
||||
var prefabsToLoad = 4;
|
||||
function loadPrefabs() {
|
||||
OS.AddScript("prefabs/shipPrefab.js");
|
||||
OS.AddScript("prefabs/islandPrefab.js");
|
||||
OS.AddScript("prefabs/oceanTilePrefab.js");
|
||||
OS.AddScript("prefabs/wavePrefab.js");
|
||||
OS.AddScript("prefabs/shipPrefab.js");
|
||||
OS.AddScript("prefabs/islandPrefab.js");
|
||||
OS.AddScript("prefabs/oceanTilePrefab.js");
|
||||
OS.AddScript("prefabs/wavePrefab.js");
|
||||
|
||||
// Delay switching to Ocean room until everything is loaded.
|
||||
WaitForPrefabsToLoad();
|
||||
|
||||
if (Oversimplified.DEBUG.showMessages) console.log("Ran loadPrefabs()");
|
||||
}
|
||||
|
||||
// Callback function that prevents Ocean room from loading before everything it references is loaded.
|
||||
WaitForPrefabsToLoad = function () {
|
||||
console.log("waiting for " + (prefabsToLoad - prefabsLoaded).toString() + " prefabs to load");
|
||||
if (prefabsLoaded < prefabsToLoad || !window["oceanRoom"]) {
|
||||
setTimeout(function(){WaitForPrefabsToLoad()}, 0.1);
|
||||
} else {
|
||||
// Create player and ocean objects in rm_Ocean.
|
||||
G.player = rm_Ocean.AddObject(OS.P["Ship"]);
|
||||
G.oceanParticle = rm_Ocean.AddObject(OS.P["Ocean Particle"]);
|
||||
|
||||
if (G.player.xBound) { // Force rm_Ocean to wait until G.player is completely loaded!
|
||||
// Load the rooms only after the prefabs are loaded.
|
||||
rm_Ocean.SetAsCurrentRoom();
|
||||
} else {
|
||||
setTimeout(function(){WaitForPrefabsToLoad()}, 0.1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
27
loadRooms.js
|
|
@ -1,15 +1,20 @@
|
|||
// var rm_TitleScreen = OS.R.Add("Default");
|
||||
// var rm_Ocean = OS.R.Add("Ocean", {
|
||||
var rm_Ocean = OS.R.Add("Default", {
|
||||
width: pixel(64) * 50, //50x45 map of 64x64 squares. This will allow a single pixel on the map to represent a 64x square and fit comfortably on screen.
|
||||
height: pixel(64) * 44,
|
||||
backgroundColor: "#1b2632"
|
||||
var rm_Load = OS.R.Add("Default");
|
||||
var rm_Ocean = OS.R.Add("Ocean Room", {
|
||||
// Putting my room "constants" here.
|
||||
width: pixel(64) * 50, //50x45 map of 64x64 squares. This will allow a single pixel on the map to represent a 64x square and fit comfortably on screen.
|
||||
height: pixel(64) * 44,
|
||||
backgroundColor: "#1b2632",
|
||||
squaresX: 50,
|
||||
squaresY: 44,
|
||||
squareSize: pixel(64),
|
||||
numberOfIslands: 10,
|
||||
clockTimerCutoff: ((1 / OS.S.defaultStep) * 60) * 5, // 5 minute day.
|
||||
});
|
||||
|
||||
function loadRooms() {
|
||||
// OS.AddScript("rooms/titleScreen.js");
|
||||
OS.AddScript("rooms/oceanRoom.js");
|
||||
|
||||
// OS.SetRoom(rm_TitleScreen);
|
||||
OS.SetRoom(rm_Ocean);
|
||||
OS.AddScript("rooms/oceanRoom.js");
|
||||
|
||||
rm_Load.SetAsCurrentRoom();
|
||||
|
||||
if (Oversimplified.DEBUG.showMessages) console.log("Ran loadRooms()");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,132 +1,243 @@
|
|||
var ani_island_1 = OS.A.Add("Island 1", 256, 256, {});
|
||||
|
||||
function islandPrefab() {}
|
||||
function islandPrefab() {
|
||||
if (Oversimplified.DEBUG.showMessages) console.log("Ran islandPrefab()");
|
||||
prefabsLoaded++;
|
||||
}
|
||||
|
||||
var pr_island = OS.P.Add("Island", {
|
||||
solid: true,
|
||||
imageSrc: "images/island.png",
|
||||
animations: [ani_island_1],
|
||||
solid: true,
|
||||
imageSrc: "images/island.png",
|
||||
animations: [ani_island_1],
|
||||
depth: -50,
|
||||
|
||||
mapX: 0,
|
||||
mapY: 0,
|
||||
mapWidth: 1,
|
||||
mapHeight: 1,
|
||||
mapColor: "#00AB00",
|
||||
mapX: 0,
|
||||
mapY: 0,
|
||||
mapWidth: 1,
|
||||
mapHeight: 1,
|
||||
mapColor: "#00AB00",
|
||||
|
||||
canTrade: true,
|
||||
haggleAmount: 0,
|
||||
timesHaggledToday: 0,
|
||||
canTrade: true,
|
||||
haggleAmount: 0,
|
||||
timesHaggledToday: 0,
|
||||
itemsSoldToday: [0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0],
|
||||
itemsBoughtToday: [0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0],
|
||||
|
||||
money: 0,
|
||||
inventory: [0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0],
|
||||
|
||||
storageSpace: [0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0],
|
||||
innPriceDifference: 0,
|
||||
innStays: 0,
|
||||
priceDifferences: [0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0],
|
||||
itemsSold: [0, 0, 0, 0, // The more you sell, the lower the price gets
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0],
|
||||
itemsBought: [0, 0, 0, 0, // The more you buy, the higher the price gets
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0],
|
||||
|
||||
inventory: [0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0],
|
||||
priceDifferences: [],
|
||||
itemsSold: [0, 0, 0, 0, // The more you sell, the lower the price gets
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0],
|
||||
itemsBought: [0, 0, 0, 0, // The more you buy, the higher the price gets
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0]
|
||||
storageFee: 10,
|
||||
storageFeeMultiplier: 0.1,
|
||||
storage: [0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0],
|
||||
});
|
||||
|
||||
pr_island.DoFirst = function () {
|
||||
this.GetMapPosition();
|
||||
this.SetUp();
|
||||
this.GetMapPosition();
|
||||
this.SetUp();
|
||||
}
|
||||
|
||||
pr_island.GetMapPosition = function () {
|
||||
this.mapX = (this.x / OS.S.pixelScale) / (OS.camera.width / OS.S.pixelScale);
|
||||
this.mapY = (this.y / OS.S.pixelScale) / (OS.camera.height / OS.S.pixelScale);
|
||||
this.mapX = (this.x / OS.S.pixelScale) / (OS.camera.width / OS.S.pixelScale);
|
||||
this.mapY = (this.y / OS.S.pixelScale) / (OS.camera.height / OS.S.pixelScale);
|
||||
}
|
||||
|
||||
pr_island.SetUp = function () {
|
||||
for (var i = 0; i < 16; i++) {
|
||||
if (Math.randomRange(0, 100) < 25) {
|
||||
this.inventory[i] = Math.round(Math.randomRange(0, 20));
|
||||
}
|
||||
}
|
||||
// console.log(this.name + " stock: " + this.inventory);
|
||||
for (var i = 0; i < 16; i++) {
|
||||
this.storageSpace[i] = Math.round(Math.randomRange(20, 35));
|
||||
|
||||
this.AdjustPrices();
|
||||
// console.log(this.name + " pricing: " + this.priceDifferences);
|
||||
if (this.storageSpace[i] > 30) {
|
||||
this.inventory[i] = Math.round(this.storageSpace[i] - Math.randomRange(0, 30));
|
||||
} else if (Math.randomRange(0, 100) < 25) {
|
||||
this.inventory[i] = Math.round(Math.randomRange(0, this.storageSpace[i]));
|
||||
}
|
||||
}
|
||||
// console.log(this.name + " stock: " + this.inventory);
|
||||
|
||||
if (this.CheckInventory().length < 4) {
|
||||
this.SetUp();
|
||||
}
|
||||
this.AdjustPrices();
|
||||
// console.log(this.name + " pricing: " + this.priceDifferences);
|
||||
|
||||
if (this.CheckInventory().length < 4) {
|
||||
this.SetUp();
|
||||
} else {
|
||||
for (var i = 0; i < 16; i++) {
|
||||
// Generate the amount of money the shop has based on what it has.
|
||||
this.money += (G.economy.cargoItemWorth[i] + this.priceDifferences[i]) * this.inventory[i];
|
||||
}
|
||||
|
||||
// Minimum amount of money is 100.
|
||||
if (this.money < 100) this.money = 100;
|
||||
}
|
||||
}
|
||||
|
||||
pr_island.AdjustPrices = function () {
|
||||
for (var i = 0; i < 16; i++) {
|
||||
if (this.inventory[i] > 10) {
|
||||
this.priceDifferences[i] = -Math.round(this.inventory[i] * Math.randomRange(1, 3));
|
||||
} else if (this.inventory[i] < 5) {
|
||||
this.priceDifferences[i] = Math.round((10 - this.inventory[i]) * Math.randomRange(1, 3));
|
||||
} else {
|
||||
this.priceDifferences[i] = Math.round(Math.randomRange(-2, 2));
|
||||
}
|
||||
for (var i = 0; i < 16; i++) {
|
||||
// Save the previous price difference so the change doesn't get above a certain thereshold.
|
||||
var previousPrice = newPriceDifference = this.priceDifferences[i];
|
||||
|
||||
if (G.economy.cargoItemWorth[i] + this.priceDifferences[i] < 0) {
|
||||
this.priceDifferences[i] = -G.economy.cargoItemWorth[i] + 1;
|
||||
}
|
||||
}
|
||||
if (this.inventory[i] > (this.storageSpace[i] / 2)) {
|
||||
newPriceDifference -= Math.round(this.inventory[i] * Math.randomRange(1, 3));
|
||||
}
|
||||
else if (this.inventory[i] < (this.storageSpace[i] / 4)) {
|
||||
newPriceDifference += Math.round((this.storageSpace[i] - this.inventory[i]) * Math.randomRange(1, 3));
|
||||
}
|
||||
else {
|
||||
newPriceDifference += Math.round(Math.randomRange(-2, 2));
|
||||
}
|
||||
|
||||
newPriceDifference = Math.round(newPriceDifference * ((this.itemsBought[i] + 1) / (this.itemsSold[i] + 1)));
|
||||
|
||||
if (Math.abs(newPriceDifference) > Math.abs(previousPrice) + G.economy.maxPriceChange) {
|
||||
// Prevent price from changing more than the limit.
|
||||
newPriceDifference = previousPrice + ((previousPrice < 0) ? -G.economy.maxPriceChange : G.economy.maxPriceChange);
|
||||
}
|
||||
|
||||
if (G.economy.cargoItemWorth[i] + newPriceDifference < 0) {
|
||||
newPriceDifference = -G.economy.cargoItemWorth[i] + 1;
|
||||
}
|
||||
|
||||
this.priceDifferences[i] = newPriceDifference;
|
||||
}
|
||||
|
||||
var priceDifferencesOrdered = this.priceDifferences.slice().sort(sortNumber);
|
||||
this.innPriceDifference += Math.round(Math.randomRange(priceDifferencesOrdered[0], priceDifferencesOrdered[priceDifferencesOrdered.length -1])) - Math.round(Math.randomRange(0, this.innStays));
|
||||
}
|
||||
|
||||
pr_island.SimulateTrade = function () {
|
||||
// This will be run on a timer that runs when not trading.
|
||||
for (var i = 0; i < 16; i++) {
|
||||
if (this.inventory[i] > 0) {
|
||||
this.inventory[i] += Math.round(Math.randomRange(-5, 5));
|
||||
if (this.inventory[i] < 0) {
|
||||
this.inventory[i] = 0;
|
||||
}
|
||||
} else {
|
||||
if (Math.randomRange(0, 100) < 15) {
|
||||
this.inventory[i] = Math.round(Math.randomRange(0, 5));
|
||||
}
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < 16; i++) {
|
||||
var amount = 0;
|
||||
if (this.inventory[i] > 0) {
|
||||
amount = Math.round(Math.randomRange(-this.storageSpace[i], this.storageSpace[i]));
|
||||
this.inventory[i] += amount;
|
||||
|
||||
this.AdjustPrices();
|
||||
if (this.inventory[i] < 0) {
|
||||
this.inventory[i] = 0;
|
||||
}
|
||||
if (this.inventory[i] > this.storageSpace[i]) {
|
||||
this.inventory[i] = this.storageSpace[i];
|
||||
}
|
||||
} else {
|
||||
if (Math.randomRange(0, 100) < 15) {
|
||||
amount = Math.round(Math.randomRange(0, this.storageSpace[i]));
|
||||
this.inventory[i] = amount;
|
||||
}
|
||||
}
|
||||
// If the amount is positive, then subtract half the amount from the money (because they bought stuff)
|
||||
// Otherwise, add the negative amount (because they sold that much)
|
||||
this.money += (-amount * (G.economy.cargoItemWorth[i] + this.priceDifferences[i])) * ((amount > 0) ? 0.5 : 1);
|
||||
}
|
||||
|
||||
if (this.money <= 0) this.money = 100; // If they run out of money, give them some.
|
||||
|
||||
this.AdjustPrices();
|
||||
}
|
||||
|
||||
pr_island.CheckInventory = function () { // Returns an array of indices that have cargo
|
||||
var indicesWithCargo = [];
|
||||
for (var i = 0; i < this.inventory.length; i++) {
|
||||
if (this.inventory[i] > 0) {
|
||||
indicesWithCargo.push(i);
|
||||
}
|
||||
}
|
||||
return indicesWithCargo;
|
||||
pr_island.NewDay = function () {
|
||||
this.haggleAmount = 0;
|
||||
this.timesHaggledToday = 0;
|
||||
this.itemsSoldToday = [0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0];
|
||||
this.itemsBoughtToday = [0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0];
|
||||
this.SimulateTrade();
|
||||
}
|
||||
|
||||
pr_island.CheckInventory = function () { // Returns an array of indices that have cargo
|
||||
var indicesWithCargo = [];
|
||||
for (var i = 0; i < this.inventory.length; i++) {
|
||||
if (this.inventory[i] > 0) {
|
||||
indicesWithCargo.push(i);
|
||||
}
|
||||
}
|
||||
return indicesWithCargo;
|
||||
}
|
||||
|
||||
pr_island.TradeWith = function () {
|
||||
// Change music to Trade.
|
||||
// console.log(this.inventory);
|
||||
guiControl.trade.island = this;
|
||||
guiControl.trade.haggleAmount = 0;
|
||||
guiControl.trade.activateDelay = 5;
|
||||
guiControl.trade.show = true;
|
||||
// Change music to Trade.
|
||||
// console.log(this.inventory);
|
||||
mus_sail.Stop();
|
||||
mus_trade.Play();
|
||||
guiControl.trade.island = this;
|
||||
guiControl.trade.haggleAmount = 0;
|
||||
guiControl.trade.activateDelay = 5;
|
||||
guiControl.trade.show = true;
|
||||
}
|
||||
|
||||
pr_island.CanSellTo = function (itemIndex, price) {
|
||||
if (this.inventory[itemIndex] < this.storageSpace[itemIndex] && price < this.money) {
|
||||
// If there's space in the inventory and there's enough money.
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
pr_island.SellTo = function (itemIndex, price) {
|
||||
// Play Buy sound.
|
||||
this.inventory[itemIndex]++;
|
||||
this.itemsBought[itemIndex]++;
|
||||
// Play Buy sound.
|
||||
this.inventory[itemIndex]++;
|
||||
this.itemsBought[itemIndex]++;
|
||||
this.money -= price;
|
||||
|
||||
G.inventory.cargo[itemIndex]--;
|
||||
G.inventory.money += price;
|
||||
G.economy.cargoSold[itemIndex]++;
|
||||
G.inventory.cargo[itemIndex]--;
|
||||
G.inventory.money += price;
|
||||
G.economy.cargoSold[itemIndex]++;
|
||||
}
|
||||
|
||||
pr_island.CanBuyFrom = function (itemIndex, price) {
|
||||
if (this.inventory[itemIndex] > 0) { // If there's enough of the item
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
pr_island.BuyFrom = function (itemIndex, price) {
|
||||
// Play Sell sound.
|
||||
this.inventory[itemIndex]--;
|
||||
this.itemsBought[itemIndex]++;
|
||||
// Play Sell sound.
|
||||
this.inventory[itemIndex]--;
|
||||
this.itemsSold[itemIndex]++;
|
||||
this.money += price;
|
||||
|
||||
G.inventory.cargo[itemIndex]++;
|
||||
G.inventory.money -= price;
|
||||
G.economy.cargoBought[itemIndex]++;
|
||||
G.inventory.cargo[itemIndex]++;
|
||||
G.inventory.money -= price;
|
||||
G.economy.cargoBought[itemIndex]++;
|
||||
}
|
||||
|
||||
pr_island.StayAtInn = function () {
|
||||
// Play Sell sound.
|
||||
this.innStays++;
|
||||
|
||||
G.stats.illness--;
|
||||
G.inventory.money -= G.economy.innCost + this.innPriceDifference;
|
||||
G.economy.innStays++;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,81 +1,93 @@
|
|||
var ani_ocean = OS.A.Add("Ocean", 256, 256, {columns: 10, speed: 1/60});
|
||||
var ani_ocean = OS.A.Add("Ocean", 256, 256, { columns: 10, speed: 1/60 });
|
||||
|
||||
function oceanTilePrefab() {}
|
||||
function oceanTilePrefab() {
|
||||
if (Oversimplified.DEBUG.showMessages) console.log("Ran oceanTilePrefab()");
|
||||
prefabsLoaded++;
|
||||
}
|
||||
|
||||
var pr_ocean = OS.P.Add("Ocean Particle", {
|
||||
imageSrc: "images/ocean_sheet.png",
|
||||
animations: [ani_ocean],
|
||||
depth: -100, // Draw below everything.
|
||||
imageSrc: "images/ocean_sheet.png",
|
||||
animations: [ani_ocean],
|
||||
depth: -100, // Draw below everything.
|
||||
|
||||
positionCheckStep: 30,
|
||||
positionCheckProgress: 30,
|
||||
doCheckPosition: false,
|
||||
positionCheckStep: 30,
|
||||
positionCheckProgress: 30,
|
||||
doCheckPosition: false,
|
||||
|
||||
moveTimer: 0,
|
||||
moveTimer: 0,
|
||||
});
|
||||
|
||||
pr_ocean.BeforeDo = function () {
|
||||
this.positionCheckProgress++;
|
||||
if (this.positionCheckProgress >= this.positionCheckStep) {
|
||||
this.positionCheckProgress = 0;
|
||||
this.doCheckPosition = true;
|
||||
}
|
||||
this.positionCheckProgress++;
|
||||
if (this.positionCheckProgress >= this.positionCheckStep) {
|
||||
this.positionCheckProgress = 0;
|
||||
this.doCheckPosition = true;
|
||||
}
|
||||
}
|
||||
pr_ocean.Do = function () {
|
||||
// Move around randomly.
|
||||
this.moveTimer++;
|
||||
if (this.moveTimer >= 120) {
|
||||
this.x += 1 * pixel(Math.round(Math.randomRange(-1, 1)));
|
||||
this.y += 1 * pixel(Math.round(Math.randomRange(-1, 1)));
|
||||
this.moveTimer = 0;
|
||||
}
|
||||
// Move around randomly.
|
||||
this.moveTimer++;
|
||||
if (this.moveTimer >= 120) {
|
||||
this.x += 1 * pixel(Math.round(Math.randomRange(-1, 1)));
|
||||
this.y += 1 * pixel(Math.round(Math.randomRange(-1, 1)));
|
||||
this.moveTimer = 0;
|
||||
}
|
||||
}
|
||||
|
||||
pr_ocean.CheckPosition = function (checkX, checkY, direction) {
|
||||
if (this.doCheckPosition) {
|
||||
// If it's completely off the screen, then update position.
|
||||
if ((Math.abs(this.x - checkX) > (OS.camera.width + this.xBound)) ||
|
||||
(Math.abs(this.y - checkY) > (OS.camera.height + this.yBound)))
|
||||
{
|
||||
switch (direction) {
|
||||
case 0:
|
||||
this.x = checkX + (OS.camera.width + this.xBound) + randomSmidge();
|
||||
this.y = checkY + randomSmidge();
|
||||
if (this.doCheckPosition) {
|
||||
// If it's completely off the screen, then update position.
|
||||
if ((Math.abs(this.x - checkX) > (OS.camera.width + this.xBound)) ||
|
||||
(Math.abs(this.y - checkY) > (OS.camera.height + this.yBound)))
|
||||
{
|
||||
switch (direction) {
|
||||
case 0: {
|
||||
this.x = checkX + (OS.camera.width + this.xBound) + randomSmidge();
|
||||
this.y = checkY + randomSmidge();
|
||||
break;
|
||||
case 45:
|
||||
this.x = checkX + (OS.camera.width + this.xBound) + randomSmidge();
|
||||
this.y = checkY - (OS.camera.height + this.yBound) + randomSmidge();
|
||||
}
|
||||
case 45: {
|
||||
this.x = checkX + (OS.camera.width + this.xBound) + randomSmidge();
|
||||
this.y = checkY - (OS.camera.height + this.yBound) + randomSmidge();
|
||||
break;
|
||||
case 90:
|
||||
this.x = checkX + randomSmidge();
|
||||
this.y = checkY - (OS.camera.height + this.yBound) + randomSmidge();
|
||||
}
|
||||
case 90: {
|
||||
this.x = checkX + randomSmidge();
|
||||
this.y = checkY - (OS.camera.height + this.yBound) + randomSmidge();
|
||||
break;
|
||||
case 135:
|
||||
this.x = checkX - (OS.camera.width + this.xBound) + randomSmidge();
|
||||
this.y = checkY - (OS.camera.height + this.yBound) + randomSmidge();
|
||||
}
|
||||
case 135: {
|
||||
this.x = checkX - (OS.camera.width + this.xBound) + randomSmidge();
|
||||
this.y = checkY - (OS.camera.height + this.yBound) + randomSmidge();
|
||||
break;
|
||||
case 180:
|
||||
this.x = checkX - (OS.camera.width + this.xBound) + randomSmidge();
|
||||
this.y = checkY + randomSmidge();
|
||||
}
|
||||
case 180: {
|
||||
this.x = checkX - (OS.camera.width + this.xBound) + randomSmidge();
|
||||
this.y = checkY + randomSmidge();
|
||||
break;
|
||||
case 225:
|
||||
this.x = checkX - (OS.camera.width + this.xBound) + randomSmidge();
|
||||
this.y = checkY + (OS.camera.height + this.yBound) + randomSmidge();
|
||||
}
|
||||
case 225: {
|
||||
this.x = checkX - (OS.camera.width + this.xBound) + randomSmidge();
|
||||
this.y = checkY + (OS.camera.height + this.yBound) + randomSmidge();
|
||||
break;
|
||||
case 270:
|
||||
this.x = checkX + randomSmidge();
|
||||
this.y = checkY + (OS.camera.height + this.yBound) + randomSmidge();
|
||||
}
|
||||
case 270: {
|
||||
this.x = checkX + randomSmidge();
|
||||
this.y = checkY + (OS.camera.height + this.yBound) + randomSmidge();
|
||||
break;
|
||||
case 315:
|
||||
this.x = checkX + (OS.camera.width + this.xBound) + randomSmidge();
|
||||
this.y = checkY + (OS.camera.height + this.yBound) + randomSmidge();
|
||||
}
|
||||
case 315: {
|
||||
this.x = checkX + (OS.camera.width + this.xBound) + randomSmidge();
|
||||
this.y = checkY + (OS.camera.height + this.yBound) + randomSmidge();
|
||||
break;
|
||||
default:
|
||||
console.log("No valid direction");
|
||||
}
|
||||
default: {
|
||||
console.log("No valid direction");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.doCheckPosition = false;
|
||||
}
|
||||
this.doCheckPosition = false;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,191 +7,234 @@ var ani_ship_dl = OS.A.Add("Ship Down-Left", 64, 64, {columns: 2, speed: 1/60, y
|
|||
var ani_ship_d = OS.A.Add("Ship Down", 64, 64, {columns: 2, speed: 1/60, yOffset: 64 * 0});
|
||||
var ani_ship_dr = OS.A.Add("Ship Down-Right", 64, 64, {columns: 2, speed: 1/60, yOffset: 64 * 2});
|
||||
|
||||
function shipPrefab() {}
|
||||
function shipPrefab() {
|
||||
if (Oversimplified.DEBUG.showMessages) console.log("Ran shipPrefab()");
|
||||
prefabsLoaded++;
|
||||
}
|
||||
|
||||
var pr_ship = OS.P.Add("Ship", {
|
||||
solid: true,
|
||||
imageSrc: "images/ship_sheet.png",
|
||||
maskImageSrc: "images/ship_mask.png",
|
||||
animations: [ani_ship_r, ani_ship_ur, ani_ship_u, ani_ship_ul, ani_ship_l, ani_ship_dl, ani_ship_d, ani_ship_dr],
|
||||
|
||||
direction: 0,
|
||||
currentSpeed: 0,
|
||||
pointInFront : {x: 0, y: 0 },
|
||||
moveStepSize: 3,
|
||||
moveStepAmount: 5 * Oversimplified.R[Oversimplified.R.currentRoom].stepSpeed,
|
||||
moveStepProgress: 0,
|
||||
doTakeStep: false,
|
||||
solid: true,
|
||||
imageSrc: "images/ship_sheet.png",
|
||||
maskImageSrc: "images/ship_mask.png",
|
||||
animations: [ani_ship_r, ani_ship_ur, ani_ship_u, ani_ship_ul, ani_ship_l, ani_ship_dl, ani_ship_d, ani_ship_dr],
|
||||
|
||||
direction: 0,
|
||||
currentSpeed: 0,
|
||||
pointInFront : {x: 0, y: 0 },
|
||||
moveStepSize: 3,
|
||||
moveStepAmount: 5 * OS.R[OS.R.currentRoom].stepSpeed,
|
||||
moveStepProgress: 0,
|
||||
doTakeStep: false,
|
||||
|
||||
energyRefillTimer: 0
|
||||
energyRefillTimer: 0,
|
||||
|
||||
drawSickIndicator: 0,
|
||||
drawSickIndicatorTime: secondsWorthOfFrames(1.5),
|
||||
});
|
||||
|
||||
pr_ship.BeforeDo = function () {
|
||||
this.GetMapPosition();
|
||||
if (G.gameStarted) {
|
||||
this.GetMapPosition();
|
||||
}
|
||||
}
|
||||
|
||||
pr_ship.Do = function () {
|
||||
if (guiControl && guiControl.inventory && guiControl.map && guiControl.trade) { // Force it to wait until loaded.
|
||||
if (!guiControl.inventory.show && !guiControl.map.show && !guiControl.trade.show) {
|
||||
if (ct_left().down) {
|
||||
this.direction += 45;
|
||||
} else if (ct_right().down) {
|
||||
this.direction -= 45;
|
||||
}
|
||||
this.direction = Math.clampAngle(this.direction);
|
||||
|
||||
if (ct_up().down) {
|
||||
this.currentSpeed++;
|
||||
} else if (ct_down().down) {
|
||||
this.currentSpeed--;
|
||||
}
|
||||
this.AdjustSpeedBasedOnEnergy();
|
||||
if (G.gameStarted) {
|
||||
if (guiControl && guiControl.inventory && guiControl.map && guiControl.trade) { // Force it to wait until loaded.
|
||||
if (!guiControl.inventory.show && !guiControl.map.show && !guiControl.trade.show) {
|
||||
if (ct_left().down) {
|
||||
this.direction += 45;
|
||||
} else if (ct_right().down) {
|
||||
this.direction -= 45;
|
||||
}
|
||||
this.direction = Math.clampAngle(this.direction);
|
||||
|
||||
if (ct_up().down) {
|
||||
this.currentSpeed++;
|
||||
} else if (ct_down().down) {
|
||||
this.currentSpeed--;
|
||||
}
|
||||
this.AdjustSpeedBasedOnEnergy();
|
||||
|
||||
this.CheckInteraction();
|
||||
}
|
||||
}
|
||||
this.CheckInteraction();
|
||||
}
|
||||
}
|
||||
|
||||
this.currentSpeed = Math.clamp(this.currentSpeed, 0, 4);
|
||||
|
||||
this.moveStepProgress += this.currentSpeed * this.moveStepAmount;
|
||||
if (this.moveStepProgress >= this.moveStepSize) {
|
||||
this.moveStepProgress -= this.moveStepSize;
|
||||
this.doTakeStep = true;
|
||||
} else {
|
||||
this.doTakeStep = false;
|
||||
}
|
||||
this.currentSpeed = Math.clamp(this.currentSpeed, 0, 4);
|
||||
|
||||
this.moveStepProgress += this.currentSpeed * this.moveStepAmount;
|
||||
if (this.moveStepProgress >= this.moveStepSize) {
|
||||
this.moveStepProgress -= this.moveStepSize;
|
||||
this.doTakeStep = true;
|
||||
} else {
|
||||
this.doTakeStep = false;
|
||||
}
|
||||
|
||||
|
||||
this.SeamlessScroll();
|
||||
// console.log(G.player.name + " created at " + G.player.x + ", " + G.player.y);
|
||||
this.SeamlessScroll();
|
||||
// console.log(G.player.name + " created at " + G.player.x + ", " + G.player.y);
|
||||
}
|
||||
}
|
||||
|
||||
pr_ship.AfterDo = function () {
|
||||
this.CheckMovement();
|
||||
this.UpdateEnergy();
|
||||
if (G.gameStarted) {
|
||||
this.CheckMovement();
|
||||
this.UpdateEnergy();
|
||||
}
|
||||
}
|
||||
|
||||
pr_ship.DrawAbove = function () {
|
||||
if (G.gameStarted) {
|
||||
this.drawSickIndicator--;
|
||||
if (this.drawSickIndicator < 0) {
|
||||
this.drawSickIndicator = 0;
|
||||
}
|
||||
if (this.drawSickIndicator > 0) {
|
||||
var sickIndicatorHeight = Math.round((this.drawSickIndicatorTime - this.drawSickIndicator) / 2) / OS.S.pixelScale;
|
||||
var sickIndicatorY = this.y - sickIndicatorHeight - Oversimplified.camera.y - (guiControl.iconScaled / 2);
|
||||
guiControl.drawIcon(4, 1, this.x - Oversimplified.camera.x - (guiControl.iconScaled / 2), sickIndicatorY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pr_ship.GetMapPosition = function () {
|
||||
this.mapX = pixel(Math.round(this.x / pixel(64)));
|
||||
this.mapY = pixel(Math.round(this.y / pixel(64)));
|
||||
console.log(this.mapX + ", " + this.mapY);
|
||||
this.mapX = pixel(Math.round(this.x / pixel(64)));
|
||||
this.mapY = pixel(Math.round(this.y / pixel(64)));
|
||||
// console.log(this.mapX + ", " + this.mapY);
|
||||
}
|
||||
|
||||
pr_ship.CheckInteraction = function () {
|
||||
if (ct_confirm().down) {
|
||||
var objectsFound = OS.GameObjectsAtPoint(this.pointInFront.x, this.pointInFront.y);
|
||||
if (objectsFound.length > 0) {
|
||||
for (var i = 0; i < objectsFound.length; i++) {
|
||||
if (objectsFound[i].canTrade) {
|
||||
// console.log("interacting with island: " + objectsFound[i].name);
|
||||
objectsFound[i].TradeWith();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (ct_confirm().down) {
|
||||
var objectsFound = OS.GameObjectsAtPoint(this.pointInFront.x, this.pointInFront.y);
|
||||
if (objectsFound.length > 0) {
|
||||
for (var i = 0; i < objectsFound.length; i++) {
|
||||
if (objectsFound[i].canTrade) {
|
||||
// console.log("interacting with island: " + objectsFound[i].name);
|
||||
objectsFound[i].TradeWith();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pr_ship.CheckMovement = function () {
|
||||
var moveAmount = pixel(G.stats.speed + this.currentSpeed);
|
||||
var movedSuccessfully = false;
|
||||
switch (this.direction) {
|
||||
case 0:
|
||||
if (this.image.currentAnimation != "Ship Right") this.SetAnimation("Ship Right");
|
||||
if (this.doTakeStep) movedSuccessfully = this.SimpleMove(moveAmount, 0, true, pixel(4));
|
||||
this.pointInFront.x = this.x + this.xBound + pixel(2) + moveAmount;
|
||||
this.pointInFront.y = this.y;
|
||||
break;
|
||||
case 45:
|
||||
if (this.image.currentAnimation != "Ship Up-Right") this.SetAnimation("Ship Up-Right");
|
||||
if (this.doTakeStep) movedSuccessfully = this.SimpleMove(moveAmount, -moveAmount, true, pixel(4));
|
||||
this.pointInFront.x = this.x + this.xBound + pixel(2) + moveAmount;
|
||||
this.pointInFront.y = this.y - this.yBound - pixel(2) - moveAmount;
|
||||
break;
|
||||
case 90:
|
||||
if (this.image.currentAnimation != "Ship Up") this.SetAnimation("Ship Up");
|
||||
if (this.doTakeStep) movedSuccessfully = this.SimpleMove(0, -moveAmount, true, pixel(4));
|
||||
this.pointInFront.x = this.x;
|
||||
this.pointInFront.y = this.y - this.yBound - pixel(2) - moveAmount;
|
||||
break;
|
||||
case 135:
|
||||
if (this.image.currentAnimation != "Ship Up-Left") this.SetAnimation("Ship Up-Left");
|
||||
if (this.doTakeStep) movedSuccessfully = this.SimpleMove(-moveAmount, -moveAmount, true, pixel(4));
|
||||
this.pointInFront.x = this.x - this.xBound - pixel(2) - moveAmount;
|
||||
this.pointInFront.y = this.y - this.yBound - pixel(2) - moveAmount;
|
||||
break;
|
||||
case 180:
|
||||
if (this.image.currentAnimation != "Ship Left") this.SetAnimation("Ship Left");
|
||||
if (this.doTakeStep) movedSuccessfully = this.SimpleMove(-moveAmount, 0, true, pixel(4));
|
||||
this.pointInFront.x = this.x - this.xBound - pixel(2) - moveAmount;
|
||||
this.pointInFront.y = this.y;
|
||||
break;
|
||||
case 225:
|
||||
if (this.image.currentAnimation != "Ship Down-Left") this.SetAnimation("Ship Down-Left");
|
||||
if (this.doTakeStep) movedSuccessfully = this.SimpleMove(-moveAmount, moveAmount, true, pixel(4));
|
||||
this.pointInFront.x = this.x - this.xBound - pixel(2) - moveAmount;
|
||||
this.pointInFront.y = this.y + this.yBound + pixel(2) + moveAmount;
|
||||
break;
|
||||
case 270:
|
||||
if (this.image.currentAnimation != "Ship Down") this.SetAnimation("Ship Down");
|
||||
if (this.doTakeStep) movedSuccessfully = this.SimpleMove(0, moveAmount, true, pixel(4));
|
||||
this.pointInFront.x = this.x;
|
||||
this.pointInFront.y = this.y + this.yBound + pixel(2) + moveAmount;
|
||||
break;
|
||||
case 315:
|
||||
if (this.image.currentAnimation != "Ship Down-Right") this.SetAnimation("Ship Down-Right");
|
||||
if (this.doTakeStep) movedSuccessfully = this.SimpleMove(moveAmount, moveAmount, true, pixel(4));
|
||||
this.pointInFront.x = this.x + this.xBound + pixel(2) + moveAmount;
|
||||
this.pointInFront.y = this.y + this.yBound + pixel(2) + moveAmount;
|
||||
break;
|
||||
default:
|
||||
console.log("No valid direction");
|
||||
break;
|
||||
}
|
||||
var moveAmount = pixel(G.stats.speed + this.currentSpeed);
|
||||
var movedSuccessfully = false;
|
||||
switch (this.direction) {
|
||||
case 0: {
|
||||
if (this.sprite.currentAnimation != "Ship Right") this.SetAnimation("Ship Right");
|
||||
if (this.doTakeStep) movedSuccessfully = this.SimpleMove(moveAmount, 0, true, pixel(4));
|
||||
this.pointInFront.x = this.x + this.xBound + pixel(2) + moveAmount;
|
||||
this.pointInFront.y = this.y;
|
||||
break;
|
||||
}
|
||||
case 45: {
|
||||
if (this.sprite.currentAnimation != "Ship Up-Right") this.SetAnimation("Ship Up-Right");
|
||||
if (this.doTakeStep) movedSuccessfully = this.SimpleMove(moveAmount, -moveAmount, true, pixel(4));
|
||||
this.pointInFront.x = this.x + this.xBound + pixel(2) + moveAmount;
|
||||
this.pointInFront.y = this.y - this.yBound - pixel(2) - moveAmount;
|
||||
break;
|
||||
}
|
||||
case 90: {
|
||||
if (this.sprite.currentAnimation != "Ship Up") this.SetAnimation("Ship Up");
|
||||
if (this.doTakeStep) movedSuccessfully = this.SimpleMove(0, -moveAmount, true, pixel(4));
|
||||
this.pointInFront.x = this.x;
|
||||
this.pointInFront.y = this.y - this.yBound - pixel(2) - moveAmount;
|
||||
break;
|
||||
}
|
||||
case 135: {
|
||||
if (this.sprite.currentAnimation != "Ship Up-Left") this.SetAnimation("Ship Up-Left");
|
||||
if (this.doTakeStep) movedSuccessfully = this.SimpleMove(-moveAmount, -moveAmount, true, pixel(4));
|
||||
this.pointInFront.x = this.x - this.xBound - pixel(2) - moveAmount;
|
||||
this.pointInFront.y = this.y - this.yBound - pixel(2) - moveAmount;
|
||||
break;
|
||||
}
|
||||
case 180: {
|
||||
if (this.sprite.currentAnimation != "Ship Left") this.SetAnimation("Ship Left");
|
||||
if (this.doTakeStep) movedSuccessfully = this.SimpleMove(-moveAmount, 0, true, pixel(4));
|
||||
this.pointInFront.x = this.x - this.xBound - pixel(2) - moveAmount;
|
||||
this.pointInFront.y = this.y;
|
||||
break;
|
||||
}
|
||||
case 225: {
|
||||
if (this.sprite.currentAnimation != "Ship Down-Left") this.SetAnimation("Ship Down-Left");
|
||||
if (this.doTakeStep) movedSuccessfully = this.SimpleMove(-moveAmount, moveAmount, true, pixel(4));
|
||||
this.pointInFront.x = this.x - this.xBound - pixel(2) - moveAmount;
|
||||
this.pointInFront.y = this.y + this.yBound + pixel(2) + moveAmount;
|
||||
break;
|
||||
}
|
||||
case 270: {
|
||||
if (this.sprite.currentAnimation != "Ship Down") this.SetAnimation("Ship Down");
|
||||
if (this.doTakeStep) movedSuccessfully = this.SimpleMove(0, moveAmount, true, pixel(4));
|
||||
this.pointInFront.x = this.x;
|
||||
this.pointInFront.y = this.y + this.yBound + pixel(2) + moveAmount;
|
||||
break;
|
||||
}
|
||||
case 315: {
|
||||
if (this.sprite.currentAnimation != "Ship Down-Right") this.SetAnimation("Ship Down-Right");
|
||||
if (this.doTakeStep) movedSuccessfully = this.SimpleMove(moveAmount, moveAmount, true, pixel(4));
|
||||
this.pointInFront.x = this.x + this.xBound + pixel(2) + moveAmount;
|
||||
this.pointInFront.y = this.y + this.yBound + pixel(2) + moveAmount;
|
||||
break;
|
||||
}
|
||||
default: {
|
||||
console.log("No valid direction");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.doTakeStep && !movedSuccessfully) {
|
||||
this.currentSpeed = 0;
|
||||
}
|
||||
if (this.doTakeStep && !movedSuccessfully) {
|
||||
this.currentSpeed = 0;
|
||||
}
|
||||
}
|
||||
|
||||
pr_ship.UpdateEnergy = function () {
|
||||
this.energyRefillTimer++;
|
||||
if (this.energyRefillTimer >= (100 / G.stats.crew) + ((G.stats.illness) * (100 / G.stats.crew))) {
|
||||
G.stats.energy += G.stats.crew;
|
||||
this.energyRefillTimer = 0;
|
||||
}
|
||||
this.energyRefillTimer++;
|
||||
if (this.energyRefillTimer >= (100 / G.stats.crew) + ((G.stats.illness) * (100 / G.stats.crew))) {
|
||||
G.stats.energy += G.stats.crew;
|
||||
this.energyRefillTimer = 0;
|
||||
}
|
||||
|
||||
if (this.doTakeStep) {
|
||||
G.stats.energy -= ((this.currentSpeed / G.stats.speed) + ((G.stats.illness) * 0.1)) * 0.25;
|
||||
}
|
||||
if (this.doTakeStep) {
|
||||
G.stats.energy -= ((this.currentSpeed / G.stats.speed) + ((G.stats.illness) * 0.1)) * 0.25;
|
||||
}
|
||||
|
||||
if (G.stats.energy < 0) G.stats.energy = 0;
|
||||
if (G.stats.energy > G.stats.maxEnergy) G.stats.energy = G.stats.maxEnergy;
|
||||
if (G.stats.energy < 0) G.stats.energy = 0;
|
||||
if (G.stats.energy > G.stats.maxEnergy) G.stats.energy = G.stats.maxEnergy;
|
||||
}
|
||||
|
||||
pr_ship.SeamlessScroll = function () {
|
||||
if (this.x <= rm_Ocean.mapLeftTrigger) {
|
||||
this.x = rm_Ocean.mapLeftTriggerTarget;
|
||||
OS.SetCamera({x: rm_Ocean.width});
|
||||
}
|
||||
else if (this.x >= rm_Ocean.mapRightTrigger) {
|
||||
this.x = rm_Ocean.mapRightTriggerTarget;
|
||||
OS.SetCamera({x: 0});
|
||||
}
|
||||
else if (this.y <= rm_Ocean.mapUpTrigger) {
|
||||
this.y = rm_Ocean.mapUpTriggerTarget;
|
||||
OS.SetCamera({y: rm_Ocean.height});
|
||||
}
|
||||
else if (this.y >= rm_Ocean.mapDownTrigger) {
|
||||
this.y = rm_Ocean.mapDownTriggerTarget;
|
||||
OS.SetCamera({y: 0});
|
||||
}
|
||||
if (this.x <= rm_Ocean.mapLeftTrigger) {
|
||||
this.x = rm_Ocean.mapLeftTriggerTarget;
|
||||
OS.SetCamera({x: rm_Ocean.width});
|
||||
}
|
||||
else if (this.x >= rm_Ocean.mapRightTrigger) {
|
||||
this.x = rm_Ocean.mapRightTriggerTarget;
|
||||
OS.SetCamera({x: 0});
|
||||
}
|
||||
else if (this.y <= rm_Ocean.mapUpTrigger) {
|
||||
this.y = rm_Ocean.mapUpTriggerTarget;
|
||||
OS.SetCamera({y: rm_Ocean.height});
|
||||
}
|
||||
else if (this.y >= rm_Ocean.mapDownTrigger) {
|
||||
this.y = rm_Ocean.mapDownTriggerTarget;
|
||||
OS.SetCamera({y: 0});
|
||||
}
|
||||
}
|
||||
|
||||
pr_ship.AdjustSpeedBasedOnEnergy = function () {
|
||||
if (this.currentSpeed > 3 && G.stats.energy < (G.stats.maxEnergy * 0.3) ||
|
||||
this.currentSpeed > 2 && G.stats.energy < (G.stats.maxEnergy * 0.15) ||
|
||||
this.currentSpeed > 1 && G.stats.energy < (G.stats.maxEnergy * 0.05))
|
||||
{
|
||||
this.currentSpeed--;
|
||||
}
|
||||
if (this.currentSpeed > 3 && G.stats.energy < (G.stats.maxEnergy * 0.3) ||
|
||||
this.currentSpeed > 2 && G.stats.energy < (G.stats.maxEnergy * 0.15) ||
|
||||
this.currentSpeed > 1 && G.stats.energy < (G.stats.maxEnergy * 0.05))
|
||||
{
|
||||
this.currentSpeed--;
|
||||
}
|
||||
}
|
||||
|
||||
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.
|
||||
if (Math.randomRange(0, 100) < percentChance) {
|
||||
snd_illness.Play();
|
||||
G.stats.illness++;
|
||||
this.drawSickIndicator += secondsWorthOfFrames(1.5);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +1,27 @@
|
|||
var ani_wave = OS.A.Add("Wave", 64, 64, {columns: 10, speed: 1/10});
|
||||
|
||||
function wavePrefab() {}
|
||||
function wavePrefab() {
|
||||
if (Oversimplified.DEBUG.showMessages) console.log("Ran wavePrefab()");
|
||||
prefabsLoaded++;
|
||||
}
|
||||
|
||||
var pr_wave = OS.P.Add("Wave Particle", {
|
||||
imageSrc: "images/wave_sheet.png",
|
||||
animations: [ani_wave],
|
||||
depth: -90, // Draw above ocean, below everything else.
|
||||
imageSrc: "images/wave_sheet.png",
|
||||
animations: [ani_wave],
|
||||
depth: -90, // Draw above ocean, below everything else.
|
||||
|
||||
lifeTimer: 100,
|
||||
lifeTimer: 100,
|
||||
});
|
||||
|
||||
pr_wave.DoFirst = function () {
|
||||
if (!snd_wave.IsPlaying()) {
|
||||
snd_wave.Play();
|
||||
}
|
||||
}
|
||||
pr_wave.Do = function () {
|
||||
// Move around randomly.
|
||||
this.lifeTimer--;
|
||||
if (this.lifeTimer <= 0) {
|
||||
this.Destroy();
|
||||
}
|
||||
// Move around randomly.
|
||||
this.lifeTimer--;
|
||||
if (this.lifeTimer <= 0) {
|
||||
this.Destroy();
|
||||
}
|
||||
}
|
||||
|
|
@ -1,200 +1,177 @@
|
|||
function oceanRoom () {
|
||||
// Create objects on room creation for persistence.
|
||||
G.player = rm_Ocean.AddObject(OS.P["Ship"]);
|
||||
G.oceanParticle = rm_Ocean.AddObject(OS.P["Ocean Particle"]);
|
||||
|
||||
rm_Ocean.GenerateMap();
|
||||
|
||||
// When room is loaded, explicitly set room to rm_Ocean, just in case "Default" doesn't work/is loaded too slowly
|
||||
// to make sure DoFirst runs.
|
||||
OS.SetRoom(rm_Ocean);
|
||||
if (Oversimplified.DEBUG.showMessages) console.log("Ran oceanRoom()");
|
||||
}
|
||||
|
||||
rm_Ocean.waveTimer = Math.round(Math.randomRange(30, 150));
|
||||
rm_Ocean.speedGaugeImg = new Image();
|
||||
rm_Ocean.speedGaugeImg.src = "images/speed_gauge_sheet.png";
|
||||
|
||||
rm_Ocean.clockTimerCutoff = (1 / OS.S.defaultStep) * 60 * 5; // 5 minute day.
|
||||
rm_Ocean.clockTimerCount = 0;
|
||||
rm_Ocean.clockImg = new Image();
|
||||
rm_Ocean.clockImg.src = "images/clock_sheet.png";
|
||||
|
||||
rm_Ocean.clockTimerCount = 1; // Set it to 1 so it doesn't check for player illness immediately!
|
||||
|
||||
rm_Ocean.DoFirst = function () {
|
||||
G.player.x = (pixel(64) * 25) - pixel(32) - G.player.xBound;
|
||||
G.player.y = pixel(64) * 22;
|
||||
console.log(G.player.name + " created at " + G.player.x + ", " + G.player.y);
|
||||
mus_title.Play();
|
||||
|
||||
G.oceanParticle.x = G.player.x + randomSmidge();
|
||||
G.oceanParticle.y = G.player.y + randomSmidge();
|
||||
// G.player and G.oceanParticle are created in loadPrefabs.js
|
||||
|
||||
// Reset camera whenever room starts
|
||||
OS.SetCamera({
|
||||
x: G.player.x - (OS.camera.width / 2),
|
||||
y: G.player.y - (OS.camera.height / 2),
|
||||
objectToFollow: G.player
|
||||
});
|
||||
rm_Ocean.GenerateMap();
|
||||
|
||||
this.mapLeftTrigger = OS.camera.hBorder;
|
||||
this.mapLeftTriggerTarget = this.width - (OS.camera.width - OS.camera.hBorder);
|
||||
this.mapRightTrigger = this.width - OS.camera.hBorder;
|
||||
this.mapRightTriggerTarget = OS.camera.width - OS.camera.hBorder;
|
||||
this.mapUpTrigger = OS.camera.vBorder;
|
||||
this.mapUpTriggerTarget = this.height - (OS.camera.height - OS.camera.vBorder);
|
||||
this.mapDownTrigger = this.height - OS.camera.vBorder;
|
||||
this.mapDownTriggerTarget = OS.camera.height - OS.camera.vBorder;
|
||||
console.log("player xBound: " + 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));
|
||||
// console.log(G.player.name + " created at " + G.player.x + ", " + G.player.y);
|
||||
|
||||
// G.economy.UpdateEconomy();
|
||||
G.oceanParticle.x = G.player.x + randomSmidge();
|
||||
G.oceanParticle.y = G.player.y + randomSmidge();
|
||||
|
||||
// Reset camera whenever room starts
|
||||
OS.SetCamera({
|
||||
x: G.player.x - (OS.camera.width / 2),
|
||||
y: G.player.y - (OS.camera.height / 2),
|
||||
objectToFollow: G.player,
|
||||
});
|
||||
|
||||
this.mapLeftTrigger = OS.camera.hBorder;
|
||||
this.mapLeftTriggerTarget = this.width - (OS.camera.width - OS.camera.hBorder);
|
||||
this.mapRightTrigger = this.width - OS.camera.hBorder;
|
||||
this.mapRightTriggerTarget = OS.camera.width - OS.camera.hBorder;
|
||||
this.mapUpTrigger = OS.camera.vBorder;
|
||||
this.mapUpTriggerTarget = this.height - (OS.camera.height - OS.camera.vBorder);
|
||||
this.mapDownTrigger = this.height - OS.camera.vBorder;
|
||||
this.mapDownTriggerTarget = OS.camera.height - OS.camera.vBorder;
|
||||
|
||||
// G.economy.UpdateEconomy();
|
||||
}
|
||||
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);
|
||||
if (G.gameStarted) {
|
||||
if (guiControl && guiControl.inventory && guiControl.map && guiControl.trade) { // Force it to wait until loaded.
|
||||
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) {
|
||||
if (ct_cancel().down) {
|
||||
snd_select.Play();
|
||||
guiControl.inventory.activateDelay = 5;
|
||||
guiControl.inventory.show = true;
|
||||
}
|
||||
if (ct_m.down) {
|
||||
snd_select.Play();
|
||||
guiControl.map.activateDelay = 5;
|
||||
guiControl.map.show = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.RunClock();
|
||||
}
|
||||
// Make waves even if the game hasn't started, but not when on trade screen.
|
||||
if (guiControl && guiControl.trade) { // Force it to wait until loaded.
|
||||
if (!guiControl.trade.show) {
|
||||
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.inventory.show && !guiControl.map.show && !guiControl.trade.show) {
|
||||
if (ct_cancel().down) {
|
||||
guiControl.inventory.activateDelay = 5;
|
||||
guiControl.inventory.show = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.RunClock();
|
||||
}
|
||||
}
|
||||
|
||||
rm_Ocean.DrawAbove = function () {
|
||||
if (G.gameStarted) {
|
||||
this.DrawNightDarkness();
|
||||
|
||||
// Draw the speed indicator in Bottom Left corner.
|
||||
OS.context.drawImage(rm_Ocean.speedGaugeImg, G.player.currentSpeed * 32, 0, 32, 32, 16, OS.camera.height - 32 - 16, 32, 32);
|
||||
guiControl.drawSpeedGauge();
|
||||
|
||||
this.DrawEnergyBar();
|
||||
guiControl.drawEnergyBar();
|
||||
|
||||
this.DrawClock();
|
||||
guiControl.drawClock();
|
||||
|
||||
// drawPixelText("Testing 1 2 3!", 0, 0, 0, "white", 4);
|
||||
// drawPixelText("Testing 1 2 3!", 0, 64, 0, "white", 6);
|
||||
drawInventoryGUI();
|
||||
drawMapGUI();
|
||||
drawTradeGUI();
|
||||
guiControl.inventory.Draw();
|
||||
guiControl.map.Draw();
|
||||
guiControl.trade.Draw();
|
||||
} else {
|
||||
guiControl.title.Draw();
|
||||
}
|
||||
}
|
||||
|
||||
rm_Ocean.DoLast = function () {
|
||||
// Clear Objects on room exit. This is best practice unless you need persistent objects.
|
||||
//rm_Ocean.objects = {};
|
||||
// Clear Objects on room exit. This is best practice unless you need persistent objects.
|
||||
//rm_Ocean.objects = {};
|
||||
}
|
||||
|
||||
rm_Ocean.RunClock = function () {
|
||||
if (guiControl.trade && !guiControl.trade.show) { // Only advance time when not trading.
|
||||
rm_Ocean.clockTimerCount++;
|
||||
if (rm_Ocean.clockTimerCount > rm_Ocean.clockTimerCutoff) {
|
||||
rm_Ocean.clockTimerCount = 0;
|
||||
// Play New_Day sound.
|
||||
G.economy.UpdateEconomy();
|
||||
if (guiControl.trade && !guiControl.trade.show) { // Only advance time when not trading.
|
||||
rm_Ocean.clockTimerCount++;
|
||||
if (rm_Ocean.clockTimerCount > rm_Ocean.clockTimerCutoff) {
|
||||
rm_Ocean.clockTimerCount = 0;
|
||||
// Play New_Day sound.
|
||||
G.economy.UpdateEconomy();
|
||||
|
||||
for (var i = 0; i < G.map.length; i++) {
|
||||
G.map[i].island.haggleAmount = 0;
|
||||
G.map[i].island.timesHaggledToday = 0;
|
||||
G.map[i].island.SimulateTrade();
|
||||
}
|
||||
}
|
||||
for (var i = 0; i < G.map.length; i++) {
|
||||
G.map[i].island.NewDay();
|
||||
}
|
||||
|
||||
G.SaveGame();
|
||||
}
|
||||
|
||||
if (rm_Ocean.clockTimerCount == 0 ||
|
||||
rm_Ocean.clockTimerCount == Math.round(rm_Ocean.clockTimerCutoff * 0.33) ||
|
||||
rm_Ocean.clockTimerCount == Math.round(rm_Ocean.clockTimerCutoff * 0.66)) {
|
||||
G.player.CheckIllnessIncrease();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
rm_Ocean.DrawNightDarkness = function () {
|
||||
var alphaFormula = (Math.sin((((this.clockTimerCount / (this.clockTimerCutoff * Math.PI)) * 10) * 1.5) - 2) - 0.4);
|
||||
if (alphaFormula < 0) alphaFormula = 0;
|
||||
|
||||
if (alphaFormula > 0) {
|
||||
var saveGlobalAlpha = OS.context.globalAlpha;
|
||||
var tmp = Oversimplified.context.fillStyle;
|
||||
OS.context.globalAlpha = alphaFormula;
|
||||
Oversimplified.context.fillStyle = "#112189";
|
||||
Oversimplified.context.fillRect(0, 0, Oversimplified.camera.width, Oversimplified.camera.height);
|
||||
Oversimplified.context.fillStyle = tmp;
|
||||
Oversimplified.context.globalAlpha = saveGlobalAlpha;
|
||||
}
|
||||
}
|
||||
|
||||
rm_Ocean.DrawEnergyBar = function () {
|
||||
var percentage = G.stats.energy / G.stats.maxEnergy;
|
||||
var barHeight = pixel(2);
|
||||
var maxBarWidth = 32;
|
||||
var barWidth = pixel(Math.round(maxBarWidth * percentage));
|
||||
|
||||
var saveFillStyle = OS.context.fillStyle;
|
||||
OS.context.fillStyle = "#0055FF";
|
||||
OS.context.fillRect(64, OS.camera.height - barHeight - 16, barWidth, barHeight);
|
||||
OS.context.fillStyle = saveFillStyle;
|
||||
}
|
||||
|
||||
rm_Ocean.DrawClock = function () {
|
||||
var screenX = OS.camera.width - pixel(9) - pixel(2);
|
||||
var screenY = OS.camera.height - pixel(9) - pixel(2);
|
||||
var percentOfClock = this.clockTimerCount / this.clockTimerCutoff;
|
||||
var clockFrameX = Math.floor(16 * percentOfClock) * pixel(9);
|
||||
OS.context.drawImage(this.clockImg, clockFrameX, 0, pixel(9), pixel(9), screenX, screenY, pixel(9), pixel(9));
|
||||
// console.log(this.clockTimerCount);
|
||||
var alphaFormula = (Math.sin((((this.clockTimerCount / (this.clockTimerCutoff * Math.PI)) * 10) * 1.5) - 2) - 0.4);
|
||||
if (alphaFormula < 0) alphaFormula = 0;
|
||||
|
||||
if (alphaFormula > 0) {
|
||||
var saveGlobalAlpha = OS.context.globalAlpha;
|
||||
var tmp = Oversimplified.context.fillStyle;
|
||||
OS.context.globalAlpha = alphaFormula;
|
||||
Oversimplified.context.fillStyle = "#112189";
|
||||
Oversimplified.context.fillRect(0, 0, Oversimplified.camera.width, Oversimplified.camera.height);
|
||||
Oversimplified.context.fillStyle = tmp;
|
||||
Oversimplified.context.globalAlpha = saveGlobalAlpha;
|
||||
}
|
||||
}
|
||||
|
||||
rm_Ocean.GenerateMap = function () {
|
||||
var island1 = rm_Ocean.AddObject(OS.P["Island"], {
|
||||
x: pixel(64) * 25, //Exact center of map.
|
||||
y: pixel(64) * 22
|
||||
});
|
||||
|
||||
console.log(island1.name + " created at " + island1.x + ", " + island1.y);
|
||||
G.map.push({
|
||||
island: island1,
|
||||
drawX: 25,
|
||||
drawY: 22,
|
||||
drawWidth: 1,
|
||||
drawHeight: 1
|
||||
});
|
||||
|
||||
var usedXSquares = [];
|
||||
var usedYSquares = [];
|
||||
for (var i = 0; i < 9; i++) {
|
||||
var xSquare = Math.round(Math.randomRange(1, 49));
|
||||
while (usedXSquares.indexOf(xSquare) != -1 &&
|
||||
usedXSquares.indexOf(xSquare + 1) != -1 && usedXSquares.indexOf(xSquare - 1) != -1 &&
|
||||
usedXSquares.indexOf(xSquare + 2) != -1 && usedXSquares.indexOf(xSquare - 2) != -1)
|
||||
{
|
||||
xSquare = Math.round(Math.randomRange(1, 49));
|
||||
}
|
||||
usedXSquares.push(xSquare);
|
||||
|
||||
var ySquare = Math.round(Math.randomRange(1, 43));
|
||||
while (usedYSquares.indexOf(ySquare) != -1 &&
|
||||
usedYSquares.indexOf(ySquare + 1) != -1 && usedYSquares.indexOf(ySquare - 1) != -1 &&
|
||||
usedYSquares.indexOf(ySquare + 2) != -1 && usedYSquares.indexOf(ySquare - 2) != -1)
|
||||
{
|
||||
ySquare = Math.round(Math.randomRange(1, 49));
|
||||
}
|
||||
usedYSquares.push(ySquare);
|
||||
|
||||
var xPosition = pixel(64) * xSquare;
|
||||
var yPosition = pixel(64) * ySquare;
|
||||
|
||||
G.map.push({
|
||||
island: rm_Ocean.AddObject(OS.P["Island"], {
|
||||
x: xPosition,
|
||||
y: yPosition
|
||||
}),
|
||||
drawX: xSquare,
|
||||
drawY: ySquare,
|
||||
drawWidth: 1,
|
||||
drawHeight: 1
|
||||
});
|
||||
console.log(G.map[i + 1].island.name + " created at " + G.map[i + 1].island.x + ", " + G.map[i + 1].island.y);
|
||||
var xSquares = [25];
|
||||
var ySquares = [22];
|
||||
while (xSquares.length < this.numberOfIslands) {
|
||||
var randomNumber = Math.round(Math.randomRange(2, this.squaresX - 2));
|
||||
var found = false;
|
||||
for (var i = 0; i < xSquares.length; i++) {
|
||||
if (xSquares[i] - ((this.squaresX / this.numberOfIslands) / 2) < randomNumber && randomNumber < xSquares[i] + ((this.squaresX / this.numberOfIslands) / 2)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) xSquares.push(randomNumber);
|
||||
}
|
||||
while (ySquares.length < this.numberOfIslands) {
|
||||
var randomNumber = Math.round(Math.randomRange(2, this.squaresY - 2));
|
||||
var found = false;
|
||||
for (var i = 0; i < ySquares.length; i++) {
|
||||
if (ySquares[i] - ((this.squaresY / this.numberOfIslands) / 2) < randomNumber && randomNumber < ySquares[i] + ((this.squaresY / this.numberOfIslands) / 2)) {
|
||||
found = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!found) ySquares.push(randomNumber);
|
||||
}
|
||||
|
||||
for (var i = 0; i < this.numberOfIslands; i++) {
|
||||
G.map[i] = {
|
||||
island: rm_Ocean.AddObject(OS.P["Island"], {
|
||||
x: this.squareSize * xSquares[i],
|
||||
y: this.squareSize * ySquares[i]
|
||||
}),
|
||||
drawX: xSquares[i],
|
||||
drawY: ySquares[i],
|
||||
drawWidth: 1,
|
||||
drawHeight: 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,19 +0,0 @@
|
|||
function titleScreen () {
|
||||
// When room is loaded, explicitly set room to rm_TitleScreen, just in case "Default" doesn't work/is loaded too slowly
|
||||
OS.SetRoom(rm_TitleScreen);
|
||||
}
|
||||
|
||||
rm_TitleScreen.Do = function () {
|
||||
// Menu options.
|
||||
}
|
||||
rm_TitleScreen.DrawBelow = function () {
|
||||
// Fill background color because I can't figure out how to make OversimplifiedJS change the bg color on room change!
|
||||
var tmp = Oversimplified.context.fillStyle;
|
||||
Oversimplified.context.fillStyle = "#D9BEA5";
|
||||
Oversimplified.context.fillRect(0, 0, Oversimplified.camera.width, Oversimplified.camera.height);
|
||||
Oversimplified.context.fillStyle = tmp;
|
||||
}
|
||||
rm_TitleScreen.DoLast = function () {
|
||||
// Clear Objects on room exit. This is best practice unless you need persistent objects.
|
||||
rm_TitleScreen.objects = {};
|
||||
}
|
||||