Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Putting global things globally (wants refactoring); neaten up with `w…
- Loading branch information
Showing
with
11 additions
and
4 deletions.
-
+1
−0
snek.jsx
-
+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); |
|
|
} |
|
|
|
|
|
|
|
|