Skip to content

Commit

Permalink
add win treasure states. ui area
Browse files Browse the repository at this point in the history
  • Loading branch information
mrspeaker committed Apr 26, 2014
1 parent 5c98b98 commit cb0f89d
Show file tree
Hide file tree
Showing 10 changed files with 77 additions and 17 deletions.
6 changes: 3 additions & 3 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
</section>

<!-- vendors -->
<script src="lib/jquery-2.1.0.js"></script>
<script src="lib/lodash-2.4.1.js"></script>
<script src="vendor/jquery-2.1.0.js"></script>
<script src="vendor/lodash-2.4.1.js"></script>

<!-- Ω library -->
<script src="lib/Ω/Ω.js"></script>
Expand Down Expand Up @@ -71,7 +71,7 @@
<script src="scripts/Game.js"></script>

<script>
var game = new LD29(700, 300);
var game = new LD29(700, 400);

document
.querySelector("#fs")
Expand Down
4 changes: 4 additions & 0 deletions lib/Ω/screens/Screen.js
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@

},

renderPost: function (gfx) {},

_render: function (gfx) {

this.renderBG && this.renderBG(gfx);
Expand All @@ -143,6 +145,8 @@
}
this.camera.renderPost(gfx);

this.renderPost(gfx);

} else {

// Render over entire view port
Expand Down
10 changes: 9 additions & 1 deletion lib/Ω/utils/State.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,18 +9,26 @@
this.count = -1;
this.locked = false; // Um, why is this feature necessary?

this.data = null;

};

State.prototype = {

set: function (state, resetIfSame) {
set: function (state, data, resetIfSame) {

if (typeof data === Boolean) {
resetIfSame = data;
data = null;
}
if (this.locked || (state === this.state && !resetIfSame)) {
return;
}

this.last = this.state;
this.state = state;
this.count = -1;
this.data = data;

},

Expand Down
2 changes: 1 addition & 1 deletion res/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ canvas {
top: 0; left: 0; bottom: 0; right: 0;


width: 700px;
/*width: 700px;*/

/*cursor: url('data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAAZdEVYdFNvZnR3YXJlAFBhaW50Lk5FVCB2My41LjbQg61aAAAADUlEQVQYV2P4//8/IwAI/QL/+TZZdwAAAABJRU5ErkJggg=='),
none;*/
Expand Down
23 changes: 19 additions & 4 deletions scripts/entities/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@

state: null,

cash: 0,

init: function (x, y, beach) {

this._super(x, y);
this.beach = beach;
this.anims = new Ω.Anims([
new Ω.Anim("walk", this.sheet, 120, [[0, 0], [1, 0]]),
new Ω.Anim("dig", this.sheet, 120, [[0, 1], [1, 1]])
new Ω.Anim("dig", this.sheet, 120, [[0, 1], [1, 1]]),
new Ω.Anim("rockout", this.sheet, 120, [[0, 1], [0, 10]])
]);

this.state = new Ω.utils.State("BORN");
Expand Down Expand Up @@ -55,9 +58,20 @@
this.anims.set("dig");
}
if (this.state.count > 50) {
this.state.set("LOOKING");
console.log("YOu got!", this.state.data.treasure);
this.state.set("ROCKINGOUT");
}
this.anims.tick();
break;
case "ROCKINGOUT":
if (this.state.first()) {
this.anims.set("rockout");
}
this.anims.tick();
if (this.state.count > 60) {
this.state.set("LOOKING");
}

break;
}

Expand All @@ -84,8 +98,9 @@

if (!(xo || yo)) {

if (this.beach.search()) {
this.state.set("DIGGING");
var gets = this.beach.search();
if (gets) {
this.state.set("DIGGING", {treasure: gets});
return true;
}

Expand Down
1 change: 0 additions & 1 deletion scripts/levels/Beach.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
var treasure = this.treasure[blockCellPos[1]][blockCellPos[0]]
if (treasure) {
this.treasure[blockCellPos[1]][blockCellPos[0]] = 0;
console.log("found treauser");
}
return treasure;
},
Expand Down
12 changes: 11 additions & 1 deletion scripts/screens/MainScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
this.beach = this.add(new window.Beach(40, 10));
this.add(this.beach.map, "map", 1);
this.player = this.add(new window.Player(Ω.env.w * 0.5, Ω.env.h * 0.2, this.beach));
this.camera = new Ω.Camera(0, 0, Ω.env.w, Ω.env.h);
this.camera = new Ω.Camera(0, 0, Ω.env.w, Ω.env.h - 100);

},

Expand All @@ -28,7 +28,17 @@

this.clear(gfx, "hsl(198, 68%, 52%)");

},

renderPost: function (gfx) {

var c = gfx.ctx;

c.fillStyle = "hsl(200, 40%, 20%)";
c.fillRect(0, Ω.env.h - 100, Ω.env.w, 100);

}

});

window.MainScreen = MainScreen;
Expand Down
23 changes: 19 additions & 4 deletions src/entities/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,16 @@

state: null,

cash: 0,

init: function (x, y, beach) {

this._super(x, y);
this.beach = beach;
this.anims = new Ω.Anims([
new Ω.Anim("walk", this.sheet, 120, [[0, 0], [1, 0]]),
new Ω.Anim("dig", this.sheet, 120, [[0, 1], [1, 1]])
new Ω.Anim("dig", this.sheet, 120, [[0, 1], [1, 1]]),
new Ω.Anim("rockout", this.sheet, 120, [[0, 1], [0, 10]])
]);

this.state = new Ω.utils.State("BORN");
Expand Down Expand Up @@ -55,9 +58,20 @@
this.anims.set("dig");
}
if (this.state.count > 50) {
this.state.set("LOOKING");
console.log("YOu got!", this.state.data.treasure);
this.state.set("ROCKINGOUT");
}
this.anims.tick();
break;
case "ROCKINGOUT":
if (this.state.first()) {
this.anims.set("rockout");
}
this.anims.tick();
if (this.state.count > 60) {
this.state.set("LOOKING");
}

break;
}

Expand All @@ -84,8 +98,9 @@

if (!(xo || yo)) {

if (this.beach.search()) {
this.state.set("DIGGING");
var gets = this.beach.search();
if (gets) {
this.state.set("DIGGING", {treasure: gets});
return true;
}

Expand Down
1 change: 0 additions & 1 deletion src/levels/Beach.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
var treasure = this.treasure[blockCellPos[1]][blockCellPos[0]]
if (treasure) {
this.treasure[blockCellPos[1]][blockCellPos[0]] = 0;
console.log("found treauser");
}
return treasure;
},
Expand Down
12 changes: 11 additions & 1 deletion src/screens/MainScreen.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
this.beach = this.add(new window.Beach(40, 10));
this.add(this.beach.map, "map", 1);
this.player = this.add(new window.Player(Ω.env.w * 0.5, Ω.env.h * 0.2, this.beach));
this.camera = new Ω.Camera(0, 0, Ω.env.w, Ω.env.h);
this.camera = new Ω.Camera(0, 0, Ω.env.w, Ω.env.h - 100);

},

Expand All @@ -28,7 +28,17 @@

this.clear(gfx, "hsl(198, 68%, 52%)");

},

renderPost: function (gfx) {

var c = gfx.ctx;

c.fillStyle = "hsl(200, 40%, 20%)";
c.fillRect(0, Ω.env.h - 100, Ω.env.w, 100);

}

});

window.MainScreen = MainScreen;
Expand Down

0 comments on commit cb0f89d

Please sign in to comment.