Skip to content
This repository
Browse code

Merge pull request #2 from Krassmus/gh-pages

Better including this game into Stud.IP or other sites.
  • Loading branch information...
commit 181555b76e56888c2fbf4a19dba4f5439457daa5 2 parents 8901c90 + 60d8034
Witali Mik authored February 21, 2012
24  assets/js/levels.js
@@ -3,17 +3,17 @@ Crafty.scene("Loading",function(){
3 3
     
4 4
     var toLoad = [
5 5
     //Images
6  
-    "assets/img/bg.png",
7  
-    "assets/img/ships.png",
8  
-    "assets/img/weapon1_small.png",
9  
-    "assets/img/weapon2.png",
10  
-    "assets/img/dmg.png",
11  
-    "assets/img/asteroid64.png",
12  
-    "assets/img/asteroid32.png",
13  
-    "assets/img/explosion.png",
14  
-    "media/sounds/explode.mp3",
15  
-    "media/sounds/explode.ogg",
16  
-    "media/sounds/explode.wav",
  6
+    game_path + "/assets/img/bg.png",
  7
+    game_path + "/assets/img/ships.png",
  8
+    game_path + "/assets/img/weapon1_small.png",
  9
+    game_path + "/assets/img/weapon2.png",
  10
+    game_path + "/assets/img/dmg.png",
  11
+    game_path + "/assets/img/asteroid64.png",
  12
+    game_path + "/assets/img/asteroid32.png",
  13
+    game_path + "/assets/img/explosion.png",
  14
+    game_path + "/media/sounds/explode.mp3",
  15
+    game_path + "/media/sounds/explode.ogg",
  16
+    game_path + "/media/sounds/explode.wav",
17 17
     ];
18 18
     Crafty.background("black");
19 19
     Crafty.e("2D","DOM","Text").css({
@@ -46,7 +46,7 @@ Crafty.scene("Loading",function(){
46 46
 //Level 1 Scene
47 47
 Crafty.scene("Level1",function(){
48 48
     //Setup background of level
49  
-    Crafty.background("url(assets/img/bg.png)");
  49
+    Crafty.background("url(" + game_path + "/assets/img/bg.png)");
50 50
     //Play background music and repeat
51 51
     Crafty.audio.play("space",-1);
52 52
     $('.level').text('Level: 1');
9  assets/js/player.js
@@ -179,6 +179,7 @@
179 179
         if(this.lives <= 0){
180 180
             this.destroy();
181 181
             this.infos.alert.show().text('Game Over!').effect('pulsate',500);
  182
+            gameHooks.endGame(this.score);
182 183
             Crafty.pause();
183 184
         }else{
184 185
             this.reset();
@@ -214,5 +215,9 @@
214 215
     updateLives:function(){
215 216
         this.infos.lives.text("Lives: "+this.lives);
216 217
     }
217  
-  
218  
-});
  218
+    
  219
+});
  220
+
  221
+var gameHooks = {
  222
+    endGame: function (score) {}
  223
+}
48  assets/js/sounds.js
... ...
@@ -1,56 +1,56 @@
1 1
 Crafty.audio.add({
2 2
     space: [
3  
-    "media/music/through-space.wav",
4  
-    "media/music/through-space.mp3",
5  
-    "media/music/through-space.ogg"
  3
+    game_path + "/media/music/through-space.wav",
  4
+    game_path + "/media/music/through-space.mp3",
  5
+    game_path + "/media/music/through-space.ogg"
6 6
     ]
7 7
 });
8 8
 Crafty.audio.add({
9 9
     spaceship: [
10  
-    "media/music/spaceship.wav",
11  
-    "media/music/spaceship.mp3",
12  
-    "media/music/spaceship.ogg"
  10
+    game_path + "/media/music/spaceship.wav",
  11
+    game_path + "/media/music/spaceship.mp3",
  12
+    game_path + "/media/music/spaceship.ogg"
13 13
     ]
14 14
 });
15 15
 Crafty.audio.add({   
16 16
     explosion0: [
17  
-    "media/sounds/explodemini.wav",
18  
-    "media/sounds/explodemini.mp3",
19  
-    "media/sounds/explodemini.ogg"
  17
+    game_path + "/media/sounds/explodemini.wav",
  18
+    game_path + "/media/sounds/explodemini.mp3",
  19
+    game_path + "/media/sounds/explodemini.ogg"
20 20
     ]
21 21
 });
22 22
 Crafty.audio.add({
23 23
     explosion1: [
24  
-    "media/sounds/explode.wav",
25  
-    "media/sounds/explode.mp3",
26  
-    "media/sounds/explode.ogg"
  24
+    game_path + "/media/sounds/explode.wav",
  25
+    game_path + "/media/sounds/explode.mp3",
  26
+    game_path + "/media/sounds/explode.ogg"
27 27
     ]
28 28
     });
29 29
 Crafty.audio.add({
30 30
     laser1: [
31  
-    "media/sounds/laser1.wav",
32  
-    "media/sounds/laser1.mp3",
33  
-    "media/sounds/laser1.ogg"
  31
+    game_path + "/media/sounds/laser1.wav",
  32
+    game_path + "/media/sounds/laser1.mp3",
  33
+    game_path + "/media/sounds/laser1.ogg"
34 34
     ]
35 35
     });
36 36
 Crafty.audio.add({
37 37
     laser2: [
38  
-    "media/sounds/laser2.wav",
39  
-    "media/sounds/laser2.mp3",
40  
-    "media/sounds/laser2.ogg"
  38
+    game_path + "/media/sounds/laser2.wav",
  39
+    game_path + "/media/sounds/laser2.mp3",
  40
+    game_path + "/media/sounds/laser2.ogg"
41 41
     ]
42 42
     });
43 43
 Crafty.audio.add({
44 44
     laser3: [
45  
-    "media/sounds/laser3.wav",
46  
-    "media/sounds/laser3.mp3",
47  
-    "media/sounds/laser3.ogg"
  45
+    game_path + "/media/sounds/laser3.wav",
  46
+    game_path + "/media/sounds/laser3.mp3",
  47
+    game_path + "/media/sounds/laser3.ogg"
48 48
     ]
49 49
     });
50 50
 Crafty.audio.add({
51 51
     laser4: [
52  
-    "media/sounds/laser4.wav",
53  
-    "media/sounds/laser4.mp3",
54  
-    "media/sounds/laser4.ogg"
  52
+    game_path + "/media/sounds/laser4.wav",
  53
+    game_path + "/media/sounds/laser4.mp3",
  54
+    game_path + "/media/sounds/laser4.ogg"
55 55
     ]
56 56
 });
14  assets/js/sprites.js
... ...
@@ -1,4 +1,4 @@
1  
-Crafty.sprite("assets/img/ships.png",{
  1
+Crafty.sprite(game_path + "/assets/img/ships.png",{
2 2
     //Gold
3 3
     ship1:[0,0,44,47],
4 4
     ship2:[47,0,40,47],
@@ -19,22 +19,22 @@ Crafty.sprite("assets/img/ships.png",{
19 19
     ship16:[340,48,67,47]
20 20
 });
21 21
 
22  
-Crafty.sprite(5,13,"assets/img/weapon1_small.png",{
  22
+Crafty.sprite(5,13,game_path + "/assets/img/weapon1_small.png",{
23 23
     laser1:[0,0] 
24 24
 });
25  
-Crafty.sprite(27,36,"assets/img/weapon2.png",{
  25
+Crafty.sprite(27,36,game_path + "/assets/img/weapon2.png",{
26 26
     laser2:[0,0] 
27 27
 });
28  
-Crafty.sprite(29,"assets/img/dmg.png",{
  28
+Crafty.sprite(29,game_path + "/assets/img/dmg.png",{
29 29
     dmg:[0,0]
30 30
 });
31  
-Crafty.sprite(64,"assets/img/asteroid64.png",{
  31
+Crafty.sprite(64,game_path + "/assets/img/asteroid64.png",{
32 32
     asteroid64:[0,0]
33 33
 });
34  
-Crafty.sprite(32,"assets/img/asteroid32.png",{
  34
+Crafty.sprite(32,game_path + "/assets/img/asteroid32.png",{
35 35
     asteroid32:[0,0]
36 36
 });
37  
-Crafty.sprite(65,"assets/img/explosion.png",{
  37
+Crafty.sprite(65,game_path + "/assets/img/explosion.png",{
38 38
     explosion1:[0,0],
39 39
     explosion2:[0,1],
40 40
     explosion3:[0,2],
1  index.html
@@ -5,6 +5,7 @@
5 5
         <title>Cron</title>
6 6
         <script type="text/javascript" src="http://cdn.crafty-modules.com/crafty-DEBUG.js"></script>
7 7
     
  8
+        <script>var game_path = location.href.lastIndexOf("/") !== -1 ? location.href.substring(0, location.href.lastIndexOf("/") + 1) : location.href;</script>
8 9
         <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
9 10
         <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
10 11
         <script type="text/javascript" src="assets/js/sprites.js"></script>

0 notes on commit 181555b

Please sign in to comment.
Something went wrong with that request. Please try again.