Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
  • 3 commits
  • 10 files changed
  • 0 comments
  • 1 contributor
12  index.html
@@ -23,19 +23,11 @@
23 23
     <div id="game-menu" class="game-info">
24 24
 
25 25
         <div class="menu-item menu-text" id="intro">
26  
-            <p>Welcome to Tom's HTML5 Jump&Run Framework.</p>
27  
-
28  
-            <p>Please choose your level:</p>
  26
+            <p>Welcome to the Geeko challenge!</p>
29 27
         </div>
30 28
 
31  
-        <div class="menu-item menu-link" id="button-play1">
32  
-            Play Super Mario Level 1
33  
-        </div>
34  
-        <div class="menu-item menu-link" id="button-play2">
35  
-            Play Snoopy
36  
-        </div>
37 29
         <div class="menu-item menu-link" id="button-play3">
38  
-            Play SUSE
  30
+            Start
39 31
         </div>
40 32
 
41 33
         <div class="menu-item menu-text" id="help">
89  index_all.html
... ...
@@ -0,0 +1,89 @@
  1
+<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
  2
+<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  3
+<head>
  4
+    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  5
+
  6
+    <meta name="apple-mobile-web-app-status-bar-style" content="black-translucent" />
  7
+    <meta name="apple-mobile-web-app-capable" content="yes"/>
  8
+    <meta name="viewport" content="user-scalable=no, width=device-width, initial-scale=1.0, maximum-scale=1.0"/>
  9
+
  10
+    <title>Hackweek game</title>
  11
+
  12
+    <link href="css/game.css" rel="stylesheet" type="text/css">
  13
+    <link href="css/pad-controls.css" rel="stylesheet" type="text/css">
  14
+</head>
  15
+<body>
  16
+
  17
+
  18
+<div id="game-container">
  19
+    <canvas id="game">
  20
+        Guru meditation: No &lt;canvas&gt; element supported!
  21
+    </canvas>
  22
+
  23
+    <div id="game-menu" class="game-info">
  24
+
  25
+        <div class="menu-item menu-text" id="intro">
  26
+            <p>Welcome to Tom's HTML5 Jump&Run Framework.</p>
  27
+
  28
+            <p>Please choose your level:</p>
  29
+        </div>
  30
+
  31
+        <div class="menu-item menu-link" id="button-play1">
  32
+            Play Super Mario Level 1
  33
+        </div>
  34
+        <div class="menu-item menu-link" id="button-play2">
  35
+            Play Snoopy
  36
+        </div>
  37
+        <div class="menu-item menu-link" id="button-play3">
  38
+            Play SUSE
  39
+        </div>
  40
+
  41
+        <div class="menu-item menu-text" id="help">
  42
+            <p>You can use use your arrow keys, or pad controls to play.</p>
  43
+        </div>
  44
+
  45
+    </div>
  46
+
  47
+    <div id="game-over" class="game-info">
  48
+        <div class="menu-item menu-link" id="button-restart">
  49
+            Play again
  50
+        </div>
  51
+        <div class="menu-item menu-link" id="button-menu">
  52
+            Back to main menu
  53
+        </div>
  54
+    </div>
  55
+
  56
+
  57
+    <div id="pad-controls">
  58
+        <div class="controls-wrapper controls-left">
  59
+            <ul>
  60
+                <li class="cross" id="control-up"></li>
  61
+            </ul>
  62
+        </div>
  63
+        <div class="controls-wrapper controls-right">
  64
+            <ul>
  65
+                <li id="control-left"></li>
  66
+                <li id="control-right"></li>
  67
+            </ul>
  68
+        </div>
  69
+    </div>
  70
+
  71
+
  72
+</div>
  73
+
  74
+
  75
+<!-- don't forget the charset here, else the levels will be parsed incorrectly -->
  76
+<script type="text/javascript" src="js/menu.js" charset="utf-8"></script>
  77
+<script type="text/javascript" src="js/levels.js" charset="utf-8"></script>
  78
+<script type="text/javascript" src="js/game.js" charset="utf-8"></script>
  79
+<script type="text/javascript" src="js/controls.js" charset="utf-8"></script>
  80
+<script type="text/javascript" src="js/sounds.js" charset="utf-8"></script>
  81
+
  82
+
  83
+<!-- <a href="https://github.com/digitaltom/hackweek">
  84
+    <img style="position: absolute; top: 0; right: 0; border: 0;"
  85
+         src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png"
  86
+         alt="Fork me on GitHub"></a> -->
  87
+
  88
+</body>
  89
+</html>
31  js/game.js
... ...
@@ -1,15 +1,13 @@
1 1
 var ctx;
2 2
 var ticks = 0;
3 3
 var spriteMap = new Image;
4  
-var itemMap = new Image;
5  
-var enemyMap = new Image;
6 4
 var actors;
7 5
 var items;
8 6
 var debug = false;
9 7
 
10 8
 // default theme and level
11 9
 var theme = 'snoop'
12  
-var current_level = levels[2];
  10
+var current_level = levels[1];
13 11
 
14 12
 var gameInterval;
15 13
 var score
@@ -126,6 +124,10 @@ function drawLevel() {
126 124
             for (var index_x = index_x_start; index_x < index_x_max; index_x++) {
127 125
 
128 126
                 var object = { sx:null, sy:null, x:((index_x) * tw) - offset_x, y:index_y * th, deadly:false, solid:true };
  127
+
  128
+                /* used characters: # x H k h / ^ ü g ` { = } @ 1 2 3 4 5 6 ?
  129
+                *                   ß q w a s b p \ ° R | * W U B O X l j ( ) [ ]]
  130
+                *                   z 8 */
129 131
                 switch (linecontent.charAt(index_x)) {
130 132
                     case '#':
131 133
                         object.sx = 5;
@@ -151,7 +153,6 @@ function drawLevel() {
151 153
                         object.sx = 12;
152 154
                         object.sy = 6;
153 155
                         object.deadly = true;
154  
-                        object.solid = false;
155 156
                         collisionMap.push(object);
156 157
                         break;
157 158
                     case '/':
@@ -326,6 +327,16 @@ function drawLevel() {
326 327
                         object.sx = 12;
327 328
                         object.sy = 1;
328 329
                         break;
  330
+                    case 'z':
  331
+                        object.sx = 9;
  332
+                        object.sy = 9;
  333
+                        collisionMap.push(object);
  334
+                        break;
  335
+                    case '8':
  336
+                        object.sx = 0;
  337
+                        object.sy = 6;
  338
+                        collisionMap.push(object);
  339
+                        break;
329 340
                     default:
330 341
                 }
331 342
                 if (object.sx != null && object.sy != null) {
@@ -550,11 +561,9 @@ function updateElements() {
550 561
                 sprite_collide = getLevelSpriteXY(item.x, item.y)
551 562
             }
552 563
             sprite_bottom = getLevelSpriteXY(item.x + size.tile.target.w / 2, item.y + size.tile.target.h)
553  
-            if (sprite_collide == "x" || sprite_collide == "a" || sprite_collide == "s" || sprite_collide == "#" || sprite_collide == "H" ||
554  
-                item.x <= 0) {
555  
-                item.speed_x *= -1
556  
-            }
557  
-            if (sprite_bottom != "x" && sprite_bottom != "#" && sprite_bottom != "?" && sprite_bottom != "ß") {
  564
+            // turn around on collide or above edge
  565
+            if (['z', 'x', 'a', 's', '#', 'H'].indexOf(sprite_collide) >= 0 ||
  566
+                ['z', 'x', '#', '?', 'ß'].indexOf(sprite_bottom) < 0 || item.x <= 0) {
558 567
                 item.speed_x *= -1
559 568
             }
560 569
             item.x += item.speed_x
@@ -642,14 +651,12 @@ function initializeLevel() {
642 651
     score = 0
643 652
     player.pos.x = 2 * size.tile.target.w
644 653
     player.pos.y = 5 * size.tile.target.h
645  
-    scroll_x = player.pos.x - size.canvas.w / 2
  654
+    scroll_x = player.pos.x - (document.documentElement.clientWidth - 4) / 2
646 655
     theme = current_level.theme
647 656
 }
648 657
 
649 658
 function initializeTheme() {
650 659
     spriteMap.src = 'themes/' + theme + '/images/game_tiles.png';
651  
-    itemMap.src = 'themes/' + theme + '/images/item_tiles.png';
652  
-    enemyMap.src = 'themes/' + theme + '/images/enemy_tiles.png';
653 660
     player.spriteMap.src = 'themes/' + theme + '/images/player_sprites.png';
654 661
     player.sprite.x = 0
655 662
     player.sprite.y = 32
27  js/levels.js
@@ -20,19 +20,20 @@ var levels = [
20 20
         name:"SUSE",
21 21
         theme:'suse',
22 22
         template:[
23  
-            "  123                 ######     ########    ######    #####  ",
24  
-            "  456                                                         ",
25  
-            "           #######                  #### #  # #### ####       ",
26  
-            "                                    #    #  # #    #          ",
27  
-            "  #####                             #### #  # #### ###        ",
28  
-            "                      ######           # #  #    # #          ",
29  
-            "          ####                      #### #### #### ####       ",
30  
-            "                                                              ",
31  
-            "                                                              ",
32  
-            "  ~~~~     ######################    ######################   ",
33  
-            "   ^                                                          ",
34  
-            "  /ü`                                                         ",
35  
-            "xxxxxxxxxxx@@@@@@@@@@@@@@@@@@@@@@xxxxxxxxxxxxxxxxxxxxxxxxxxxxx"
  23
+            "                                    p                                              ",
  24
+            "  123                 zzzzzz     zzzzzzzz    zzzzzz    zzzzz                       ",
  25
+            "  456                                                                              ",
  26
+            "           zzzzzzz                  zzzz z  z zzzz zzzz                            ",
  27
+            "                                    z    z  z z    z                               ",
  28
+            "  zzzzz                             zzzz z  z zzzz zz?                             ",
  29
+            "                      zzz??z           z z  z    z z                               ",
  30
+            "         zzz?z                      ?zzz zzzz z?zz zzzz                            ",
  31
+            "                                                                                   ",
  32
+            "                 p            p                 p p p                              ",
  33
+            "  ~~~~     zzzzzzzzzzzzzzzzzzzzzz    zzzzzzz?z?z?z?zzzzzzzz                        ",
  34
+            "   ^                                                                               ",
  35
+            "  /ü`                                                                        B     ",
  36
+            "88888888888@@@@@@@@@@@@@@@@@@@@@@88888888888888888888888888888888888888888888888888"
36 37
         ]
37 38
     },
38 39
     {
57  js/menu.js
@@ -5,35 +5,42 @@ function hideMenus() {
5 5
 
6 6
 // Main menu
7 7
 
8  
-document.getElementById("button-play1").addEventListener('click', function (event) {
9  
-    current_level = levels[2];
10  
-    startGame();
11  
-}, false);
12  
-
13  
-document.getElementById("button-play1").addEventListener('mouseover', function (event) {
14  
-    current_level = levels[2];
15  
-    load_level()
16  
-}, false);
  8
+var button;
  9
+if (button = document.getElementById("button-play1")) {
  10
+    button.addEventListener('click', function (event) {
  11
+        current_level = levels[2];
  12
+        startGame();
  13
+    }, false);
  14
+
  15
+    button.addEventListener('mouseover', function (event) {
  16
+        current_level = levels[2];
  17
+        load_level()
  18
+    }, false);
  19
+}
17 20
 
18  
-document.getElementById("button-play2").addEventListener('click', function (event) {
19  
-    current_level = levels[0];
20  
-    startGame();
21  
-}, false);
  21
+if (button = document.getElementById("button-play2")) {
  22
+    button.addEventListener('click', function (event) {
  23
+        current_level = levels[0];
  24
+        startGame();
  25
+    }, false);
22 26
 
23  
-document.getElementById("button-play2").addEventListener('mouseover', function (event) {
24  
-    current_level = levels[0];
25  
-    load_level()
26  
-}, false);
  27
+    button.addEventListener('mouseover', function (event) {
  28
+        current_level = levels[0];
  29
+        load_level()
  30
+    }, false);
  31
+}
27 32
 
28  
-document.getElementById("button-play3").addEventListener('click', function (event) {
29  
-    current_level = levels[1];
30  
-    startGame();
31  
-}, false);
  33
+if (button = document.getElementById("button-play3")) {
  34
+    button.addEventListener('click', function (event) {
  35
+        current_level = levels[1];
  36
+        startGame();
  37
+    }, false);
32 38
 
33  
-document.getElementById("button-play3").addEventListener('mouseover', function (event) {
34  
-    current_level = levels[1];
35  
-    load_level()
36  
-}, false);
  39
+    button.addEventListener('mouseover', function (event) {
  40
+        current_level = levels[1];
  41
+        load_level()
  42
+    }, false);
  43
+}
37 44
 
38 45
 
39 46
 var start_menu = document.getElementById("game-menu");
BIN  themes/snoop/images/enemy_tiles.png
BIN  themes/snoop/images/item_tiles.png
BIN  themes/suse/images/enemy_tiles.png
BIN  themes/suse/images/game_tiles.png
BIN  themes/suse/images/item_tiles.png

No commit comments for this range

Something went wrong with that request. Please try again.