projects
/
ld40.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Merge branches 'cleaning' and 'balancing'
[ld40.git]
/
ld40.js
diff --git
a/ld40.js
b/ld40.js
index d32c5ff410d98a5a12621aa8404db1d657098430..f7954c2a7d4a0ae5239f12a0094744b2cafe8b7b 100644
(file)
--- a/
ld40.js
+++ b/
ld40.js
@@
-22,7
+22,8
@@
const MODE_DETERMINATION = 0;
const MODE_JUSTICE = 1;
const SPEED_PLAYER = 150;
const MODE_DETERMINATION = 0;
const MODE_JUSTICE = 1;
const SPEED_PLAYER = 150;
- const SPEED_PROJECTILE = 500;
+ const SPEED_PPROJECTILE = 500;
+ const SPEED_MPROJECTILE = 200;
window.addEventListener("keydown", function(e) {
// Prevent default browser action for arrows and spacebar
window.addEventListener("keydown", function(e) {
// Prevent default browser action for arrows and spacebar
@@
-43,9
+44,10
@@
this.lasttime_shoot = 0;
this.lasttime_mode = 0;
this.lasttime_damage = 0;
this.lasttime_shoot = 0;
this.lasttime_mode = 0;
this.lasttime_damage = 0;
- this.speed =
150
;
+ this.speed =
SPEED_PLAYER
;
this.switchmode(MODE_DETERMINATION);
this.weapon = new JusticeBlaster(game, this);
this.switchmode(MODE_DETERMINATION);
this.weapon = new JusticeBlaster(game, this);
+ this.weapon.bulletSpeed = SPEED_PPROJECTILE;
this.healthBar = new HealthBar(60, game.world.height - (WALL_BORDERBOTTOM / 2));
}
this.healthBar = new HealthBar(60, game.world.height - (WALL_BORDERBOTTOM / 2));
}
@@
-144,10
+146,9
@@
this.anchor.setTo(0.5, 0.5);
this.health = MONSTER_HEALTH;
this.nexttime_shoot = game.time.now;
this.anchor.setTo(0.5, 0.5);
this.health = MONSTER_HEALTH;
this.nexttime_shoot = game.time.now;
- this.weapon = new Phaser.Weapon(game, this);
- this.weapon.x = x;
- this.weapon.y = y;
- this.weapon.createBullets(20, 'projectile');
+ this.weapon = new JusticeBlaster(game, this);
+ this.weapon.bulletSpeed = SPEED_MPROJECTILE;
+ this.weapon.trackSprite(this);
}
enablePhysics() {
}
enablePhysics() {
@@
-171,7
+172,7
@@
this.weapon.fireAtSprite(player);
this.nexttime_shoot = game.time.now + (WAIT_MONSTERSHOOT / 2) + (Math.random() * WAIT_MONSTERSHOOT);
}
this.weapon.fireAtSprite(player);
this.nexttime_shoot = game.time.now + (WAIT_MONSTERSHOOT / 2) + (Math.random() * WAIT_MONSTERSHOOT);
}
- game.physics.arcade.overlap(player, this.weapon.bullets, function(p,b) {
p.damage(p.love
); });
+ game.physics.arcade.overlap(player, this.weapon.bullets, function(p,b) {
b.overlap_player(p
); });
}
}
}
}
@@
-196,13
+197,17
@@
entity.damage(player.love);
this.kill();
}
entity.damage(player.love);
this.kill();
}
+
+ overlap_player(player) {
+ player.damage(player.love);
+ this.kill();
+ }
}
class JusticeBlaster extends Phaser.Weapon {
constructor(game, parent) {
super(game, parent);
this.bulletClass = Justice;
}
class JusticeBlaster extends Phaser.Weapon {
constructor(game, parent) {
super(game, parent);
this.bulletClass = Justice;
- this.bulletSpeed = SPEED_PROJECTILE;
this.multiFire = true;
this.createBullets(100, null);
}
this.multiFire = true;
this.createBullets(100, null);
}
@@
-258,9
+263,7
@@
nexttime_determination = Math.random() * WAIT_DETERMINATION;
monsters = game.add.group();
nexttime_determination = Math.random() * WAIT_DETERMINATION;
monsters = game.add.group();
- monsters.add(new Monster(400, 500));
- monsters.children.forEach(function(monster) { monster.enablePhysics(); });
- nexttime_monsterspawn = WAIT_MONSTERSPAWN;
+ nexttime_monsterspawn = WAIT_MONSTERSPAWN / 4;
player = new Player(game.world.width / 2, game.world.height / 2);
player.enablePhysics();
player = new Player(game.world.width / 2, game.world.height / 2);
player.enablePhysics();
@@
-268,8
+271,6
@@
game.camera.follow(player);
cursors = game.input.keyboard.createCursorKeys();
game.camera.follow(player);
cursors = game.input.keyboard.createCursorKeys();
- keyboard_handler = keyPress_default;
-
}
function update () {
}
function update () {
@@
-291,16
+292,11
@@
var monster = new Monster(Math.random() * game.world.width, Math.random() * game.world.height);
monster.enablePhysics();
monsters.add(monster);
var monster = new Monster(Math.random() * game.world.width, Math.random() * game.world.height);
monster.enablePhysics();
monsters.add(monster);
- nexttime_monsterspawn = game.time.now + (WAIT_MONSTERSPAWN / player.love) + (Math.random() * WAIT_MONSTERSPAWN);
+ var waittime = WAIT_MONSTERSPAWN - ((Math.random() * 2000) * player.love);
+ nexttime_monsterspawn = game.time.now + waittime;
+ console.log('Next monster in ' + waittime);
}
if ((game.time.now - player.lastmovetime) > WAIT_KEY) player.body.velocity.x = player.body.velocity.y = 0;
}
if ((game.time.now - player.lastmovetime) > WAIT_KEY) player.body.velocity.x = player.body.velocity.y = 0;
- if (keyboard_handler) keyboard_handler();
-
- }
-
- function keyPress_default() {
-
- // Maybe needed later.
}
}