Permalink
Browse files

WASD control

1 parent 94a6307 commit 3400f6b9148e74ef345bbd0f74aa25cf095dc7b2 @huszy committed Dec 1, 2017
Showing with 6 additions and 6 deletions.
  1. +2 −2 README.md
  2. +4 −4 src/classes/Player.js
View
@@ -5,15 +5,15 @@ A game made for [#GithubGameOff](https://twitter.com/GitHubGameOff) 2017.
Demo hosted on [itch.io](https://huszy.itch.io/badgun)
-Sadly itch.io adds a very large header to the page and displays the game in iframe, and the page always scrolls out when you want to control the car, so a frameless version is hosted [here](https://badgun.onceapps.com)
+Sadly itch.io adds a very large header to the page and displays the game in iframe, and the page always scrolls out when you want to control the car with the arrow keys, so a frameless version is hosted [here](https://badgun.onceapps.com), or you can use W,A,S,D keys instead of arrows.
## Story
BADGUN, the hard-boiled Hawaiian cop loves his car. Only problem there, he drives her baby way too fast. He was fined so many times for speeding, that he loses his job. What could you do without money, without a job?
BADGUN starts car racing.
-Help BADGUN get more money! Use the arrow keys to accelerate, slow down, or turn the car. Reach as far as possible in a given time, make your way to the next level. Collect as much coins as possible. Use the brake, sometime a slower speed gets you farther. Avoid the obstacles, and watch out for the heavy traffic.
+Help BADGUN get more money! Use the arrow keys (or W,A,S,D) to accelerate, slow down, or turn the car. Reach as far as possible in a given time, make your way to the next level. Collect as much coins as possible. Use the brake, sometime a slower speed gets you farther. Avoid the obstacles, and watch out for the heavy traffic.
Key features:
- Constantly accelerating gameplay
View
@@ -112,15 +112,15 @@ export default class Player {
return
}
- if (this.game.input.keyboard.isDown(Phaser.Keyboard.LEFT)) {
+ if (this.game.input.keyboard.isDown(Phaser.Keyboard.LEFT) || this.game.input.keyboard.isDown(65)) {
this.sprite.rotation = Phaser.Math.clamp(this.sprite.rotation - 0.02, -0.2, 0)
this.turning = true
if (this.sprite.body.velocity.x > 0) {
this.sprite.body.velocity.x = 0
}
this.sprite.body.thrustLeft(this.playerConfig.turnVelocity * 40)
// this.sprite.body.velocity.x = Phaser.Math.clamp(this.sprite.body.velocity.x - this.playerConfig.turnVelocity, -1 * this.playerConfig.turnVelocity * 20, 0)
- } else if (this.game.input.keyboard.isDown(Phaser.Keyboard.RIGHT)) {
+ } else if (this.game.input.keyboard.isDown(Phaser.Keyboard.RIGHT) || this.game.input.keyboard.isDown(68)) {
this.sprite.rotation = Phaser.Math.clamp(this.sprite.rotation + 0.02, 0, 0.2)
this.turning = true
if (this.sprite.body.velocity.x < 0) {
@@ -143,12 +143,12 @@ export default class Player {
}
}
- if (this.game.input.keyboard.isDown(Phaser.Keyboard.UP)) {
+ if (this.game.input.keyboard.isDown(Phaser.Keyboard.UP) || this.game.input.keyboard.isDown(87)) {
if (this.sprite.body.velocity.y > this.playerConfig.maxVelocity) {
this.sprite.body.thrust(this.playerConfig.acceleration * 50)
}
// this.sprite.body.velocity.y = Math.max(this.sprite.body.velocity.y - this.playerConfig.acceleration / 5, this.playerConfig.maxVelocity)
- } else if (this.game.input.keyboard.isDown(Phaser.Keyboard.DOWN)) {
+ } else if (this.game.input.keyboard.isDown(Phaser.Keyboard.DOWN) || this.game.input.keyboard.isDown(83)) {
if (this.sprite.body.velocity.y < this.playerConfig.minVelocity) {
this.sprite.body.reverse(this.playerConfig.deceleration * 50)
}

0 comments on commit 3400f6b

Please sign in to comment.