Replaced every instance of OS.S.pixelScale with pixel() to make life easier.

This commit is contained in:
Robbie Antenesse 2016-04-12 18:14:09 -06:00
parent 0825c135c1
commit d8cb0151d8
9 changed files with 115 additions and 99 deletions

View File

@ -8,7 +8,7 @@ function inventoryGUI() {
function drawInventoryGUI() {
if (guiControl.inventory.show) {
OS.context.drawImage(guiControl.background, 0, 0, 240, 240, 2 * OS.S.pixelScale, 2 * OS.S.pixelScale, 240, 240);
OS.context.drawImage(guiControl.background, 0, 0, 240, 240, pixel(2), pixel(2), 240, 240);
if (ct_down().down) {
guiControl.inventory.cursorPosition++;
@ -27,19 +27,19 @@ function drawInventoryGUI() {
}
// Title
guiControl.drawPixelText("Storage", guiControl.leftBorder - (2 * OS.S.pixelScale), guiControl.topOfBackground, 8, "black", 6);
guiControl.drawPixelText("Storage", guiControl.leftBorder - pixel(2), guiControl.topOfBackground, 8, "black", 6);
// Money icon
guiControl.drawIcon(7, 2, guiControl.leftBorder, guiControl.rowTop(0));
guiControl.drawPixelText(G.inventory.moneyDisplay(), guiControl.leftBorder + ((guiControl.iconSize + 4) * OS.S.pixelScale), guiControl.rowTop(0) + OS.S.pixelScale, 8, "black", 6);
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 + ((guiControl.iconSize + 4) * OS.S.pixelScale), guiControl.rowTop(1) + OS.S.pixelScale, 8, "black", 6);
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 + ((guiControl.iconSize + 4) * OS.S.pixelScale), guiControl.rowTop(2) + OS.S.pixelScale, 8, "black", 6);
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) + OS.S.pixelScale, 8, "black", 6);
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));
@ -74,18 +74,18 @@ function drawInventoryGUI() {
}
// Title
guiControl.drawPixelText("Money", guiControl.leftBorder - (2 * OS.S.pixelScale), guiControl.topOfBackground, 8, "black", 6);
guiControl.drawPixelText("Money", guiControl.leftBorder - pixel(2), guiControl.topOfBackground, 8, "black", 6);
guiControl.drawPixelText("Actual Amt", guiControl.leftBorder - (5 * OS.S.pixelScale), guiControl.rowTop(0) + OS.S.pixelScale, 10, "black", 4);
guiControl.drawPixelText("Actual Amt", guiControl.leftBorder - pixel(5), guiControl.rowTop(0) + pixel(), 10, "black", 4);
// Money icon
guiControl.drawIcon(7, 2, guiControl.leftBorder - (5 * OS.S.pixelScale), guiControl.rowTop(1) - (3 * OS.S.pixelScale));
guiControl.drawPixelText(G.inventory.money.toString(), guiControl.leftBorder - (5 * OS.S.pixelScale) + ((guiControl.iconSize + 2) * OS.S.pixelScale), guiControl.rowTop(1) + (2 * OS.S.pixelScale) - (3 * OS.S.pixelScale), 10, "black", 4);
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) - (3 * OS.S.pixelScale), 8, "black", 6);
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) - (4 * OS.S.pixelScale));
OS.context.drawImage(guiControl.cursor, guiControl.leftBorder - (guiControl.iconScaled), guiControl.rowTop(4) - pixel(4));
// Button Action
if (ct_confirm().down || ct_cancel().down) {
@ -103,25 +103,25 @@ function drawInventoryGUI() {
}
// Title
guiControl.drawPixelText("Supplies", guiControl.leftBorder - (6 * OS.S.pixelScale), guiControl.topOfBackground, 8, "black", 6);
guiControl.drawPixelText("Supplies", guiControl.leftBorder - pixel(6), guiControl.topOfBackground, 8, "black", 6);
guiControl.drawPixelText("Heal Crew?", guiControl.leftBorder - (5 * OS.S.pixelScale), guiControl.rowTop(0) + OS.S.pixelScale, 10, "black", 4);
guiControl.drawPixelText("Heal Crew?", guiControl.leftBorder - pixel(5), guiControl.rowTop(0) + pixel(), 10, "black", 4);
// Supplies icon
guiControl.drawIcon(9, 2, guiControl.leftBorder - (5 * OS.S.pixelScale), guiControl.rowTop(1) - (3 * OS.S.pixelScale));
guiControl.drawPixelText(G.inventory.supplies.toString(), guiControl.leftBorder - (5 * OS.S.pixelScale) + ((guiControl.iconSize + 2) * OS.S.pixelScale), guiControl.rowTop(1) + (2 * OS.S.pixelScale) - (3 * OS.S.pixelScale), 2, "black", 4);
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 - (5 * OS.S.pixelScale) + (24 * OS.S.pixelScale), guiControl.rowTop(1) - (3 * OS.S.pixelScale));
guiControl.drawPixelText(G.stats.illness.toString(), guiControl.leftBorder - (5 * OS.S.pixelScale) + (24 * OS.S.pixelScale) + ((guiControl.iconSize + 2) * OS.S.pixelScale), guiControl.rowTop(1) + (2 * OS.S.pixelScale) - (3 * OS.S.pixelScale), 2, "black", 4);
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) - (3 * OS.S.pixelScale), 3, "black", 6);
guiControl.drawPixelText("Yes", guiControl.leftBorder, guiControl.rowTop(3) - (3 * OS.S.pixelScale), 3, "black", 6);
guiControl.drawPixelText("No", guiControl.leftBorder, guiControl.rowTop(2) - pixel(3), 3, "black", 6);
guiControl.drawPixelText("Yes", guiControl.leftBorder, guiControl.rowTop(3) - pixel(3), 3, "black", 6);
// Back Text
guiControl.drawPixelText("Back", guiControl.leftBorder, guiControl.rowTop(4) - (3 * OS.S.pixelScale), 8, "black", 6);
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) - (4 * OS.S.pixelScale));
guiControl.drawCursor(guiControl.leftBorder - (guiControl.iconScaled), guiControl.rowTop(guiControl.inventory.cursorPosition + 2) - pixel(4));
// Button Action
if (ct_confirm().down) {
@ -154,20 +154,20 @@ function drawInventoryGUI() {
}
// Title
guiControl.drawPixelText("Cargo", guiControl.leftBorder - (2 * OS.S.pixelScale), guiControl.topOfBackground, 8, "black", 6);
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 + ((guiControl.iconSize + 4) * OS.S.pixelScale), guiControl.rowTop(i) + OS.S.pixelScale, 8, "black", 6);
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) - (3 * OS.S.pixelScale), 8, "black", 6);
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) - (4 * OS.S.pixelScale));
OS.context.drawImage(guiControl.cursor, guiControl.leftBorder - (guiControl.iconScaled), guiControl.rowTop(4) - pixel(4));
// Button Action
if (ct_confirm().down || ct_cancel().down) {

View File

@ -2,33 +2,35 @@ function tradeGUI() {
guiControl.trade = {
screen: "main", // "main", "buy", "sell", "gossip"
cursorPosition: 0,
scroll: 0, // horizontal scroll on item lists.
page: 0, // horizontal page on item lists.
show: false,
activateDelay: 0,
island: null,
padding: 2 * OS.S.pixelScale,
leftBorder: 12 * OS.S.pixelScale,
padding: pixel(2),
leftBorder: pixel(12),
rowTop: function (rowNumber) {
return (guiControl.trade.padding + (6 * OS.S.pixelScale) + (guiControl.trade.padding * 3)) + ((guiControl.iconSize + 3) * rowNumber * OS.S.pixelScale);
return (guiControl.trade.padding + pixel(6) + (guiControl.trade.padding * 3)) + pixel((guiControl.iconSize + 3) * rowNumber);
}
}
}
function drawTradeGUI() {
if (guiControl.trade.show) {
guiControl.trade.activateDelay--;
guiControl.trade.activateDelay -= (guiControl.trade.activateDelay > 0) ? 1 : 0;
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) {
// Play Move_Cursor sound.
guiControl.trade.cursorPosition++;
}
if (ct_up().down) {
// Play Move_Cursor_Up sound.
guiControl.trade.cursorPosition--;
}
@ -45,16 +47,16 @@ function drawTradeGUI() {
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("Buy", guiControl.trade.leftBorder, guiControl.trade.rowTop(0) + OS.S.pixelScale, 8, "black", 6);
guiControl.drawPixelText("Buy", guiControl.trade.leftBorder, guiControl.trade.rowTop(0) + pixel(), 8, "black", 6);
// Supplies icon
// guiControl.drawIcon(9, 2, guiControl.trade.leftBorder, guiControl.trade.rowTop(1));
guiControl.drawPixelText("Sell", guiControl.trade.leftBorder, guiControl.trade.rowTop(1) + OS.S.pixelScale, 8, "black", 6);
guiControl.drawPixelText("Sell", guiControl.trade.leftBorder, guiControl.trade.rowTop(1) + pixel(), 8, "black", 6);
// Cargo icon
// guiControl.drawIcon(1, 0, guiControl.trade.leftBorder, guiControl.trade.rowTop(2));
guiControl.drawPixelText("Gossip", guiControl.trade.leftBorder, guiControl.trade.rowTop(2) + OS.S.pixelScale, 8, "black", 6);
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) + OS.S.pixelScale, 8, "black", 6);
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));
@ -72,11 +74,14 @@ function drawTradeGUI() {
guiControl.trade.screen = "gossip";
break;
default:
// Change music to Sail.
guiControl.trade.show = false;
break;
}
// Play Select sound.
guiControl.trade.cursorPosition = 0;
guiControl.trade.page = 0;
}
}
else if (guiControl.trade.screen == "buy") {
@ -89,11 +94,11 @@ function drawTradeGUI() {
}
// Title
guiControl.drawPixelText("Buy", guiControl.trade.leftBorder - (2 * OS.S.pixelScale), guiControl.topOfBackground, 10, "black", 6);
guiControl.drawPixelText("Buy", guiControl.trade.leftBorder - pixel(2), guiControl.topOfBackground, 10, "black", 6);
// Money icon
guiControl.drawIcon(7, 2, guiControl.trade.leftBorder - (5 * OS.S.pixelScale), guiControl.trade.rowTop(0) - (3 * OS.S.pixelScale));
guiControl.drawPixelText(G.inventory.moneyDisplay(), guiControl.trade.leftBorder - (5 * OS.S.pixelScale) + ((guiControl.iconSize + 2) * OS.S.pixelScale), guiControl.trade.rowTop(0) + (2 * OS.S.pixelScale) - (3 * OS.S.pixelScale), 10, "black", 4);
guiControl.drawIcon(7, 2, guiControl.trade.leftBorder - pixel(5), guiControl.trade.rowTop(0) - pixel(3));
guiControl.drawPixelText(G.inventory.moneyDisplay(), guiControl.trade.leftBorder - pixel(5) + pixel(guiControl.iconSize + 2), guiControl.trade.rowTop(0) + pixel(2) - pixel(3), 10, "black", 4);
// Cargo icons
var cargo = guiControl.trade.island.CheckInventory(); // Contains the item ids that have more than 1 item
@ -101,18 +106,19 @@ function drawTradeGUI() {
guiControl.drawItem(cargo[i], guiControl.trade.leftBorder, guiControl.trade.rowTop(i + 1));
var itemPrice = G.economy.cargoItemWorth[cargo[i]] + guiControl.trade.island.priceDifferences[cargo[i]];
var itemPriceDisplay = itemPrice.toString() + " c";
guiControl.drawPixelText(itemPriceDisplay, guiControl.trade.leftBorder + ((guiControl.iconSize + 4) * OS.S.pixelScale), guiControl.trade.rowTop(i + 1) + OS.S.pixelScale, 8, "black", 6);
// guiControl.drawPixelText(guiControl.trade.island.inventory[cargo[i]], guiControl.trade.leftBorder + ((guiControl.iconSize + 4) * OS.S.pixelScale), guiControl.trade.rowTop(i + 1) + OS.S.pixelScale, 8, "black", 6);
guiControl.drawPixelText(itemPriceDisplay, guiControl.trade.leftBorder + pixel(guiControl.iconSize + 4), guiControl.trade.rowTop(i + 1) + pixel(2), 8, "black", 4);
// guiControl.drawPixelText(guiControl.trade.island.inventory[cargo[i]], guiControl.trade.leftBorder + pixel(guiControl.iconSize + 4), guiControl.trade.rowTop(i + 1) + pixel(), 8, "black", 6);
}
// Back Text
guiControl.drawPixelText("Back", guiControl.trade.leftBorder, guiControl.trade.rowTop(4) - (3 * OS.S.pixelScale), 8, "black", 6);
guiControl.drawPixelText("Back", guiControl.trade.leftBorder, guiControl.trade.rowTop(4) - pixel(3), 8, "black", 6);
// Draw cursor
OS.context.drawImage(guiControl.cursor, guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(4) - (4 * OS.S.pixelScale));
OS.context.drawImage(guiControl.cursor, guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(4) - pixel(4));
// Button Action
if (ct_confirm().down || ct_cancel().down) {
// Play Select sound.
guiControl.trade.screen = "main";
guiControl.trade.cursorPosition = 0;
}
@ -127,25 +133,25 @@ function drawTradeGUI() {
}
// Title
guiControl.drawPixelText("Sell", guiControl.trade.leftBorder - (6 * OS.S.pixelScale), guiControl.topOfBackground, 10, "black", 6);
guiControl.drawPixelText("Sell", guiControl.trade.leftBorder - pixel(6), guiControl.topOfBackground, 10, "black", 6);
guiControl.drawPixelText("Heal Crew?", guiControl.trade.leftBorder - (5 * OS.S.pixelScale), guiControl.trade.rowTop(0) + OS.S.pixelScale, 10, "black", 4);
guiControl.drawPixelText("Heal Crew?", guiControl.trade.leftBorder - pixel(5), guiControl.trade.rowTop(0) + pixel(), 10, "black", 4);
// Supplies icon
guiControl.drawIcon(9, 2, guiControl.trade.leftBorder - (5 * OS.S.pixelScale), guiControl.trade.rowTop(1) - (3 * OS.S.pixelScale));
guiControl.drawPixelText(G.inventory.supplies.toString(), guiControl.trade.leftBorder - (5 * OS.S.pixelScale) + ((guiControl.iconSize + 2) * OS.S.pixelScale), guiControl.trade.rowTop(1) + (2 * OS.S.pixelScale) - (3 * OS.S.pixelScale), 2, "black", 4);
guiControl.drawIcon(9, 2, guiControl.trade.leftBorder - pixel(5), guiControl.trade.rowTop(1) - pixel(3));
guiControl.drawPixelText(G.inventory.supplies.toString(), guiControl.trade.leftBorder - pixel(5) + pixel(guiControl.iconSize + 2), guiControl.trade.rowTop(1) + pixel(2) - pixel(3), 2, "black", 4);
// Illness icon
guiControl.drawIcon(4, 1, guiControl.trade.leftBorder - (5 * OS.S.pixelScale) + (24 * OS.S.pixelScale), guiControl.trade.rowTop(1) - (3 * OS.S.pixelScale));
guiControl.drawPixelText(G.stats.illness.toString(), guiControl.trade.leftBorder - (5 * OS.S.pixelScale) + (24 * OS.S.pixelScale) + ((guiControl.iconSize + 2) * OS.S.pixelScale), guiControl.trade.rowTop(1) + (2 * OS.S.pixelScale) - (3 * OS.S.pixelScale), 2, "black", 4);
guiControl.drawIcon(4, 1, guiControl.trade.leftBorder - pixel(5) + pixel(24), guiControl.trade.rowTop(1) - pixel(3));
guiControl.drawPixelText(G.stats.illness.toString(), guiControl.trade.leftBorder - pixel(5) + pixel(24) + pixel(guiControl.iconSize + 2), guiControl.trade.rowTop(1) + pixel(2) - pixel(3), 2, "black", 4);
// Yes/No options
guiControl.drawPixelText("No", guiControl.trade.leftBorder, guiControl.trade.rowTop(2) - (3 * OS.S.pixelScale), 3, "black", 6);
guiControl.drawPixelText("Yes", guiControl.trade.leftBorder, guiControl.trade.rowTop(3) - (3 * OS.S.pixelScale), 3, "black", 6);
guiControl.drawPixelText("No", guiControl.trade.leftBorder, guiControl.trade.rowTop(2) - pixel(3), 3, "black", 6);
guiControl.drawPixelText("Yes", guiControl.trade.leftBorder, guiControl.trade.rowTop(3) - pixel(3), 3, "black", 6);
// Back Text
guiControl.drawPixelText("Back", guiControl.trade.leftBorder, guiControl.trade.rowTop(4) - (3 * OS.S.pixelScale), 8, "black", 6);
guiControl.drawPixelText("Back", guiControl.trade.leftBorder, guiControl.trade.rowTop(4) - pixel(3), 8, "black", 6);
// Draw cursor
guiControl.drawCursor(guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(guiControl.trade.cursorPosition + 2) - (4 * OS.S.pixelScale));
guiControl.drawCursor(guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(guiControl.trade.cursorPosition + 2) - pixel(4));
// Button Action
if (ct_confirm().down) {
@ -161,6 +167,7 @@ function drawTradeGUI() {
guiControl.trade.cursorPosition = 1; // The position where "Supplies" is on main screen.
break;
}
// Play Select sound.
}
if (ct_cancel().down) {
@ -178,25 +185,26 @@ function drawTradeGUI() {
}
// Title
guiControl.drawPixelText("Gossip", guiControl.trade.padding - (2 * OS.S.pixelScale), guiControl.topOfBackground, 10, "black", 6);
guiControl.drawPixelText("Gossip", guiControl.trade.padding - pixel(2), guiControl.topOfBackground, 10, "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.trade.leftBorder, guiControl.trade.rowTop(i));
guiControl.drawPixelText(G.inventory.cargo[cargo[i]], guiControl.trade.leftBorder + ((guiControl.iconSize + 4) * OS.S.pixelScale), guiControl.trade.rowTop(i) + OS.S.pixelScale, 8, "black", 6);
guiControl.drawPixelText(G.inventory.cargo[cargo[i]], guiControl.trade.leftBorder + pixel(guiControl.iconSize + 4), guiControl.trade.rowTop(i) + pixel(), 8, "black", 6);
}
// Back Text
guiControl.drawPixelText("Back", guiControl.trade.leftBorder, guiControl.trade.rowTop(4) - (3 * OS.S.pixelScale), 8, "black", 6);
guiControl.drawPixelText("Back", guiControl.trade.leftBorder, guiControl.trade.rowTop(4) - pixel(3), 8, "black", 6);
// Draw cursor
OS.context.drawImage(guiControl.cursor, guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(4) - (4 * OS.S.pixelScale));
OS.context.drawImage(guiControl.cursor, guiControl.trade.leftBorder - (guiControl.iconScaled), guiControl.trade.rowTop(4) - pixel(4));
// Button Action
if (ct_confirm().down || ct_cancel().down) {
guiControl.trade.screen = "main";
guiControl.trade.cursorPosition = 2;
// Play Select sound.
}
}
}

View File

@ -4,19 +4,19 @@ function loadGUIs() {
}
var guiControl = {
topOfBackground: (2 + 2) * OS.S.pixelScale,
upperBorder: (13 + 2) * OS.S.pixelScale,
lowerBorder: (3 + 2) * OS.S.pixelScale,
leftBorder: (10 + 2) * OS.S.pixelScale,
rightBorder: (5 + 2) * OS.S.pixelScale,
topOfBackground: pixel(2 + 2),
upperBorder: pixel(13 + 2),
lowerBorder: pixel(3 + 2),
leftBorder: pixel(10 + 2),
rightBorder: pixel(5 + 2),
iconSize: 8,
iconScaled: 8 * OS.S.pixelScale,
iconScaled: pixel(8),
iconPosition: function (cellPosition) {
return (guiControl.iconScaled * cellPosition);
},
rowTop: function (rowNumber) {
return guiControl.upperBorder + ((guiControl.iconSize + 2) * rowNumber * OS.S.pixelScale);
return guiControl.upperBorder + pixel((guiControl.iconSize + 2) * rowNumber);
},
drawIcon: function (cellX, cellY, xPosition, yPosition) {
@ -48,9 +48,9 @@ guiControl.drawPixelText = function (text, x, y, wrapWidth, color, size) {
// 5x6 font modified from http://atariage.com/forums/topic/165697-fonts/page-4#entry2081600
text = text.toString().toUpperCase();
var letterSizeX = ((size == 6) ? size - 1 : size) * OS.S.pixelScale;
var letterSizeY = size * OS.S.pixelScale;
var maxWrapWidth = Math.floor(OS.camera.width / (letterSizeX + OS.S.pixelScale));
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;
@ -234,8 +234,8 @@ guiControl.drawPixelText = function (text, x, y, wrapWidth, color, size) {
var horizontal = i - (wrapWidth * lineNumber);
var letterSheetX = letterSizeX * letterCellX;
var letterSheetY = letterSizeY * letterCellY;
var letterX = x + (letterSizeX * horizontal) + (OS.S.pixelScale * horizontal); //Places a space between characters horizontally
var letterY = y + (letterSizeY * lineNumber) + (OS.S.pixelScale * lineNumber); //Places a space between characters vertically
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);
}
}

View File

@ -6,8 +6,8 @@ var rm_Trade = OS.R.Add("Trade", {
backgroundColor: "#D9BEA5"
});
var rm_Ocean = OS.R.Add("Default", {
width: (64 * OS.S.pixelScale) * 50, //50x50 map of 64x64 squares. This will allow a single pixel on the map to represent a 64x square and fit comfortably on screen.
height: (64 * OS.S.pixelScale) * 50,
width: pixel(64) * 50, //50x50 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) * 50,
backgroundColor: "#1b2632"
});

View File

@ -69,17 +69,20 @@ pr_island.CheckInventory = function () { // Returns an array of indices that hav
}
pr_island.TradeWith = function () {
// Change music to Trade.
guiControl.trade.island = this.self;
guiControl.trade.activateDelay = 5;
guiControl.trade.show = true;
}
pr_island.SellTo = function (itemIndex, amount) {
// Play Buy sound.
this.inventory[itemIndex] += amount;
this.itemsBought[itemIndex] += amount;
}
pr_island.BuyFrom = function (itemIndex, amount) {
this.inventory[itemIndex] += amount;
// Play Sell sound.
this.inventory[itemIndex] -= amount;
this.itemsSold[itemIndex] += amount;
}

View File

@ -25,8 +25,8 @@ pr_ocean.Do = function () {
// Move around randomly.
this.moveTimer++;
if (this.moveTimer >= 120) {
this.x += 1 * Math.round(Math.randomRange(-1, 1)) * OS.S.pixelScale;
this.y += 1 * Math.round(Math.randomRange(-1, 1)) * OS.S.pixelScale;
this.x += 1 * pixel(Math.round(Math.randomRange(-1, 1)));
this.y += 1 * pixel(Math.round(Math.randomRange(-1, 1)));
this.moveTimer = 0;
}
}

View File

@ -79,56 +79,56 @@ pr_ship.CheckInteraction = function () {
}
pr_ship.CheckMovement = function () {
var moveAmount = (G.stats.speed + this.currentSpeed) * OS.S.pixelScale;
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, 8);
this.pointInFront.x = this.x + this.xBound + (OS.S.pixelScale * 2) + moveAmount;
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, 8);
this.pointInFront.x = this.x + this.xBound + (OS.S.pixelScale * 2) + moveAmount;
this.pointInFront.y = this.y - this.yBound - (OS.S.pixelScale * 2) - moveAmount;
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, 8);
this.pointInFront.x = this.x;
this.pointInFront.y = this.y - this.yBound - (OS.S.pixelScale * 2) - moveAmount;
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, 8);
this.pointInFront.x = this.x - this.xBound - (OS.S.pixelScale * 2) - moveAmount;
this.pointInFront.y = this.y - this.yBound - (OS.S.pixelScale * 2) - moveAmount;
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, 8);
this.pointInFront.x = this.x - this.xBound - (OS.S.pixelScale * 2) - moveAmount;
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, 8);
this.pointInFront.x = this.x - this.xBound - (OS.S.pixelScale * 2) - moveAmount;
this.pointInFront.y = this.y + this.yBound + (OS.S.pixelScale * 2) + moveAmount;
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, 8);
this.pointInFront.x = this.x;
this.pointInFront.y = this.y + this.yBound + (OS.S.pixelScale * 2) + moveAmount;
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, 8);
this.pointInFront.x = this.x + this.xBound + (OS.S.pixelScale * 2) + moveAmount;
this.pointInFront.y = this.y + this.yBound + (OS.S.pixelScale * 2) + moveAmount;
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");

View File

@ -1,12 +1,17 @@
function oceanRoom () {
// Create objects on room creation for persistence.
G.player = rm_Ocean.AddObject(OS.P["Ship"]);
G.player.x = ((rm_Ocean.width / OS.S.pixelScale) / 2) * OS.S.pixelScale;
G.player.y = ((rm_Ocean.height / OS.S.pixelScale) / 2) * OS.S.pixelScale;
G.player.x = pixel((rm_Ocean.width / OS.S.pixelScale) / 2);
G.player.y = pixel((rm_Ocean.height / OS.S.pixelScale) / 2);
console.log(G.player.name + " created at " + G.player.x + ", " + G.player.y);
G.oceanParticle = rm_Ocean.AddObject(OS.P["Ocean Particle"]);
G.oceanParticle.x = G.player.x + randomSmidge();
G.oceanParticle.y = G.player.y + randomSmidge();
var island1 = rm_Ocean.AddObject(OS.P["Island"]);
island1.x = pixel((rm_Ocean.width / OS.S.pixelScale) / 2) + island1.xBound + G.player.xBound;
island1.y = pixel((rm_Ocean.height / OS.S.pixelScale) / 2);
console.log(island1.name + " created at " + island1.x + ", " + island1.y);
// 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.
@ -17,9 +22,6 @@ rm_Ocean.waveTimer = Math.round(Math.randomRange(30, 150));
rm_Ocean.speedGaugeImg = new Image();
rm_Ocean.speedGaugeImg.src = "images/speed_gauge_sheet.png";
var island1 = rm_Ocean.AddObject(OS.P["Island"]);
island1.x = (((rm_Ocean.width / OS.S.pixelScale) / 2) + 64) * OS.S.pixelScale;
island1.y = ((rm_Ocean.height / OS.S.pixelScale) / 2) * OS.S.pixelScale;
rm_Ocean.DoFirst = function () {
// Reset camera whenever room starts
@ -85,9 +87,9 @@ rm_Ocean.DoLast = function () {
rm_Ocean.DrawEnergyBar = function () {
var percentage = G.stats.energy / G.stats.maxEnergy;
var barHeight = 2 * OS.S.pixelScale;
var barHeight = pixel(2);
var maxBarWidth = 32;
var barWidth = Math.round(maxBarWidth * percentage) * OS.S.pixelScale;
var barWidth = pixel(Math.round(maxBarWidth * percentage));
var saveFillStyle = OS.context.fillStyle;
OS.context.fillStyle = "#0055FF";

View File

@ -1,11 +1,10 @@
OS.S.defaultStep = 1 / 120;
OS.S.pixelScale = 4;
OS.SetCamera({
width: 64 * OS.S.pixelScale,
height: 64 * OS.S.pixelScale,
hBorder: 24 * OS.S.pixelScale,
vBorder: 24 * OS.S.pixelScale
});
width: pixel(64),
height: pixel(64),
hBorder: pixel(24),
vBorder: pixel(24)});
function start()
{
@ -16,7 +15,11 @@ function start()
OS.AddScript("loadRooms.js");
}
function pixel(number) {
return ((typeof number !== 'undefined') ? number : 1) * OS.S.pixelScale;
}
function randomSmidge() {
// Return a random amount between -10 and 10 on the pixel scale.
return (Math.round(Math.randomRange(-10, 10)) * OS.S.pixelScale);
return (pixel(Math.round(Math.randomRange(-10, 10))));
}