James Hancock
asked on
Does Javascript let io games know if it is on a phone or desktop?
Hi
I think for my io game in javascript, it would help my game object layout if I knew if the game was being played on a phone or desktop.
What is the best way to do this?
Also. . . Clear the canvas for a game loop efficiently? Is Javascript rendering super-fast?
...and then place my game objects appropriately?
Thanks
I think for my io game in javascript, it would help my game object layout if I knew if the game was being played on a phone or desktop.
What is the best way to do this?
Also. . . Clear the canvas for a game loop efficiently? Is Javascript rendering super-fast?
...and then place my game objects appropriately?
Thanks
ASKER
Is it a strategy to test the screen dimensions given and proceed from there?
Thanks
Thanks
ASKER
Thanks
Does the Javascript code receive data members of screenWidth and screenHeight? It does in HTML5?
That would be convenient. Does phone/tablet JS receive the dimensions?
Would you advise me to write in .js files or HTML5, if I intend to focus on Device games.
Does the Javascript code receive data members of screenWidth and screenHeight? It does in HTML5?
That would be convenient. Does phone/tablet JS receive the dimensions?
Would you advise me to write in .js files or HTML5, if I intend to focus on Device games.
My advice would be to write the code in whatever language you are most proficient, and test on one device, until you have acceptable results. Then use the device and browser detection code to make the necessary changes for compatibility ..testing on other devices.
HTML5 is native webpage rendering browser code, while js is more for interactive scripting and client side processing of page elements ... chances are you will employ a lot of both in making a browser game, but your engine will be java reliant.
Again the device and browser are primarily responsible for scaling elements to screen size. If it wasn’t designed this way you would literally need entirely separate code for every device that could exist. Iphone for example has differnet versions with different screen sizes and thousands of android devices have differing sizes as well.
For now.. concentrate on the game engine and playability.. because everything else can be modified through style{} manipulation for different devices and browsers later.
HTML5 is native webpage rendering browser code, while js is more for interactive scripting and client side processing of page elements ... chances are you will employ a lot of both in making a browser game, but your engine will be java reliant.
Again the device and browser are primarily responsible for scaling elements to screen size. If it wasn’t designed this way you would literally need entirely separate code for every device that could exist. Iphone for example has differnet versions with different screen sizes and thousands of android devices have differing sizes as well.
For now.. concentrate on the game engine and playability.. because everything else can be modified through style{} manipulation for different devices and browsers later.
ASKER
Thanks
I am most proficient in Java games, esp game authoritative servers after mucho EE assistance. (thanks legends) I wrote a working RTS server, with UDP packet firing for increased server speed.
That is not possible in browsers (UDP is not supported) I have access to a committed private server: non VPS
Anyway, I am keen on the idea of writing my game in Java.
What do you know about converting it afterwards to iPhone, browser, etc.
Should I just make it and ask questions later? TCP/IP clients and server...
Thanks
I am most proficient in Java games, esp game authoritative servers after mucho EE assistance. (thanks legends) I wrote a working RTS server, with UDP packet firing for increased server speed.
That is not possible in browsers (UDP is not supported) I have access to a committed private server: non VPS
Anyway, I am keen on the idea of writing my game in Java.
What do you know about converting it afterwards to iPhone, browser, etc.
Should I just make it and ask questions later? TCP/IP clients and server...
Thanks
Actually that is not true.
WebRTC uses UDP at the transport layer. ICE implementation can be used for traversing NAT and firewalls as well.
https://en.m.wikipedia.org/wiki/WebRTC
It is a browser based protocol used for real-time communications..like video, voip, and yes... games.
This article explains better than the wiki - https://hpbn.co/webrtc/
This is large undertaking, but if you can implement it, you will end up with a realtime game engine using UDP transport.
And yes, I would just start making it with your basic plan/roadmap, and cross the code barriers as they come.
As far as converting to an actual installable app, I’m afraid I can’t offer much help there.
One thing I would definitely recommend, is to do a little research and make sure you aren't reinventing the wheel so to speak. There are already browser based game engines you may be able to implement more quickly.
WebRTC uses UDP at the transport layer. ICE implementation can be used for traversing NAT and firewalls as well.
https://en.m.wikipedia.org/wiki/WebRTC
It is a browser based protocol used for real-time communications..like video, voip, and yes... games.
This article explains better than the wiki - https://hpbn.co/webrtc/
This is large undertaking, but if you can implement it, you will end up with a realtime game engine using UDP transport.
And yes, I would just start making it with your basic plan/roadmap, and cross the code barriers as they come.
As far as converting to an actual installable app, I’m afraid I can’t offer much help there.
One thing I would definitely recommend, is to do a little research and make sure you aren't reinventing the wheel so to speak. There are already browser based game engines you may be able to implement more quickly.
ASKER
Awesome
What dimensions should I give my JFrame? 1000's or 100's?
Thanks
What dimensions should I give my JFrame? 1000's or 100's?
Thanks
For dimensions it would depend I guess on whether or not you want it to be full screen or a ratio thereof.
https://alvinalexander.com/java/jframe-size-example-screen
https://alvinalexander.com/java/jframe-size-example-screen
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
Now I don't have 4to waste any time thinking on device issues!
Now I don't have 4to waste any time thinking on device issues!
Good luck man. 👌
See this question on stackoverflow.com
Detect device in Jquery/javascript
Typically however, the detection is used for browser code compatibility, rather than adjusting items for screen size. The device itself is usually responsible for scaling images and other media to fit the screen... but there are some circumstances where you would need to set limits, or prevent screen rotation. Notice most games will not rotate on a screen when the device is turned vertical...or horizontal... this is usually hard coded as landscape or portrait layout. I have no idea how they do that however. If you figure that part out let me know because I need it too. lol.