city41 / breakouts

A collection of JS engine implementations of Breakout
http://jsbreakouts.mattgreer.dev
542 stars 117 forks source link

Updated melonJS version #49

Closed obiot closed 10 years ago

obiot commented 10 years ago

Now uses the last dev branch of melonJS. The most noticeable change when playing breakouts is probably the audio support on mobile devices (as melonJS now relies on the web audio API), the rest are mostly internal improvements to the framework, API changes, and bug fixing

ellisonleao commented 10 years ago

:+1:

city41 commented 10 years ago

sweet! Thanks Olivier. I'll get this merged in ASAP, hopefully tonight.

city41 commented 10 years ago

Hey guys. It looks like on retina screens the playfield ends up half the size it should be. I see in game.js there is me.video.init('screen', 320, 416 ...), but the resulting canvas ends up being set up as <canvas width="320" height="416" style="width: 160px; height: 208px;">, so the playfield is about half the size it should be. This is happening to me on OSX 10.9 in Chrome, FF and Safari.

city41 commented 10 years ago

If I change the scale from undefined to 2.0 in the call to me.video.init, then I get the correct size on a retina display, and double the correct size on a standard display.

obiot commented 10 years ago

Unfortunately I don't have a retina display, so I cannot really help fixing this ... Is the change still make the rest to work as well ? (non retina display, and iOS ?)

city41 commented 10 years ago

Yeah other than that it's looking good. I will look into the retina issue and see if I can fix it. It should just be something like if(window.devicePixelRatio > 1) scale *= 2, or maybe even scale *= window.devicePixelRatio. I'll see if I can find a good spot inside melon to do that and send you guys a pull request for it

obiot commented 10 years ago

actually we do,

detection is made here : https://github.com/melonjs/melonJS/blob/1.0.0-dev/src/system/device.js#L345

and then used here : https://github.com/melonjs/melonJS/blob/1.0.0-dev/src/video/video.js#L117 https://github.com/melonjs/melonJS/blob/1.0.0-dev/src/video/video.js#L347 https://github.com/melonjs/melonJS/blob/1.0.0-dev/src/video/video.js#L382

and is working nicely on high-DPI devices like iphone/iPad

@parasyte you do have a retina MBP, right ?

city41 commented 10 years ago

For mobile the scale is set to "auto". I just added this (scale variable being the only change)

var scale = window.devicePixelRatio || 1;
if (!me.video.init('screen', 320, 416, me.device.isMobile ? true : false, me.device.isMobile ? "auto" : scale)) {

and now it's working well on all devices I have (iPhone 5s, standard laptop, MBP retina).

city41 commented 10 years ago

I won't deploy this out until @parasyte chimes in.

obiot commented 10 years ago

that's a smart fix ;)

parasyte commented 10 years ago

I do not have retina MBP, sorry. I have retina iPhone only. :cry:

obiot commented 10 years ago

@city41 you can go for it then !

city41 commented 10 years ago

tonight I will do the fix for Breakouts. This weekend I'll take a gander at melon and see if I can find a permanent solution.

ellisonleao commented 10 years ago

:+1:

city41 commented 10 years ago

alright, live on the site: http://jsbreakouts.org

obiot commented 10 years ago

great, thanks !

I think that maybe it's mostly an issue with the HTML/CSS, I can of course be wrong, but i'm pretty sure that out internal way of handling this correct.