Permalink
Browse files

moved file structure, you can now go off the screen and it loops back

  • Loading branch information...
fabean committed Sep 3, 2016
1 parent 9ca7a7d commit d47e32f639b69c549e833435b3ac4c0a6392affe
Showing with 40 additions and 25 deletions.
  1. 0 { → app}/css/normalize.min.css
  2. 0 { → app}/index.html
  3. +20 −12 { → app}/js/main.js
  4. +19 −11 gulpfile.js
  5. +1 −2 package.json
File renamed without changes.
File renamed without changes.
@@ -47,9 +47,11 @@ window.onload = () => {

// Handle keyboard controls
addEventListener("keydown", function (e) {
e.preventDefault(); // this stops screen wiggle
keysDown[e.keyCode] = true;
}, false);
addEventListener("keyup", function (e) {
e.preventDefault(); // this stops screen wiggle
delete keysDown[e.keyCode];
}, false);

@@ -71,39 +73,45 @@ let render = () => {
// write the score
let score = {
message: `Score: ${player.score}`,
x: 100,
y: 50
x: 50,
y: 20
}
drawText(score);

// write the health
let health = {
message: `Lives Remaining: ${player.lives}`,
x: 500,
y: 50
x: (c.width - 200),
y: 20
}
drawText(health);
}

let movePlayer = () => {
if (38 in keysDown) { // Player holding up
if (10 <= player.ship.y) {
player.ship.y += -(player.ship.speed.y);
player.ship.y += -(player.ship.speed.y);
// going to check if they've hit the top, if they have, put them on the bottom
if (player.ship.y <= 0) {
player.ship.y = c.height;
}
}
if (40 in keysDown) { // Player holding down
if (c.height-10 >= player.ship.y) {
player.ship.y += player.ship.speed.y;
player.ship.y += player.ship.speed.y;
// going to check if they've hit the top, if they have, put them on the bottom
if (player.ship.y >= c.height) {
player.ship.y = 0;
}
}
if (37 in keysDown) { // Player holding left
if (10 <= player.ship.x) {
player.ship.x += -(player.ship.speed.x);
player.ship.x += -(player.ship.speed.x);
if (player.ship.x <= 0) {
player.ship.x = c.width;
}
}
if (39 in keysDown) { // Player holding right
if (c.width-10 >= player.ship.x) {
player.ship.x += player.ship.speed.x;
player.ship.x += player.ship.speed.x;
if (player.ship.x >= c.width) {
player.ship.x = 0;
}
}
}
@@ -1,12 +1,20 @@
var gulp = require('gulp');
var server = require('gulp-server-livereload');

gulp.task('webserver', function() {
gulp.src('app')
.pipe(server({
fallback: 'index.html',
livereload: true,
directoryListing: true,
open: true
}));
var gulp = require('gulp'),
connect = require('gulp-connect');

gulp.task('connect', function() {
connect.server({
root: 'app',
livereload: true
});
});

gulp.task('html', function () {
gulp.src('./app/*.html')
.pipe(connect.reload());
});

gulp.task('watch', function () {
gulp.watch(['./app/*.html'], ['html']);
});

gulp.task('default', ['connect', 'watch']);
@@ -18,7 +18,6 @@
"homepage": "https://github.com/fabean/buffhammer#readme",
"devDependencies": {
"gulp": "^3.9.1",
"gulp-serve": "^1.4.0",
"gulp-server-livereload": "^1.8.4"
"gulp-connect": "^5.0.0",
}
}

0 comments on commit d47e32f

Please sign in to comment.