Skip to content
Permalink
Browse files

Putting global things globally (wants refactoring); neaten up with `w…

…rap()`
  • Loading branch information
stnbu committed Sep 16, 2018
1 parent 640ca7e commit 305e172388e0794081165ae7fbe9101516b48cf2
Showing with 11 additions and 4 deletions.
  1. +1 −0 snek.jsx
  2. +10 −4 soat.html
@@ -17,6 +17,7 @@ let Snake = class Snake {
move(delta) {
var orig_position = this.body[0].position.slice(); // where head was.
var i;
// this is wonky and terrible
var new_positions = [];
for (i = 0; i <= 5; i++) {
new_positions.push(this.body[i].position);
@@ -24,6 +24,12 @@

// I am a jS n00b. There is lots that need refactoring. Mostly "I know I just don't know how"

// HRRM?
Array.prototype.repeat = function(n) {
var a = [];
for (var i=0;i<n;[i++].push.apply(a,this));
return a;
}

const config = {
circle_radius: 15,
@@ -63,9 +69,9 @@
super(props);
this.changeThing = this.changeThing.bind(this);
this.state = {
direction: [0, 1],
body: [[20, 0], [20, 0], [20, 0], [20, 0], [20, 0]],
len: 5
direction: [0, 0],
body: [[10, 10]].repeat(20),
len: 20
};
}

@@ -92,7 +98,7 @@
};
});

}, 300);
}, 40);
}


0 comments on commit 305e172

Please sign in to comment.