-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from Andemanden/ActualRotator
The actual rotator. Almost only additions
- Loading branch information
Showing
4 changed files
with
94 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,39 @@ | ||
const NO_COLLISION = 0b0000; | ||
const DEFAULT_COLLISION = 0b0001; // for every normal object | ||
const PISTON_MECHANISM_COLLISION = 0b0010; // for collision with the piston. | ||
const PISTON_STOPPLATE_COLLISION = 0b0100; | ||
const PISTON_STOPPLATE_COLLISION = 0b0100; | ||
|
||
var keysdown = []; | ||
|
||
// key character to char code | ||
function ktocc(key) { | ||
return key.charCodeAt(0); | ||
} | ||
|
||
// User input | ||
function mousePressed() | ||
{ | ||
|
||
} | ||
|
||
function keyPressed() { | ||
keysdown.push(keyCode); | ||
} | ||
function keyReleased() { | ||
keysdown.splice(keysdown.indexOf(keyCode)); | ||
} | ||
|
||
// Character movement | ||
function moves() { | ||
for (key of keysdown) { | ||
switch (key) { | ||
case ktocc("w"): | ||
console.log("w"); | ||
//rotator.activate(); | ||
break; | ||
default: | ||
console.log("no"); | ||
|
||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
//This code goes so hard! Feel free to screenshot! | ||
class Rotator { | ||
/*"YOU CAN'T BEAT MEEEHH"*/ | ||
constructor(_x,_y,_w,_h,_rv) { | ||
this.x = _x;this.y = _y; this.w = _w; this.h = _h;this.rot=_rv; | ||
this.arm = new Rectangle(_x, _y, _w * 0.9, _h * 0.9,{isStatic: true}); | ||
Matter.Body.setAngle(this.arm.body, -1); | ||
this.arm.setcategory(DEFAULT_COLLISION); | ||
//The intend was mouseconstraint. But it could not find the html element | ||
} | ||
|
||
activate() { | ||
/*"And rotator runs free-wheeling"*/ | ||
Matter.Body.rotate(this.arm.body, this.rot); | ||
} | ||
|
||
show() { | ||
this.arm.show(); | ||
} | ||
} | ||
|