Skip to content

Commit

Permalink
Refactoring away from local Settings file
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonwebb committed Apr 3, 2019
1 parent b20441b commit 3780df7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 6 deletions.
1 change: 1 addition & 0 deletions 06-interactivity/js/Player.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ export default class Player {

this.p5.translate(this.x, this.y);
this.p5.rotate(this.heading);

this.p5.beginShape();

this.p5.vertex(25/2, 0);
Expand Down
3 changes: 0 additions & 3 deletions 06-interactivity/js/Settings.js

This file was deleted.

7 changes: 4 additions & 3 deletions 06-interactivity/js/entry.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import Settings from './Settings';
import DLA from '../../core/DLA';
import Player from './Player';
import SVGLoader from '../../core/SVGLoader';
Expand All @@ -24,7 +23,7 @@ const sketch = function (p5) {
player = new Player(p5, window.innerWidth/2, window.innerHeight/2);

// Set up the simulation environment
dla = new DLA(p5, Settings);
dla = new DLA(p5);
reset();
}

Expand Down Expand Up @@ -68,6 +67,7 @@ const sketch = function (p5) {
player.move();
player.draw();

// When shooting, fire a walker particle every 5 frames in the direction the player is pointed
if(player.isShooting && p5.frameCount % 5 == 0) {
dla.createWalker({
x: player.x,
Expand All @@ -79,11 +79,12 @@ const sketch = function (p5) {
});
}

// Stop shooting when mouse is released
if(!p5.mouseIsPressed) {
player.isShooting = false;
}

// Wrap player when it leaves the screen's edge
// Wrap player when it leaves the screen's edge. Has to be done here because the Player object doesn't know about the DLA object intrinsically
if(player.x < dla.edges.left) {
player.x = dla.edges.right;
}
Expand Down

0 comments on commit 3780df7

Please sign in to comment.