Commit f96e8f14 authored by Christof Musik's avatar Christof Musik
Browse files

adde fullscreen mode, vibrate on hitting a wall

parent b36d6d8e
......@@ -58,15 +58,16 @@ MainAssistant.prototype.setup = function(){
}
MainAssistant.prototype.activate = function(event){
this.controller.enableFullScreenMode(true);
}
MainAssistant.prototype.deactivate = function(event){
Mojo.Event.stopListening(this.controller.document, 'keypress', this.keyPressEventHandler);
this.levelSettings.remove();
this.levelSettings.remove();
this.levelSettings.put({
"level": this.currentLevel
});
var t = this.levelSettings.get();
var t = this.levelSettings.get();
Mojo.Log.info("saving game state! level: %d - %d", t.level, this.currentLevel);
}
......@@ -100,7 +101,7 @@ MainAssistant.prototype.initLevel = function(l){
this.ctx.save();
Mojo.Log.info("width: %d, blockSize: %d", this.width, this.blockSize);
this.ctx.translate((320 - this.width * this.blockSize) / 2, (460 - (this.height * this.blockSize)) / 2);
this.ctx.translate((320 - this.width * this.blockSize) / 2, (480 - (this.height * this.blockSize)) / 2);
this.drawLevel();
}
......@@ -167,6 +168,7 @@ MainAssistant.prototype.handleKeyPress = function(event){
this.drawFigure();
}
else {
Mojo.Controller.getAppController().playSoundNotification("vibrate", "");
this.position = currentPos;
}
......@@ -302,8 +304,14 @@ MainAssistant.prototype.calculateBoxSize = function(){
Mojo.Log.info("w: %d, h: %d", w, h);
if (w / h > this.width / this.height) {
this.blockSize = Math.floor(h / this.height);
}
else {
this.blockSize = Math.floor(w / this.width);
}
this.blockSize = Math.floor(w / this.width);
}
MainAssistant.prototype.drawLevel = function(){
......@@ -444,9 +452,9 @@ MainAssistant.prototype.drawWall = function(x, y){
this.ctx.fillStyle = "rgb(80,80,80)";
this.ctx.strokeStyle = "rgb(50,50,50)";
this.ctx.lineWidth = 4;
var d = Math.ceil(bs/3);
this.ctx.lineWidth = 4;
var d = Math.ceil(bs / 3);
switch (t) {
// alone
......@@ -550,17 +558,17 @@ MainAssistant.prototype.drawTarget = function(x, y){
}
MainAssistant.prototype.drawFigure = function(){
var bs = this.blockSize;
var bs = this.blockSize;
this.ctx.fillStyle = "rgb(0,0,255)";
this.drawEmpty(this.position.x, this.position.y);
this.drawEmpty(this.position.x, this.position.y);
this.ctx.fillStyle = "rgb(0,0,200)";
this.ctx.beginPath();
this.ctx.arc(this.position.x*bs+Math.ceil(bs/2), this.position.y*bs+Math.ceil(bs/2), bs/4, 0, 2*Math.PI);
this.ctx.fill();
this.ctx.beginPath();
this.ctx.arc(this.position.x*bs+Math.ceil(bs/2), this.position.y*bs+Math.ceil(bs/2), bs/2.5, 0, 2*Math.PI);
this.ctx.stroke();
this.ctx.beginPath();
this.ctx.arc(this.position.x * bs + Math.ceil(bs / 2), this.position.y * bs + Math.ceil(bs / 2), bs / 4, 0, 2 * Math.PI);
this.ctx.fill();
this.ctx.beginPath();
this.ctx.arc(this.position.x * bs + Math.ceil(bs / 2), this.position.y * bs + Math.ceil(bs / 2), bs / 2.5, 0, 2 * Math.PI);
this.ctx.stroke();
}
MainAssistant.prototype.showLevelDoneDialog = function(){
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment