Update code styles and spacing
This commit is contained in:
parent
27e95d4011
commit
7b8729d4e0
|
@ -6,7 +6,7 @@ guiControl.inventory = {
|
|||
screen: "main",
|
||||
cursorPosition: 0,
|
||||
show: false,
|
||||
activateDelay: 0
|
||||
activateDelay: 0,
|
||||
}
|
||||
|
||||
guiControl.inventory.Draw = function () {
|
||||
|
@ -59,23 +59,27 @@ guiControl.inventory.Draw = function () {
|
|||
if (guiControl.inventory.activateDelay <= 0) {
|
||||
if (ct_confirm().down) {
|
||||
switch (guiControl.inventory.cursorPosition) {
|
||||
case 0:
|
||||
case 0: {
|
||||
snd_select.Play();
|
||||
guiControl.inventory.screen = "money";
|
||||
break;
|
||||
case 1:
|
||||
}
|
||||
case 1: {
|
||||
snd_select.Play();
|
||||
guiControl.inventory.screen = "cargo";
|
||||
break;
|
||||
case 2:
|
||||
}
|
||||
case 2: {
|
||||
snd_select.Play();
|
||||
guiControl.inventory.screen = "status";
|
||||
break;
|
||||
default:
|
||||
}
|
||||
default: {
|
||||
snd_cursorup.Play();
|
||||
guiControl.inventory.show = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
guiControl.inventory.cursorPosition = 0;
|
||||
guiControl.inventory.activateDelay = 5;
|
||||
|
|
|
@ -4,7 +4,7 @@ function mapGUI() {
|
|||
|
||||
guiControl.map = {
|
||||
show: false,
|
||||
activateDelay: 0
|
||||
activateDelay: 0,
|
||||
}
|
||||
|
||||
guiControl.map.Draw = function () {
|
||||
|
|
|
@ -13,7 +13,7 @@ guiControl.title = {
|
|||
|
||||
rowTop: function (rowNumber) {
|
||||
return pixel(32) + pixel(2) + pixel((guiControl.iconSize + 2) * rowNumber);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
guiControl.title.Draw = function () {
|
||||
|
@ -56,7 +56,7 @@ guiControl.title.Draw = function () {
|
|||
if (guiControl.title.activateDelay <= 0) {
|
||||
if (ct_confirm().down) {
|
||||
switch (guiControl.title.cursorPosition) {
|
||||
case 0:
|
||||
case 0: {
|
||||
snd_select.Play();
|
||||
mus_title.Stop();
|
||||
mus_sail.Play();
|
||||
|
@ -64,7 +64,8 @@ guiControl.title.Draw = function () {
|
|||
G.gameStarted = true;
|
||||
G.SaveGame();
|
||||
break;
|
||||
case 1:
|
||||
}
|
||||
case 1: {
|
||||
if (G.savedGameExists) { // once loading is in, allow this.
|
||||
G.LoadGame();
|
||||
snd_select.Play();
|
||||
|
@ -76,7 +77,8 @@ guiControl.title.Draw = function () {
|
|||
snd_cannotbuy.Play();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
}
|
||||
case 2: {
|
||||
if (false) { // once loading is in, allow this.
|
||||
snd_select.Play();
|
||||
guiControl.title.show = false;
|
||||
|
@ -86,6 +88,7 @@ guiControl.title.Draw = function () {
|
|||
snd_cannotbuy.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
guiControl.title.cursorPosition = 0;
|
||||
// console.log(guiControl.title.screen);
|
||||
|
|
|
@ -17,7 +17,7 @@ guiControl.trade = {
|
|||
|
||||
rowTop: function (rowNumber) {
|
||||
return (guiControl.trade.padding + pixel(6) + (guiControl.trade.padding * 3)) + pixel((guiControl.iconSize + 3) * rowNumber);
|
||||
}
|
||||
},
|
||||
}
|
||||
|
||||
guiControl.trade.Draw = function () {
|
||||
|
@ -86,7 +86,7 @@ guiControl.trade.Draw = function () {
|
|||
if (guiControl.trade.activateDelay <= 0) {
|
||||
if (ct_confirm().down) {
|
||||
switch (guiControl.trade.cursorPosition) {
|
||||
case 0:
|
||||
case 0: {
|
||||
if (guiControl.trade.island.CheckInventory().length > 0) {
|
||||
snd_select.Play();
|
||||
guiControl.trade.screen = "buy";
|
||||
|
@ -96,7 +96,8 @@ guiControl.trade.Draw = function () {
|
|||
snd_cannotbuy.Play();
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
}
|
||||
case 1: {
|
||||
if (G.inventory.CheckCargo().length > 0) {
|
||||
snd_select.Play();
|
||||
guiControl.trade.screen = "sell";
|
||||
|
@ -105,18 +106,21 @@ guiControl.trade.Draw = function () {
|
|||
snd_cannotbuy.Play();
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
}
|
||||
case 2: {
|
||||
snd_select.Play();
|
||||
guiControl.trade.screen = "tavern";
|
||||
guiControl.trade.activateDelay = 5;
|
||||
break;
|
||||
default:
|
||||
}
|
||||
default: {
|
||||
snd_cursorup.Play();
|
||||
mus_trade.Stop();
|
||||
mus_sail.Play();
|
||||
guiControl.trade.show = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// snd_select.Play();
|
||||
guiControl.trade.cursorPosition = 0;
|
||||
|
@ -196,7 +200,7 @@ guiControl.trade.Draw = function () {
|
|||
if (guiControl.trade.activateDelay <= 0) {
|
||||
if (ct_confirm().down) {
|
||||
switch (guiControl.trade.cursorPosition) {
|
||||
case 0: // Haggle
|
||||
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.
|
||||
{
|
||||
|
@ -207,7 +211,8 @@ guiControl.trade.Draw = function () {
|
|||
guiControl.trade.island.timesHaggledToday++;
|
||||
}
|
||||
break;
|
||||
case 1: // Buy
|
||||
}
|
||||
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.
|
||||
|
@ -218,13 +223,15 @@ guiControl.trade.Draw = function () {
|
|||
snd_cannotbuy.Play();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
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) {
|
||||
|
@ -303,7 +310,7 @@ guiControl.trade.Draw = function () {
|
|||
if (guiControl.trade.activateDelay <= 0) {
|
||||
if (ct_confirm().down) {
|
||||
switch (guiControl.trade.cursorPosition) {
|
||||
case 0: // Haggle
|
||||
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.
|
||||
{
|
||||
|
@ -314,7 +321,8 @@ guiControl.trade.Draw = function () {
|
|||
guiControl.trade.island.timesHaggledToday++;
|
||||
}
|
||||
break;
|
||||
case 1: // Sell
|
||||
}
|
||||
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.
|
||||
|
@ -325,13 +333,15 @@ guiControl.trade.Draw = function () {
|
|||
snd_cannotbuy.Play();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
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) {
|
||||
|
@ -379,13 +389,14 @@ guiControl.trade.Draw = function () {
|
|||
if (guiControl.trade.activateDelay <= 0) {
|
||||
if (ct_confirm().down) {
|
||||
switch (guiControl.trade.cursorPosition) {
|
||||
case 0:
|
||||
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:
|
||||
}
|
||||
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();
|
||||
|
@ -393,13 +404,15 @@ guiControl.trade.Draw = function () {
|
|||
snd_cannotbuy.Play();
|
||||
}
|
||||
break;
|
||||
default:
|
||||
}
|
||||
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;
|
||||
|
|
14
index.html
14
index.html
|
@ -41,12 +41,15 @@
|
|||
|
||||
<section>
|
||||
<h2>
|
||||
<a id="about" class="anchor" href="#about" aria-hidden="true"><span aria-hidden="true" class="octicon octicon-link"></span></a>About</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 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>
|
||||
|
@ -104,8 +107,7 @@
|
|||
<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>
|
||||
</div>
|
||||
<!--[if !IE]><script>fixScale(document);</script><![endif]-->
|
||||
</body>
|
||||
</html>
|
|
@ -16,5 +16,4 @@ fixScale = function(doc) {
|
|||
scales = [.25, 1.6];
|
||||
doc[addEvent](type, fix, true);
|
||||
}
|
||||
|
||||
};
|
|
@ -22,7 +22,7 @@ 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
|
||||
up : ct_wasd_up.up || ct_arrow_up.up,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -30,7 +30,7 @@ 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
|
||||
up : ct_wasd_left.up || ct_arrow_left.up,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -38,7 +38,7 @@ 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
|
||||
up : ct_wasd_down.up || ct_arrow_down.up,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -46,7 +46,7 @@ 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
|
||||
up : ct_wasd_right.up || ct_arrow_right.up,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,7 +54,7 @@ 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
|
||||
up : ct_space.up || ct_z.up,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,6 +62,6 @@ 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
|
||||
up : ct_shift.up || ct_x.up,
|
||||
}
|
||||
}
|
||||
|
|
126
loadGUIs.js
126
loadGUIs.js
|
@ -165,175 +165,217 @@ guiControl.drawPixelText = function (text, x, y, wrapWidth, color, size) {
|
|||
for (var i = 0; i < text.length; i++) {
|
||||
var letterCellX, letterCellY;
|
||||
switch (text.charAt(i)) {
|
||||
case "A":
|
||||
case "A": {
|
||||
letterCellX = 0;
|
||||
letterCellY = 0;
|
||||
break;
|
||||
case "B":
|
||||
}
|
||||
case "B": {
|
||||
letterCellX = 1;
|
||||
letterCellY = 0;
|
||||
break;
|
||||
case "C":
|
||||
}
|
||||
case "C": {
|
||||
letterCellX = 2;
|
||||
letterCellY = 0;
|
||||
break;
|
||||
case "D":
|
||||
}
|
||||
case "D": {
|
||||
letterCellX = 3;
|
||||
letterCellY = 0;
|
||||
break;
|
||||
case "E":
|
||||
}
|
||||
case "E": {
|
||||
letterCellX = 4;
|
||||
letterCellY = 0;
|
||||
break;
|
||||
case "F":
|
||||
}
|
||||
case "F": {
|
||||
letterCellX = 5;
|
||||
letterCellY = 0;
|
||||
break;
|
||||
case "G":
|
||||
}
|
||||
case "G": {
|
||||
letterCellX = 0;
|
||||
letterCellY = 1;
|
||||
break;
|
||||
case "H":
|
||||
}
|
||||
case "H": {
|
||||
letterCellX = 1;
|
||||
letterCellY = 1;
|
||||
break;
|
||||
case "I":
|
||||
}
|
||||
case "I": {
|
||||
letterCellX = 2;
|
||||
letterCellY = 1;
|
||||
break;
|
||||
case "J":
|
||||
}
|
||||
case "J": {
|
||||
letterCellX = 3;
|
||||
letterCellY = 1;
|
||||
break;
|
||||
case "K":
|
||||
}
|
||||
case "K": {
|
||||
letterCellX = 4;
|
||||
letterCellY = 1;
|
||||
break;
|
||||
case "L":
|
||||
}
|
||||
case "L": {
|
||||
letterCellX = 5;
|
||||
letterCellY = 1;
|
||||
break;
|
||||
case "M":
|
||||
}
|
||||
case "M": {
|
||||
letterCellX = 0;
|
||||
letterCellY = 2;
|
||||
break;
|
||||
case "N":
|
||||
}
|
||||
case "N": {
|
||||
letterCellX = 1;
|
||||
letterCellY = 2;
|
||||
break;
|
||||
case "O":
|
||||
}
|
||||
case "O": {
|
||||
letterCellX = 2;
|
||||
letterCellY = 2;
|
||||
break;
|
||||
case "P":
|
||||
}
|
||||
case "P": {
|
||||
letterCellX = 3;
|
||||
letterCellY = 2;
|
||||
break;
|
||||
case "Q":
|
||||
}
|
||||
case "Q": {
|
||||
letterCellX = 4;
|
||||
letterCellY = 2;
|
||||
break;
|
||||
case "R":
|
||||
}
|
||||
case "R": {
|
||||
letterCellX = 5;
|
||||
letterCellY = 2;
|
||||
break;
|
||||
case "S":
|
||||
}
|
||||
case "S": {
|
||||
letterCellX = 0;
|
||||
letterCellY = 3;
|
||||
break;
|
||||
case "T":
|
||||
}
|
||||
case "T": {
|
||||
letterCellX = 1;
|
||||
letterCellY = 3;
|
||||
break;
|
||||
case "U":
|
||||
}
|
||||
case "U": {
|
||||
letterCellX = 2;
|
||||
letterCellY = 3;
|
||||
break;
|
||||
case "V":
|
||||
}
|
||||
case "V": {
|
||||
letterCellX = 3;
|
||||
letterCellY = 3;
|
||||
break;
|
||||
case "W":
|
||||
}
|
||||
case "W": {
|
||||
letterCellX = 4;
|
||||
letterCellY = 3;
|
||||
break;
|
||||
case "X":
|
||||
}
|
||||
case "X": {
|
||||
letterCellX = 5;
|
||||
letterCellY = 3;
|
||||
break;
|
||||
case "Y":
|
||||
}
|
||||
case "Y": {
|
||||
letterCellX = 0;
|
||||
letterCellY = 4;
|
||||
break;
|
||||
case "Z":
|
||||
}
|
||||
case "Z": {
|
||||
letterCellX = 1;
|
||||
letterCellY = 4;
|
||||
break;
|
||||
case "1":
|
||||
}
|
||||
case "1": {
|
||||
letterCellX = 2;
|
||||
letterCellY = 4;
|
||||
break;
|
||||
case "2":
|
||||
}
|
||||
case "2": {
|
||||
letterCellX = 3;
|
||||
letterCellY = 4;
|
||||
break;
|
||||
case "3":
|
||||
}
|
||||
case "3": {
|
||||
letterCellX = 4;
|
||||
letterCellY = 4;
|
||||
break;
|
||||
case "4":
|
||||
}
|
||||
case "4": {
|
||||
letterCellX = 5;
|
||||
letterCellY = 4;
|
||||
break;
|
||||
case "5":
|
||||
}
|
||||
case "5": {
|
||||
letterCellX = 0;
|
||||
letterCellY = 5;
|
||||
break;
|
||||
case "6":
|
||||
}
|
||||
case "6": {
|
||||
letterCellX = 1;
|
||||
letterCellY = 5;
|
||||
break;
|
||||
case "7":
|
||||
}
|
||||
case "7": {
|
||||
letterCellX = 2;
|
||||
letterCellY = 5;
|
||||
break;
|
||||
case "8":
|
||||
}
|
||||
case "8": {
|
||||
letterCellX = 3;
|
||||
letterCellY = 5;
|
||||
break;
|
||||
case "9":
|
||||
}
|
||||
case "9": {
|
||||
letterCellX = 4;
|
||||
letterCellY = 5;
|
||||
break;
|
||||
case "0":
|
||||
}
|
||||
case "0": {
|
||||
letterCellX = 5;
|
||||
letterCellY = 5;
|
||||
break;
|
||||
case ".":
|
||||
}
|
||||
case ".": {
|
||||
letterCellX = 0;
|
||||
letterCellY = 6;
|
||||
break;
|
||||
case ",":
|
||||
}
|
||||
case ",": {
|
||||
letterCellX = 1;
|
||||
letterCellY = 6;
|
||||
break;
|
||||
case "-":
|
||||
}
|
||||
case "-": {
|
||||
letterCellX = 2;
|
||||
letterCellY = 6;
|
||||
break;
|
||||
case "?":
|
||||
}
|
||||
case "?": {
|
||||
letterCellX = 3;
|
||||
letterCellY = 6;
|
||||
break;
|
||||
case "!":
|
||||
}
|
||||
case "!": {
|
||||
letterCellX = 4;
|
||||
letterCellY = 6;
|
||||
break;
|
||||
default: // Default to Space
|
||||
}
|
||||
default: {// Default to Space
|
||||
letterCellX = 5;
|
||||
letterCellY = 6;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
var lineNumber = Math.floor(i/wrapWidth);
|
||||
var horizontal = i - (wrapWidth * lineNumber);
|
||||
|
|
|
@ -75,7 +75,7 @@ G.stats = {
|
|||
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.
|
||||
illness: 0, // Your crew's overall health. When this is low, your ship slows down.
|
||||
};
|
||||
|
||||
G.economy = { // Aww yea, supply and demand.
|
||||
|
@ -113,7 +113,7 @@ G.economy = { // Aww yea, supply and demand.
|
|||
}
|
||||
G.economy.innCost += Math.round(totalInnCost / G.map.length); // Apply the average inn price.
|
||||
// console.log(G.economy.cargoItemWorth);
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
G.SaveGame = function () {
|
||||
|
@ -134,16 +134,16 @@ G.SaveGame = function () {
|
|||
crew: G.stats.crew,
|
||||
energy: G.stats.energy,
|
||||
maxEnergy: G.stats.maxEnergy,
|
||||
illness: G.stats.illness
|
||||
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()
|
||||
cargoBought: G.economy.cargoBought.slice(),
|
||||
},
|
||||
map: []
|
||||
map: [],
|
||||
};
|
||||
for (var i = 0; i < G.map.length; i++) {
|
||||
saveObject.map.push({
|
||||
|
@ -156,7 +156,7 @@ G.SaveGame = function () {
|
|||
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()
|
||||
itemsBought: G.map[i].island.itemsBought.slice(),
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -15,8 +15,7 @@ function 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"])
|
||||
{
|
||||
if (prefabsLoaded < prefabsToLoad || !window["oceanRoom"]) {
|
||||
setTimeout(function(){WaitForPrefabsToLoad()}, 0.1);
|
||||
} else {
|
||||
// Create player and ocean objects in rm_Ocean.
|
||||
|
|
|
@ -8,7 +8,7 @@ var rm_Ocean = OS.R.Add("Ocean Room", {
|
|||
squaresY: 44,
|
||||
squareSize: pixel(64),
|
||||
numberOfIslands: 10,
|
||||
clockTimerCutoff: ((1 / OS.S.defaultStep) * 60) * 5 // 5 minute day.
|
||||
clockTimerCutoff: ((1 / OS.S.defaultStep) * 60) * 5, // 5 minute day.
|
||||
});
|
||||
|
||||
function loadRooms() {
|
||||
|
|
|
@ -59,7 +59,7 @@ var pr_island = OS.P.Add("Island", {
|
|||
storage: [0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0,
|
||||
0, 0, 0, 0]
|
||||
0, 0, 0, 0],
|
||||
});
|
||||
|
||||
pr_island.DoFirst = function () {
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
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() {
|
||||
if (Oversimplified.DEBUG.showMessages) console.log("Ran oceanTilePrefab()");
|
||||
|
@ -41,43 +41,52 @@ pr_ocean.CheckPosition = function (checkX, checkY, direction) {
|
|||
(Math.abs(this.y - checkY) > (OS.camera.height + this.yBound)))
|
||||
{
|
||||
switch (direction) {
|
||||
case 0:
|
||||
case 0: {
|
||||
this.x = checkX + (OS.camera.width + this.xBound) + randomSmidge();
|
||||
this.y = checkY + randomSmidge();
|
||||
break;
|
||||
case 45:
|
||||
}
|
||||
case 45: {
|
||||
this.x = checkX + (OS.camera.width + this.xBound) + randomSmidge();
|
||||
this.y = checkY - (OS.camera.height + this.yBound) + randomSmidge();
|
||||
break;
|
||||
case 90:
|
||||
}
|
||||
case 90: {
|
||||
this.x = checkX + randomSmidge();
|
||||
this.y = checkY - (OS.camera.height + this.yBound) + randomSmidge();
|
||||
break;
|
||||
case 135:
|
||||
}
|
||||
case 135: {
|
||||
this.x = checkX - (OS.camera.width + this.xBound) + randomSmidge();
|
||||
this.y = checkY - (OS.camera.height + this.yBound) + randomSmidge();
|
||||
break;
|
||||
case 180:
|
||||
}
|
||||
case 180: {
|
||||
this.x = checkX - (OS.camera.width + this.xBound) + randomSmidge();
|
||||
this.y = checkY + randomSmidge();
|
||||
break;
|
||||
case 225:
|
||||
}
|
||||
case 225: {
|
||||
this.x = checkX - (OS.camera.width + this.xBound) + randomSmidge();
|
||||
this.y = checkY + (OS.camera.height + this.yBound) + randomSmidge();
|
||||
break;
|
||||
case 270:
|
||||
}
|
||||
case 270: {
|
||||
this.x = checkX + randomSmidge();
|
||||
this.y = checkY + (OS.camera.height + this.yBound) + randomSmidge();
|
||||
break;
|
||||
case 315:
|
||||
}
|
||||
case 315: {
|
||||
this.x = checkX + (OS.camera.width + this.xBound) + randomSmidge();
|
||||
this.y = checkY + (OS.camera.height + this.yBound) + randomSmidge();
|
||||
break;
|
||||
default:
|
||||
}
|
||||
default: {
|
||||
console.log("No valid direction");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.doCheckPosition = false;
|
||||
}
|
||||
|
|
|
@ -29,7 +29,7 @@ var pr_ship = OS.P.Add("Ship", {
|
|||
energyRefillTimer: 0,
|
||||
|
||||
drawSickIndicator: 0,
|
||||
drawSickIndicatorTime: secondsWorthOfFrames(1.5)
|
||||
drawSickIndicatorTime: secondsWorthOfFrames(1.5),
|
||||
});
|
||||
|
||||
pr_ship.BeforeDo = function () {
|
||||
|
@ -120,58 +120,67 @@ pr_ship.CheckMovement = function () {
|
|||
var moveAmount = pixel(G.stats.speed + this.currentSpeed);
|
||||
var movedSuccessfully = false;
|
||||
switch (this.direction) {
|
||||
case 0:
|
||||
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:
|
||||
}
|
||||
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:
|
||||
}
|
||||
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:
|
||||
}
|
||||
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:
|
||||
}
|
||||
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:
|
||||
}
|
||||
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:
|
||||
}
|
||||
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:
|
||||
}
|
||||
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:
|
||||
}
|
||||
default: {
|
||||
console.log("No valid direction");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (this.doTakeStep && !movedSuccessfully) {
|
||||
this.currentSpeed = 0;
|
||||
|
|
|
@ -24,7 +24,7 @@ rm_Ocean.DoFirst = function () {
|
|||
OS.SetCamera({
|
||||
x: G.player.x - (OS.camera.width / 2),
|
||||
y: G.player.y - (OS.camera.height / 2),
|
||||
objectToFollow: G.player
|
||||
objectToFollow: G.player,
|
||||
});
|
||||
|
||||
this.mapLeftTrigger = OS.camera.hBorder;
|
||||
|
@ -171,7 +171,7 @@ rm_Ocean.GenerateMap = function () {
|
|||
drawX: xSquares[i],
|
||||
drawY: ySquares[i],
|
||||
drawWidth: 1,
|
||||
drawHeight: 1
|
||||
drawHeight: 1,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
6
start.js
6
start.js
|
@ -6,10 +6,10 @@ OS.SetCamera({
|
|||
width: pixel(160), // 640
|
||||
height: pixel(120), // 480
|
||||
hBorder: pixel(64),
|
||||
vBorder: pixel(48)});
|
||||
vBorder: pixel(48),
|
||||
});
|
||||
|
||||
function start()
|
||||
{
|
||||
function start() {
|
||||
OS.AddScript("loadControls.js");
|
||||
OS.AddScript("loadAudio.js");
|
||||
OS.AddScript("loadGameManager.js");
|
||||
|
|
|
@ -34,7 +34,6 @@ body {
|
|||
margin: 0;
|
||||
line-height: 1.8em;
|
||||
-webkit-font-smoothing: antialiased;
|
||||
|
||||
}
|
||||
|
||||
h1, h2, h3, h4, h5, h6 {
|
||||
|
|
Loading…
Reference in New Issue