Skip to content

Commit

Permalink
resolved conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
adamcbrewer committed Nov 10, 2012
2 parents 370a727 + 87db05f commit 1095827
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 17 deletions.
15 changes: 14 additions & 1 deletion css/index.css
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
body{
color: hotpink;
font-family: 'Comic Sans MS', cursive;
background: url(../img/bg.jpg);

}

h1 { font-size: 50px; text-transform: uppercase;}

#container {
margin: auto;
width: 1024px;
Expand All @@ -6,4 +15,8 @@

#cr-stage {
border: 1px solid black;
}
/* background: url("../img/background.jpg") 0 0 repeat;
*/
}


Binary file added img/background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/bg.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added img/shooter-sprites.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified img/shooter-sprites.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
7 changes: 3 additions & 4 deletions index.html
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<!DOCTYPE html>
<html>
<head>
<title>YOUR GAME NAME HERE</title>
<title>Unicorn >> SUPER BLASTER!</title>

<link rel="stylesheet" type="text/css" href="css/index.css"></link>

Expand All @@ -12,10 +12,9 @@
</head>
<body>
<div id="container">
<h1>YOUR GAME NAME HERE</h1>
<div id="cr-stage">
<h1>Unicorn SUPER BLASTER!!!!ONE!1!!</h1>
<div id="cr-stage" class="catchadream">
</div>
<p>YOUR GAME INSTRUCTIONS HERE</p>
</div>

<script>
Expand Down
42 changes: 30 additions & 12 deletions js/game.js
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,25 @@
}
});

Crafty.c('EnemyBullet', {
init: function() {
this.requires('Renderable, Collision, Delay, SpriteAnimation')
.spriteName('bullet')
.collision()
// set up animation from column 0, row 1 to column 1
.animate('fly', 0, 1, 1)
// start the animation
.animate('fly', -5, -1)
// move left every frame, destroy bullet if its off the screen
.bind("EnterFrame", function() {
this.x -= 10;
if (this.x > 1024 || this.x < 0) {
this.destroy();
}
})
}
});


// targets to shoot at
Crafty.c('Target', {
Expand All @@ -101,12 +120,13 @@
// choose a random position
this._randomlyPosition();
this.moveTarget();
this.randomlyFire();
},
// randomly position
_randomlyPosition: function() {
this.attr({
x: 1000, //Crafty.math.randomNumber(1000, 1200),
y: Crafty.math.randomNumber(0,600-this.h)});
x: 900, //Crafty.math.randomNumber(1000, 1200),
y: Crafty.math.randomNumber(0,600)});
},
// we got hit!
_hitByBullet: function() {
Expand All @@ -130,15 +150,12 @@
},

moveTarget: function() {
// var hit = this.hit('Player');
// if (hit) {
// this.attack(hit);
// } else {

var xMovement = Crafty.math.randomInt(-100, 100);
var yMovement = Crafty.math.randomInt(-100, 100);

var newPos = {
x: this.x + (Crafty("Player")._x - this.x)/5,
x: this.x -50, //this.x + (Crafty("Player")._x - this.x)/5,
y: this.y + (Crafty("Player")._y - this.y)/5,
w: this.w,
h: this.h
Expand All @@ -147,9 +164,13 @@
if(this.within.call(newPos, 0, 0, Crafty.viewport.width, Crafty.viewport.height)) {
this.tween({x: newPos.x, y: newPos.y}, 60);
}
//}

this.delay(this.moveTarget, 300);
},

randomlyFire: function() {
this.delay(this.randomlyFire, Crafty.math.randomInt(800, 1200))
Crafty.e("EnemyBullet").attr({x: this.x - 5, y: this.y});
}
});

Expand Down Expand Up @@ -186,9 +207,6 @@
[180, 40]
))




// also react to the SPACE key being pressed
.requires('Keyboard')
.bind('KeyDown', function(e) {
Expand All @@ -199,6 +217,7 @@
});

this.onHit('Target', this.badGuyCollision);
this.onHit('EnemyBullet', this.badGuyCollision)

// bind our movement handler to keep us within the Viewport
this.bind('Moved', function(oldPosition) {
Expand All @@ -209,7 +228,6 @@
// replace the ship with an explosion!
Crafty.e("Explosion").attr({x:this.x, y:this.y});
this.destroy();

}
});

Expand Down

0 comments on commit 1095827

Please sign in to comment.