Ha, I was wondering what happened here.
So, to recap, I posted B.R.O.O.M. to my website... B.R.O.O.M. ā Photics.com ...which stands for Bomb Removal & Ordnance Obliterating Machine. It's an attempt to create a game without a Physics API. In doing so, it highlights what might be good additions to a Hype Physics API.
As of version 0.1.1, I have WASD and Arrow key controls. By pressing an arrow key to move the main character, the web page itself was moving. Using the "event.preventDefault();" line stops the page from moving with the arrow keys.
window.onkeydown=function(event){
event.preventDefault();
moving = hypeDocument.isPlayingTimelineNamed('x') + hypeDocument.isPlayingTimelineNamed('y');
if (moving == false) {
if (event.keyCode == 37 || event.keyCode == 65) {
if (hypeDocument.currentTimeInTimelineNamed('x') > 0) {
hypeDocument.continueTimelineNamed('x', hypeDocument.kDirectionReverse);
}
} else if (event.keyCode == 38 || event.keyCode == 87) {
if (hypeDocument.currentTimeInTimelineNamed('y') > 0) {
hypeDocument.continueTimelineNamed('y', hypeDocument.kDirectionReverse);
}
} else if (event.keyCode == 39 || event.keyCode == 68) {
hypeDocument.continueTimelineNamed('x', hypeDocument.kDirectionForward);
} else if (event.keyCode == 40 || event.keyCode == 83) {
hypeDocument.continueTimelineNamed('y', hypeDocument.kDirectionForward);
}
}
}
Key Codes:
- Left = 37
- Up = 38
- Right = 39
- Down = 40
- A = 65
- W = 87
- D = 68
- S = 83
Basically, I have two timelines. One controls the X movement and another controls the Y movement.
It's a tile based game, so I stop the timeline with keyframes.
Controls are probably a good starting point for a Physics API. B.R.O.O.M. works because minimal collision detection is necessary. So far, I stop the actor from leaving the scene by going too far up or too far to the left.
I have to figure out if I'm going to scale the whole scene or make the level changebased on the screen size. That's where the "view" in Matter.js would be handy. It's probably easier to scale the whole scene. Heh, but I'm not sure what to do with the different ratios... 3:2, 4:3 and 16:9.