Width and height of the window

Monkey Targets Forums/HTML5/Width and height of the window

pit(Posted 2014) [#1]
Hi all,

i'm trying to make my game working in HTML (I developed it in for GLFW target until now)
Question: how to change the defaul size of the window ?
In CONFIG.MONKEY of the HTML5, I didn't found any parameter for that ???

thanks

Pit


dawlane(Posted 2014) [#2]
Open up the MonkeyGame.html. You will find your answer in there. Another topic of interest would be how include the applications made for the html target in your own web site.
http://www.monkey-x.com/Community/posts.php?topic=9283&post=97007&view=all#97007


pit(Posted 2014) [#3]
Thanks a lot dawlane !


pit(Posted 2014) [#4]
As it seems that you have an experience with HTML5, a little question.
In dektop mode (glfw) my game as +/- 50 fps
in html, this decrease to +/- 20 fps !!!

such decreasing of performance is normal in html 5 ?

Pit


dawlane(Posted 2014) [#5]
There will always be performance differences between the targets. Targets that don't compile to the system native CPU architecture will always have a performance hit, so you have to try to avoid code that is calculation intensive, this include those functions that are native to MonkeyX and Mojo. The speed on a HTML5 and Flash depends on the browser, the power of the system it's running on; this includes the operating system and how you have coded your application. The Android target likewise depends on the hardware and how you code, while code that will work as expected on a desktop will work almost as just as well on a iOS device, as long as you are coding for that devices limitations.
The general rule for cross platform compatibility is to code for the lowest denominator. For some performance tips search the forum for object pooling, image/sprite atlas and performance. Also type "monkey x performance" into the google search bar may so show results.
Edit: If you are changing the canvas size etc, You will also incur a penalty on performance. I would suggest that you use autofit.


pit(Posted 2014) [#6]
Hi dawlane,

Thanks for your advice !
this morning I replaced two PlaySound (for a sound of +/- 5 seconds) by PlayMusic and replaced also a "while-wend" by a test of MusicState at the beginning of "onupdate" (as i want all the game "freezed" when the music si playing).
And.... my performance problem is solved (and also a "crash" problem with the while-wend pause, first reason why I tried this other method) !
So it seems that I must take care with the sound management, whiuch cause no problem in desktop mode, but seems very important in html5...

thanks again

Pit


dawlane(Posted 2014) [#7]
The state of audio playing cannot be determined on some targets. You would be better off using the millisec function to mark the elapsed time or trigger events at specific times in such cases. Like wise some browsers cannot play specific audio formats, so the browser would also need to be identified.


pit(Posted 2014) [#8]
Hi dawlane,

1) ok I will see how to adapt my program following your advices.
2) I have seen somewhere on this forum that mp3 format is accepted by all the browser ? Is it correct ? If yes, I can translate my sound to this format.
3) when I say that Idon't have any perf problem on html5, it's not totaly right. I'm on Mac. With Firefox, FPS are +/- at 60 fps. But if I use Safari, it decrease to +/- 20 fps !
Is it normal ? Is Safari so slow with HTML5 ?


dawlane(Posted 2014) [#9]
MP3 should be supported on all browsers above a certain version and with the correct audio extensions installed for those that require them; such as gstreamer for Linux. There is one problem with the MP3 format; it's not very good for looping (looping wasn't in the designers minds when they thought it up) and requires a little bit of work to get rid of the gap when the loop is repeated.
As stated earlier, performance depends on the system and the browser used, so it's not uncommon for two browsers on the same system to have differences in performance. The reason for this as far as I am aware, is that the HTML5 API standards haven't been finalised yet. So browser authors tend to not to spend much time on such things and concentrate on browser security and stability. You will also find that CSS3 is not fully supported by some web browsers for the same reason. Rumour had it that Microsoft had to implement CSS3 so they could still compete. You will most likely find that the best browser will be Goolge Chrome. This browser is the one recommend for use with MonkeyX HTML5 applications.
To find out more about the state of support in browsers: Google html5 support, and pay particular attention to anything by web developers.


pit(Posted 2014) [#10]
Hi dawnlane,

following your advice, I have seen a lot of interesting about html5. I will look at this now. In order to understand how I can optimize my program for this target.

But I'm still very surprised that on the same machine, with the same programs running (in fact only TED from monkey), we can have such difference between two browser (60 fps versus 20 fps) .As far I know, Safari is supposed to have good performance with javascript ?

I think I will create a new toipic on the forum. mAybe some other people have some experience with such problem on Safari ?

Thanks

Pit