collinhover / impactplusplus

Impact++ is a collection of additions to ImpactJS with full featured physics, dynamic lighting, UI, abilities, and more.
http://collinhover.github.com/impactplusplus
MIT License
276 stars 59 forks source link

Possibility to set margins on the canvas? #37

Closed nakanaa closed 11 years ago

nakanaa commented 11 years ago

I wanted my canvas to be fullscreen (GAME_WIDTH_PCT = 1 & GAME_WIDTH_PCT = 1) but leave space for a 200px sidebar. For it, I added these to config-user.js:

"GAME_WIDTH_MARGIN": 200,
"GAME_HEIGHT_MARGIN": 0,

and edited core/game.js resize function:

var width = _c.GAME_WIDTH_PCT ? ig.global.innerWidth * _c.GAME_WIDTH_PCT - _c.GAME_WIDTH_MARGIN : _c.GAME_WIDTH;
var height = _c.GAME_HEIGHT_PCT ? ig.global.innerHeight * _c.GAME_HEIGHT_PCT - _c.GAME_HEIGHT_MARGIN : _c.GAME_HEIGHT;

I think this would be a good addition to Impact++ itself. Didn't make a pull request at least yet because I wasn't sure if you'd want this in.

collinhover commented 11 years ago

I wouldn't mind having this functionality, thanks for submitting the idea! However, it looks as if your margin setup only affects the game when the screen size is set by a percent of the window size, and it only puts the margin on the right and/or bottom. We'd need to add config options to set the margins on any side and it seems like we'd also need to modify the CSS of the canvas?

collinhover commented 11 years ago

Closing for now due to inactivity. If you get the feature worked out, please submit a pull request!