diff --git a/rose/web/game.css b/rose/web/game.css index 3d676dd0..480a6953 100644 --- a/rose/web/game.css +++ b/rose/web/game.css @@ -35,7 +35,7 @@ body { background-color: #222; } -#start, #stop, #music_ctl { +#start, #stop, #music_ctl, #settings { width: 120px; padding: 8px 24px; margin: 0; @@ -129,3 +129,43 @@ body { #game { border: 1px #666 solid; } + + +/* The Modal (background) */ +.modal { + display: none; /* Hidden by default */ + position: fixed; /* Stay in place */ + z-index: 1; /* Sit on top */ + padding-top: 100px; /* Location of the box */ + left: 0; + top: 0; + width: 100%; /* Full width */ + height: 100%; /* Full height */ + overflow: auto; /* Enable scroll if needed */ + background-color: rgb(0,0,0); /* Fallback color */ + background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ +} + +/* Modal Content */ +.modal-content { + background-color: #fefefe; + margin: auto; + padding: 20px; + border: 1px solid #888; + width: 80%; +} + +/* The Close Button */ +.close { + color: #aaaaaa; + float: right; + font-size: 28px; + font-weight: bold; +} + +.close:hover, +.close:focus { + color: #000; + text-decoration: none; + cursor: pointer; +} \ No newline at end of file diff --git a/rose/web/game.js b/rose/web/game.js index ed1afc45..92330eb3 100644 --- a/rose/web/game.js +++ b/rose/web/game.js @@ -1,3 +1,14 @@ +function GetParameterValues(param) { + var url = window.location.href.slice(window.location.href.indexOf('?') + 1).split('&'); + for (var i = 0; i < url.length; i++) { + var urlparam = url[i].split('='); + if (urlparam[0] == param) { + return urlparam[1]; + } + } + return 'default'; +} +var theme = GetParameterValues("theme"); var ROSE = (function() { "use strict"; @@ -27,7 +38,19 @@ var ROSE = (function() { this.obstacles = new Obstacles(image_loader); this.cars = new Cars(image_loader); this.finish_line = new FinishLine(image_loader); - this.sound = new Sound("res/soundtrack/Nyan_Cat.ogg"); + this.sound = new Sound(`res/themes/${theme}/soundtrack/soundtrack.ogg`); + + console.log(this.theme); + // Get the element that closes the modal + var modal = document.getElementById("myModal"); + + var span = document.getElementsByClassName("close")[0]; + + // When the user clicks on (x), close the modal + span.onclick = function() { + modal.style.display = "none"; + } + } App.prototype.onmessage = function(m) { @@ -102,6 +125,19 @@ var ROSE = (function() { event.preventDefault(); self.stop(); }); + + $("#settings").click(function(event) { + event.preventDefault(); +// self.settings(); + var modal = document.getElementById("myModal"); + modal.style.display = "block"; + + $( "#theme" ).on( "change", function() { + var theme = $( "#theme").val(); + window.location.replace(`http://127.0.0.1:8880/?theme=${theme}`); + } ); + + }); } Controller.prototype.start = function() { @@ -130,6 +166,10 @@ var ROSE = (function() { }) } + Controller.prototype.settings = function(){ + + } + Controller.prototype.update = function(state) { if(state.players.length == 0){ $("#info").text("No players connected") @@ -267,22 +307,22 @@ var ROSE = (function() { this.textures = {}; var self = this; - loader.load("res/obstacles/barrier.png", function(img) { + loader.load(`res/themes/${theme}/obstacles/barrier.png`, function(img) { self.textures["barrier"] = img; }); - loader.load("res/obstacles/bike.png", function(img) { + loader.load(`res/themes/${theme}/obstacles/bike.png`, function(img) { self.textures["bike"] = img; }); - loader.load("res/obstacles/crack.png", function(img) { + loader.load(`res/themes/${theme}/obstacles/crack.png`, function(img) { self.textures["crack"] = img; }); - loader.load("res/obstacles/penguin.png", function(img) { + loader.load(`res/themes/${theme}/obstacles/penguin.png`, function(img) { self.textures["penguin"] = img; }); - loader.load("res/obstacles/trash.png", function(img) { + loader.load(`res/themes/${theme}/obstacles/trash.png`, function(img) { self.textures["trash"] = img; }); - loader.load("res/obstacles/water.png", function(img) { + loader.load(`res/themes/${theme}/obstacles/water.png`, function(img) { self.textures["water"] = img; }); } @@ -306,22 +346,37 @@ var ROSE = (function() { this.players = null; this.textures = [null, null, null, null]; var self = this; - loader.load("res/cars/car1.png", function(img) { + loader.load(`res/themes/${theme}/cars/car1.png`, function(img) { self.textures[0] = img; }); - loader.load("res/cars/car2.png", function(img) { + loader.load(`res/themes/${theme}/cars/car2.png`, function(img) { self.textures[1] = img; }); - loader.load("res/cars/car3.png", function(img) { + loader.load(`res/themes/${theme}/cars/car3.png`, function(img) { self.textures[2] = img; }); - loader.load("res/cars/car4.png", function(img) { + loader.load(`res/themes/${theme}/cars/car4.png`, function(img) { self.textures[3] = img; }); } Cars.prototype.update = function(state) { this.players = state.players; + this.effect = new Audio(); + this.effect.src = "res/points_effects.mpeg"; + this.players = state.players; + console.log(state) + var i; + for(i = 0; i < state.track.length; i++){ + if (state.track[i]['x'] == state.players[0]['x'] && state.track[i]['y'] == state.players[0]['y']){ + + this.effect.play(); + + + + } + + } } Cars.prototype.draw = function(ctx) { @@ -346,7 +401,7 @@ var ROSE = (function() { this.texture = null; this.timeleft = null; var self = this; - loader.load("res/end/final_flag.png", function(img) { + loader.load(`res/themes/${theme}/end/final_flag.png`, function(img) { self.texture = img; }); } @@ -370,13 +425,13 @@ var ROSE = (function() { this.textures = [null, null, null]; var self = this; - loader.load("res/bg/bg_1.png", function(img) { + loader.load(`res/themes/${theme}/bg/bg_1.png`, function(img) { self.textures[0] = img; }); - loader.load("res/bg/bg_2.png", function(img) { + loader.load(`res/themes/${theme}/bg/bg_2.png`, function(img) { self.textures[1] = img; }); - loader.load("res/bg/bg_3.png", function(img) { + loader.load(`res/themes/${theme}/bg/bg_3.png`, function(img) { self.textures[2] = img; }); } diff --git a/rose/web/index.html b/rose/web/index.html index 27d80df2..0313c9bf 100644 --- a/rose/web/index.html +++ b/rose/web/index.html @@ -1,55 +1,76 @@ - + ROSE Game - + - -
+ -
+ +
+ + + - + +
- - + + +
- -
+ +
-
-
+
+
60
-
- +
+

Unsupported browser

-
+ -
+
- - + + - - + + + +