Skip to content
Browse files

added preloading images/sounds, removed wav files because of size

  • Loading branch information...
1 parent 181555b commit b9fb881469509e565e2d5c093e382c710844af1e @BlackScorp committed Mar 1, 2012
View
8,454 assets/js/crafty.js
8,454 additions, 0 deletions not shown because the diff is too large. Please use a local Git client to view these changes.
View
4 assets/js/game.js
@@ -21,6 +21,6 @@ $(function(){
bars.shield.progressbar({
value: 0
});
- //$('#interface').hide();
- Crafty.scene("Level1");
+ $('#interface').hide();
+ Crafty.scene("Loading");
});
View
57 assets/js/levels.js
@@ -1,20 +1,34 @@
//Loading Scene
Crafty.scene("Loading",function(){
-
+
var toLoad = [
//Images
- game_path + "/assets/img/bg.png",
- game_path + "/assets/img/ships.png",
- game_path + "/assets/img/weapon1_small.png",
- game_path + "/assets/img/weapon2.png",
- game_path + "/assets/img/dmg.png",
- game_path + "/assets/img/asteroid64.png",
- game_path + "/assets/img/asteroid32.png",
- game_path + "/assets/img/explosion.png",
- game_path + "/media/sounds/explode.mp3",
- game_path + "/media/sounds/explode.ogg",
- game_path + "/media/sounds/explode.wav",
+ game_path + "assets/img/bg.png",
+ game_path + "assets/img/ships.png",
+ game_path + "assets/img/weapon1_small.png",
+ game_path + "assets/img/weapon2.png",
+ game_path + "assets/img/dmg.png",
+ game_path + "assets/img/asteroid64.png",
+ game_path + "assets/img/asteroid32.png",
+ game_path + "assets/img/explosion.png",
+ //Sounds
+ game_path + "media/sounds/explode.mp3",
+ game_path + "media/sounds/explode.ogg",
+ game_path + "media/sounds/explodemini.mp3",
+ game_path + "media/sounds/explodemini.ogg",
+ game_path + "media/sounds/laser1.mp3",
+ game_path + "media/sounds/laser1.ogg",
+ game_path + "media/sounds/laser2.mp3",
+ game_path + "media/sounds/laser2.ogg",
+ game_path + "media/sounds/laser3.mp3",
+ game_path + "media/sounds/laser3.ogg",
+ game_path + "media/sounds/laser4.mp3",
+ game_path + "media/sounds/laser4.ogg",
+ //Music
+ game_path + "media/music/spaceship.mp3",
+ game_path + "media/music/spaceship.ogg",
];
+
Crafty.background("black");
Crafty.e("2D","DOM","Text").css({
"color":"#ffffff"
@@ -24,21 +38,24 @@ Crafty.scene("Loading",function(){
}).css({
"color":"#ffffff"
});
+
Crafty.load(toLoad,
function() {
- //when loaded
- // Crafty.scene("Level1"); //go to Level1 scene
+
+ //when loaded
+ $('#interface').show();
+ Crafty.scene("Level1"); //go to Level1 scene
},
function(e) {
-
+
loaded.text(Math.round(e.percent)+" %");
//progress
},
function(e) {
- console.log(e);
-
+ console.log("Error on loading: "+e.src);
+
//uh oh, error loading
}
);
@@ -47,8 +64,7 @@ Crafty.scene("Loading",function(){
Crafty.scene("Level1",function(){
//Setup background of level
Crafty.background("url(" + game_path + "/assets/img/bg.png)");
- //Play background music and repeat
- Crafty.audio.play("space",-1);
+
$('.level').text('Level: 1');
var spotEnemys = function(frame){
@@ -77,6 +93,7 @@ Crafty.scene("Level1",function(){
Crafty.stage.elem.style.backgroundPosition ="0px "+frame.frame+"px";
});
-
+ //Play background music and repeat
+ Crafty.audio.play("space",-1);
});
View
8 assets/js/sounds.js
@@ -1,55 +1,47 @@
Crafty.audio.add({
space: [
- game_path + "/media/music/through-space.wav",
game_path + "/media/music/through-space.mp3",
game_path + "/media/music/through-space.ogg"
]
});
Crafty.audio.add({
spaceship: [
- game_path + "/media/music/spaceship.wav",
game_path + "/media/music/spaceship.mp3",
game_path + "/media/music/spaceship.ogg"
]
});
Crafty.audio.add({
explosion0: [
- game_path + "/media/sounds/explodemini.wav",
game_path + "/media/sounds/explodemini.mp3",
game_path + "/media/sounds/explodemini.ogg"
]
});
Crafty.audio.add({
explosion1: [
- game_path + "/media/sounds/explode.wav",
game_path + "/media/sounds/explode.mp3",
game_path + "/media/sounds/explode.ogg"
]
});
Crafty.audio.add({
laser1: [
- game_path + "/media/sounds/laser1.wav",
game_path + "/media/sounds/laser1.mp3",
game_path + "/media/sounds/laser1.ogg"
]
});
Crafty.audio.add({
laser2: [
- game_path + "/media/sounds/laser2.wav",
game_path + "/media/sounds/laser2.mp3",
game_path + "/media/sounds/laser2.ogg"
]
});
Crafty.audio.add({
laser3: [
- game_path + "/media/sounds/laser3.wav",
game_path + "/media/sounds/laser3.mp3",
game_path + "/media/sounds/laser3.ogg"
]
});
Crafty.audio.add({
laser4: [
- game_path + "/media/sounds/laser4.wav",
game_path + "/media/sounds/laser4.mp3",
game_path + "/media/sounds/laser4.ogg"
]
View
6 index.html
@@ -3,13 +3,13 @@
<head>
<meta charset="UTF-8" />
<title>Cron</title>
- <script type="text/javascript" src="http://cdn.crafty-modules.com/crafty-DEBUG.js"></script>
-
+ <!-- <script type="text/javascript" src="http://cdn.crafty-modules.com/crafty-DEBUG.js"></script> -->
+ <script type="text/javascript" src="assets/js/crafty.js"></script>
<script>var game_path = location.href.lastIndexOf("/") !== -1 ? location.href.substring(0, location.href.lastIndexOf("/") + 1) : location.href;</script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>
<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.16/jquery-ui.min.js"></script>
<script type="text/javascript" src="assets/js/sprites.js"></script>
- <script type="text/javascript" src="assets/js/sounds.js"></script>
+ <script type="text/javascript" src="assets/js/sounds.js"></script>
<script type="text/javascript" src="assets/js/weapons.js"></script>
<script type="text/javascript" src="assets/js/effects.js"></script>
<script type="text/javascript" src="assets/js/enemys.js"></script>
View
BIN media/music/spaceship.wav
Binary file not shown.
View
BIN media/music/through-space.wav
Binary file not shown.
View
BIN media/sounds/explode.wav
Binary file not shown.
View
BIN media/sounds/explodemini.wav
Binary file not shown.
View
BIN media/sounds/laser1.wav
Binary file not shown.
View
BIN media/sounds/laser2.wav
Binary file not shown.
View
BIN media/sounds/laser3.wav
Binary file not shown.
View
BIN media/sounds/laser4.wav
Binary file not shown.

0 comments on commit b9fb881

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