Adam's Lair Forum

game development and casual madness
It is currently 2017/04/29, 23:26

All times are UTC + 1 hour [ DST ]




Post new topic Reply to topic  [ 3 posts ] 
Author Message
 Post subject: Resolution/Window
PostPosted: 2016/04/03, 00:36 
One-Hit Wonder
One-Hit Wonder

Joined: 2016/04/03, 00:28
Posts: 1
Role: Hobbyist
Heyho! I am fresh new to this forum and I am just learning duality! So, a couple of friends and I wanted to start making a game using the duality framework, but we are not sure how to handle resolution and responsiveness in window mode, so it would look the the way it should be on all screens and devices. Can someone help us out how to scale it the best way and what to do exactly?

I thank everyone that will be answering very much :)


Top
 Profile  
 
 Post subject: Re: Resolution/Window
PostPosted: 2016/04/03, 11:00 
Site Admin
Site Admin
User avatar

Joined: 2013/05/11, 22:30
Posts: 1949
Location: Germany
Role: Professional
Hello and welcome ^^

As always, there are lots of ways to approach the topic and I'd say it depends on the kind of game you want to make.

If you have a strategy game for example, it may be a good thing for players to use a higher resolution for simply displaying more stuff and providing a better overview on the map. In this case, you wouldn't have to do anything - this is the default behavior.

If you instead choose to provide a constant "view", you'll have to scale the rendering to match the resolution. There's a "soft" way that just does scaling, as it is done in the Dual Stick Space Shooter sample package, or more specifically here. You'll get a similar physical size / appearance at the cost of completely disregarding aspect ratio and thus providing a slightly different viewport on different screens.

Another option was implemented by loeller in the MoonRogue game with fixed scaling options and a black border around the main viewport, should the window be larger than that. A nice option for pixel art I think.

_________________
Blog | GitHub | Twitter (@Adams_Lair)


Top
 Profile  
 
 Post subject: Re: Resolution/Window
PostPosted: 2016/04/03, 21:20 
Veteran Member
Veteran Member
User avatar

Joined: 2016/01/10, 10:56
Posts: 144
Location: Budapest
Role: Hobbyist
Hello, and welcome to the forums!

The latter two options Adam mentioned differ in a small, but important detail: camera mode. If you use the parallax camera, it's Z coordinate will determine the size of the area fitting on the screen, because of the perspective projection. If you disable the parallax setting, it's simpler: the ratio of the pixel and the world units is 1, since it is paralell projection.

In my game, I used flat (not parallax) projection, and scaling it up was dead simple because of Duality's flexible camera rendering pipeline. It didn't even involve coding. (Of course changing between multiple scaling levels needs some code.)

The main thing is, that you need two cameras, one of them rendering your game at a fixed resolution to a RenderTarget, which is a built-in Duality resource. In the RenderTarget's inspector, you need to assign a texture to render to.
It's important to set the destination texture's resolution before.

Set the texture's filtering mode to Nearest. After that, you can assign that texture to any sprite, which you can scale up. There are some limitations though: it only looks good with pixel graphics, and only at certain scale levels. Set the second camera to render only this sprite to screen using the render group controls, and the first mentioned camera to not.

There's more information of the process in this topic.

I hope it helps :]


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 3 posts ] 

All times are UTC + 1 hour [ DST ]


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group