Permalink
Browse files

work on geeko level

  • Loading branch information...
1 parent f1a0b9f commit e139fc5a621fb28fb12d9c1b6bac307f50ea4804 @digitaltom committed Dec 28, 2012
Showing with 145 additions and 51 deletions.
  1. +2 −10 index.html
  2. +89 −0 index_all.html
  3. +8 −3 js/game.js
  4. +14 −13 js/levels.js
  5. +32 −25 js/menu.js
  6. BIN themes/suse/images/game_tiles.png
View
12 index.html
@@ -23,19 +23,11 @@
<div id="game-menu" class="game-info">
<div class="menu-item menu-text" id="intro">
- <p>Welcome to Tom's HTML5 Jump&Run Framework.</p>
-
- <p>Please choose your level:</p>
+ <p>Welcome to the Geeko challenge!</p>
</div>
- <div class="menu-item menu-link" id="button-play1">
- Play Super Mario Level 1
- </div>
- <div class="menu-item menu-link" id="button-play2">
- Play Snoopy
- </div>
<div class="menu-item menu-link" id="button-play3">
- Play SUSE
+ Start
</div>
<div class="menu-item menu-text" id="help">
View
89 index_all.html
@@ -0,0 +1,89 @@
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
+<head>
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
+
+ <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
+ <meta name="apple-mobile-web-app-capable" content="yes"/>
+ <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
+
+ <title>Hackweek game</title>
+
+ <link href="css/game.css" rel="stylesheet" type="text/css">
+ <link href="css/pad-controls.css" rel="stylesheet" type="text/css">
+</head>
+<body>
+
+
+<div id="game-container">
+ <canvas id="game">
+ Guru meditation: No &lt;canvas&gt; element supported!
+ </canvas>
+
+ <div id="game-menu" class="game-info">
+
+ <div class="menu-item menu-text" id="intro">
+ <p>Welcome to Tom's HTML5 Jump&Run Framework.</p>
+
+ <p>Please choose your level:</p>
+ </div>
+
+ <div class="menu-item menu-link" id="button-play1">
+ Play Super Mario Level 1
+ </div>
+ <div class="menu-item menu-link" id="button-play2">
+ Play Snoopy
+ </div>
+ <div class="menu-item menu-link" id="button-play3">
+ Play SUSE
+ </div>
+
+ <div class="menu-item menu-text" id="help">
+ <p>You can use use your arrow keys, or pad controls to play.</p>
+ </div>
+
+ </div>
+
+ <div id="game-over" class="game-info">
+ <div class="menu-item menu-link" id="button-restart">
+ Play again
+ </div>
+ <div class="menu-item menu-link" id="button-menu">
+ Back to main menu
+ </div>
+ </div>
+
+
+ <div id="pad-controls">
+ <div class="controls-wrapper controls-left">
+ <ul>
+ <li class="cross" id="control-up"></li>
+ </ul>
+ </div>
+ <div class="controls-wrapper controls-right">
+ <ul>
+ <li id="control-left"></li>
+ <li id="control-right"></li>
+ </ul>
+ </div>
+ </div>
+
+
+</div>
+
+
+<!-- don't forget the charset here, else the levels will be parsed incorrectly -->
+<script type="text/javascript" src="js/menu.js" charset="utf-8"></script>
+<script type="text/javascript" src="js/levels.js" charset="utf-8"></script>
+<script type="text/javascript" src="js/game.js" charset="utf-8"></script>
+<script type="text/javascript" src="js/controls.js" charset="utf-8"></script>
+<script type="text/javascript" src="js/sounds.js" charset="utf-8"></script>
+
+
+<!-- <a href="https://github.com/digitaltom/hackweek">
+ <img style="position: absolute; top: 0; right: 0; border: 0;"
+ src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"
+ alt="Fork me on GitHub"></a> -->
+
+</body>
+</html>
View
11 js/game.js
@@ -7,7 +7,7 @@ var debug = false;
// default theme and level
var theme = 'snoop'
-var current_level = levels[2];
+var current_level = levels[1];
var gameInterval;
var score
@@ -127,7 +127,7 @@ function drawLevel() {
/* used characters: # x H k h / ^ ü g ` { = } @ 1 2 3 4 5 6 ?
* ß q w a s b p \ ° R | * W U B O X l j ( ) [ ]]
- * z */
+ * z 8 */
switch (linecontent.charAt(index_x)) {
case '#':
object.sx = 5;
@@ -332,6 +332,11 @@ function drawLevel() {
object.sy = 9;
collisionMap.push(object);
break;
+ case '8':
+ object.sx = 0;
+ object.sy = 6;
+ collisionMap.push(object);
+ break;
default:
}
if (object.sx != null && object.sy != null) {
@@ -646,7 +651,7 @@ function initializeLevel() {
score = 0
player.pos.x = 2 * size.tile.target.w
player.pos.y = 5 * size.tile.target.h
- scroll_x = player.pos.x - size.canvas.w / 2
+ scroll_x = player.pos.x - (document.documentElement.clientWidth - 4) / 2
theme = current_level.theme
}
View
27 js/levels.js
@@ -20,19 +20,20 @@ var levels = [
name:"SUSE",
theme:'suse',
template:[
- " 123 ###### ######## ###### ##### ",
- " 456 ",
- " ####### #### # # #### #### ",
- " # # # # # ",
- " zzzzz #### # # #### ### ",
- " ###### # # # # # ",
- " zzz?z #### #### #### #### ",
- " ",
- " p p ",
- " ~~~~ zzzzzzzzzzzzzzzzzzzzzz ###################### ",
- " ^ ",
- " /ü` ",
- "xxxxxxxxxxx@@@@@@@@@@@@@@@@@@@@@@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
+ " p ",
+ " 123 zzzzzz zzzzzzzz zzzzzz zzzzz ",
+ " 456 ",
+ " zzzzzzz zzzz z z zzzz zzzz ",
+ " z z z z z ",
+ " zzzzz zzzz z z zzzz zz? ",
+ " zzz??z z z z z z ",
+ " zzz?z ?zzz zzzz z?zz zzzz ",
+ " ",
+ " p p p p p ",
+ " ~~~~ zzzzzzzzzzzzzzzzzzzzzz zzzzzzz?z?z?z?zzzzzzzz ",
+ " ^ ",
+ " /ü` B ",
+ "88888888888@@@@@@@@@@@@@@@@@@@@@@88888888888888888888888888888888888888888888888888"
]
},
{
View
57 js/menu.js
@@ -5,35 +5,42 @@ function hideMenus() {
// Main menu
-document.getElementById("button-play1").addEventListener('click', function (event) {
- current_level = levels[2];
- startGame();
-}, false);
-
-document.getElementById("button-play1").addEventListener('mouseover', function (event) {
- current_level = levels[2];
- load_level()
-}, false);
+var button;
+if (button = document.getElementById("button-play1")) {
+ button.addEventListener('click', function (event) {
+ current_level = levels[2];
+ startGame();
+ }, false);
+
+ button.addEventListener('mouseover', function (event) {
+ current_level = levels[2];
+ load_level()
+ }, false);
+}
-document.getElementById("button-play2").addEventListener('click', function (event) {
- current_level = levels[0];
- startGame();
-}, false);
+if (button = document.getElementById("button-play2")) {
+ button.addEventListener('click', function (event) {
+ current_level = levels[0];
+ startGame();
+ }, false);
-document.getElementById("button-play2").addEventListener('mouseover', function (event) {
- current_level = levels[0];
- load_level()
-}, false);
+ button.addEventListener('mouseover', function (event) {
+ current_level = levels[0];
+ load_level()
+ }, false);
+}
-document.getElementById("button-play3").addEventListener('click', function (event) {
- current_level = levels[1];
- startGame();
-}, false);
+if (button = document.getElementById("button-play3")) {
+ button.addEventListener('click', function (event) {
+ current_level = levels[1];
+ startGame();
+ }, false);
-document.getElementById("button-play3").addEventListener('mouseover', function (event) {
- current_level = levels[1];
- load_level()
-}, false);
+ button.addEventListener('mouseover', function (event) {
+ current_level = levels[1];
+ load_level()
+ }, false);
+}
var start_menu = document.getElementById("game-menu");
View
BIN themes/suse/images/game_tiles.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit e139fc5

Please sign in to comment.