• Advertisement

C++ Targeting Different Platforms

Recommended Posts

I am trying to write a 2D game using SFML so it will be portable.  I was thinking maybe a resolution for the desktop of 1024 x 768 and one higher resolution too with black bars.  I think that this should cover all the PCs.

Is this fine?

Secondly,  the SFML site mentions that IOS and Android are on the way for using SFML.  I am wondering what the resolutions are that I will need to use.  That is,  the least amount of different resolutions to cover all of these upcoming opportunities so I can plan ahead.  I am thinking maybe these devices might have more than one display resolution on their devices?  I am writing this here because it is not so much a question for SFML but really just general knowledge about mobile resolutions.

Thanks for the help,

Josheir

Share this post


Link to post
Share on other sites
Advertisement

Why would you off the bat limit the resolution of you application with no indication as to why this would be help. If its just for the sake of let say running on a PC then this is not optimal. Most framework these days( most likely SFML ) have the ability to enumerate the device capabilities, using that as your starting point would present a more flexible design. If it turn out that the specific resolution is too high to support your application feature, then you can use the said result(s) from enumeration to dial back resolution. Also, if you get caught up on resolution you will soon find this to be a pain, there is no such thing a mobile resolution especially on Android where the device and so wide and varied.

Share this post


Link to post
Share on other sites
16 minutes ago, cgrant said:

Why would you off the bat limit the resolution of you application with no indication as to why this would be help. If its just for the sake of let say running on a PC then this is not optimal. 

I am rewriting a program I wrote and I don't understand the need for other resolutions.  If they have 1024x768 than I figure just use it, it is optimal for the display.  This is a 2d game.  I am limiting it because it is easier than than writing more than one display with black bars, and if it is possible than why not take the easier route.  

My idea is that monitors have 1024x768 still and if not than they have the one other type 'x.'  It's optimal, 1024 x 768.  (looks how I want it to!)

16 minutes ago, cgrant said:

 Also, if you get caught up on resolution you will soon find this to be a pain, there is no such thing a mobile resolution especially on Android where the device and so wide and varied.

What are you suggesting as an alternative?  

 

Josheir

 

Edited by Josheir

Share this post


Link to post
Share on other sites

I did miss that 2D part, but yeah the only sane way you are going to get by is to do so form of scaling from your default resolution. Still think there will be some distortion, as even though the app is rendered at resolution X, the native display has a specific resolution ( can be queried ). You can go the route of having assets for a few common resolution ( gotta do the research ), or redo your asset so that they correspond to some other metric, ex. aspect ratio, instead of fix resolution. Does your app works at any other resolution than 1024 x 768 currently ? If not, can you say why ?

Share this post


Link to post
Share on other sites

Let me explain...

I wrote the program one time and it was a real pain to create it in different resolutions.  I am rewriting it now.  It worked using three different dimensions but the problem was that it looked different in all three.  I am better at programming now.

I was considering scaling but if it only works if the ratio of width and the ratio of height are the same with regards to the image displayed on the two resolution to be the same size. (I got the ratio by dividing the screen widths together and dividing the heights together)  This became the multiplier for the scaling.

So, I want to use 1024 x 768 as my default resolution.  If all of the monitors still have 1024 x 768 useable, well it would use this default resolution and be fine.  If not, my idea was to also use some other very popular resolution that every new monitor would definitely have.

So, I was wondering if my idea is sound, and I'm pretty sure it is.

Now, finally,  If a different resolution is used there shouldn't be distortion.  The same images will be used and the extra screen real estate will be blacked out.  So, it would be like viewing the 1024x768 centered on 1360 x 768 with  (1360 - 1024)/2 = 168 px as borders on the left and right.  Get it?

 

To reiterate, the idea is that 1024 x 768 is still on every monitor, and if not than there is a choice for some other monitor resolutiom that every newer computer has.

 

I can't think of any need for a very high resolution for this project.

 

What do you  all think?

Josheir

Edited by Josheir

Share this post


Link to post
Share on other sites

There is scaling but with a testing circle the shape was less circular.  I guess there is some formula though because when hacking at the different width and height scaling the image would be fairly close to the same on both resolutions.  This was using 1024 x 768 and 1360 x 768.  1024 x 768 scaled to 800 x 600 fine (and the reverse too.)  

I would think if a circle displayed on different resolutions and was a perfect circle this would be proof for the ratio of the resolutions.

Josheir

 

Edited by Josheir

Share this post


Link to post
Share on other sites

If you're going to force me to your arbitrarily picked resolution, then at least let me run it windowed.  1024x768 looks horrible on my monitors full screen and my eyes tend to get sore after 20 minutes of playing or so and I quit and go and leave a horrible review/look for the refund button/uninstall button.  You can also scale non-uniformly your 2D art assets to make them look better at whatever resolution too as 1080p is far more common these days than 4:3 for monitors and even mobile devices.

Share this post


Link to post
Share on other sites
3 hours ago, Josheir said:

Secondly,  the SFML site mentions that IOS and Android are on the way for using SFML.  I am wondering what the resolutions are that I will need to use

Yes mobiles/tablets have different resolution screens and more importantly different aspect ratios.

What I do is create the render buffer to the same as the full screen resolution of the device BUT up to a maximum size at which point I use up-scaling, Currently the maximum is 720p on mobiles for me. You might want to read this (applies to Android)

https://android-developers.googleblog.com/2013/09/using-hardware-scaler-for-performance.html

Now the real problem is the different aspect ratios. It is best to create your render buffer at the correct aspect of the device and make you game handle this but you 'could' have black bars (not something I would do myself) but please base it on 16:9 aspect not your current 4:3 !

1 hour ago, Mike2343 said:

1024x768 looks horrible

Share this post


Link to post
Share on other sites
2 hours ago, Josheir said:

Now, finally,  If a different resolution is used there shouldn't be distortion.  The same images will be used and the extra screen real estate will be blacked out.  So, it would be like viewing the 1024x768 centered on 1360 x 768 with  (1360 - 1024)/2 = 168 px as borders on the left and right.  Get it?

I use a 4k monitor as my daily driver. I will literally not be able to play a game that sits in a 1024x768 box in the very middle of the screen, because it will be too small to make out. At the very least you need to scale that 1024x768 up to the height of the monitor.

Also consider that 4:3 resolutions haven't been standard for nearly a decade. All commodity monitors are 16:9, so you'd be inflicting black bars on 90% or more of your user base.

Share this post


Link to post
Share on other sites
1 hour ago, swiftcoder said:

I use a 4k monitor as my daily driver. I will literally not be able to play a game that sits in a 1024x768 box in the very middle of the screen, because it will be too small to make out. At the very least you need to scale that 1024x768 up to the height of the monitor.

I am trying to understand this.  Swiftcoder, what is the size of this monitor in inches (high and wide,)  and what is the resolution that your 4k is running this at?   Also, what type of device is it for?

Thanks,

Josheir

Share this post


Link to post
Share on other sites
3 hours ago, Mike2343 said:

You can also scale non-uniformly your 2D art assets to make them look better at whatever resolution too 

I am confused : say we are scaling the images up for a bigger monitor with a higher resolution.  What we're discussing is that we make these images bigger because there is more space on the display.  But, I don't think I necessarily want my artwork very huge.  Maybe I am misunderstanding this exactly, what were discussing?

Confused,

Josheir

Share this post


Link to post
Share on other sites
29 minutes ago, Josheir said:

what is the resolution that your 4k is running this at?

4K is 3840 × 2160 pixels.  A 24 inch monitor running at 4K is great.  Two is even better.

You might want to consider the most common aspect ratio of displays these days is 16:9 because that's what most TV broadcasts are, so your display media (TVs, computers, tablets, phones) tend to be made to fit that.  That means 1080p and now at twice the dot-pitch, 2160p AKA 4K.

Gone are the days when you'd have an old bottle monitor showing 1024x768 with 96 PPI standing in for 72.27 points over a smaller value of an inch.  I think it's been over a decade since I've used one of those.

Share this post


Link to post
Share on other sites

Why even use a fixed resolution these days?

The one thing mobile development has given the gaming world is scalable graphics that fit any screen size.

Just use the same rules used for mobile UI. Design your art as high as you can and scale it down from there. Scaling up should be done with a "Box" scale to keep pixel perfection (1 pixel ->4 pixels ->16 pixels etc.).

Share this post


Link to post
Share on other sites
2 hours ago, Josheir said:

Swiftcoder, what is the size of this monitor in inches (high and wide,)  and what is the resolution that your 4k is running this at?   Also, what type of device is it for?

4k is a standard TV resolution, i.e. 2x 1080p in each direction, or 3840x2016.

My home monitor is 40" diagonal, but that's unusually large for a PC monitor. At work I use a 32" diagonal at the same resolution. Up until 2 years ago, I used a pair of 27" displays at 2560x1440 each.

These are all off-the-shelf PC monitors, and most standard PC monitors these days are similar, either 16:9 or 16:10 aspect ratio - 4:3 is only found on specialty pro displays at this point.

If you are planning to ship on Android or iOS, the mobile world is far more varied, not just in terms of resolutions and aspect ratios, but also in strange shape displays (such as the iPhone X "notch"). You'll have to deal with scaling your game, but also moving UI elements out of the way of mobile operating system affordances.

Share this post


Link to post
Share on other sites
4 minutes ago, swiftcoder said:

My home monitor is 40" diagonal, but that's unusually large for a PC monitor. At work I use a 32" diagonal at the same resolution. Up until 2 years ago, I used a pair of 27" displays at 2560x1440 each.

Hmm...if the monitor is that big I don't understand why the 1024 x 768 would be so small?

 

4 hours ago, swiftcoder said:

At the very least you need to scale that 1024x768 up to the height of the monitor.

And do you mean the entire height of 2160 pixels, why exactly?

 

Thanks once again,

Josheir

Share this post


Link to post
Share on other sites
36 minutes ago, Josheir said:

Hmm...if the monitor is that big I don't understand why the 1024 x 768 would be so small?

With a monitor that big you have to sit very far away in order to see the entire monitor (think about watching TV from a couch on the other side of the room). Text, for example, isn't going to be readable from that distance on such a small segment of the screen.

But more than that, it just isn't very enjoyable to play a game that makes the arbitrary decision that I should be using a monitor resolution from the 90's :)

39 minutes ago, Josheir said:

And do you mean the entire height of 2160 pixels, why exactly?

So that it fills as much of the display as possible. Everyone will still have black bars on 2 sides (since most monitors are widescreen), but at least I won't have black bars on all 4 sides that account for 87.5% of my pixels...

Share this post


Link to post
Share on other sites

No one want's 87% of their monitor to be black for your game at it's non-standard aspect ratio is what we're basically saying.  I only have a 1080p monitor (2x27") and your game would only use ~75% of my screen.  Again, for someone like me running your game in a windowed mode, not full screen might be do-able.  But for swiftcoder it would be difficult to make anything out.  Think about it, his work monitor is only 32" which is only 5" larger than mine but he has basically 2x the pixel density.  You screen and art assets would be tiny.  You're most likely going to have to scale them up or redo them for modern displays or expect poor reviews.

Share this post


Link to post
Share on other sites

I think scaling up with whole numbers and blacking the rest is the proper way to go. Then you'd have good looking graphics and use as much as possible of the monitors area.

I prefer having black bars to skewed graphics.

 

 

Share this post


Link to post
Share on other sites
13 hours ago, Josheir said:

Hmm...if the monitor is that big I don't understand why the 1024 x 768 would be so small?

What you may be missing is that not all pixels are of equal size.

4K monitors have more dense pixels, ie each pixel is smaller so you get more pixels/inch. To get the same size images displayed (in inches of used screen size), the images must use more pixels, ie be bigger in x and y size.

 

The idea is that more pixels/inch means you can show more smaller details, eg anti-aliasing of text becomes better.

Share this post


Link to post
Share on other sites
2 hours ago, Alberth said:

4K monitors have more dense pixels, ie each pixel is smaller so you get more pixels/inch

Yes, this.

Consider that a standard 1080p monitor at 24 inches has less than 100 PPI (pixels per inch). A MacBook has ~220 PPI. An iPhone X has 450 PPI. The Galaxy S6 has nearly 600 PPI.

That makes your 768 pixel tall game nearly 8 inches tall on the 1080p display, but only 1.2 inches tall on a the Galaxy S6.

Share this post


Link to post
Share on other sites

Okay, I do now have a working plan with all your help (at least with the desktops /laptops.)  This 4K is understood and is feasible for me now, and my next question is :  are there any other special cases like the 4K, let's say not including mobile's for now?  Thank you so much : swiftcoder and Bregma for mentioning this resolution type!

Sincerely,

Josheir

 

Share this post


Link to post
Share on other sites

There are some other special cases in the PC world that you can probably care significantly less about (since they affect fewer users):

  • 16:10 aspect ratio. Quite a few "pro" monitors are 16:10 instead of 16:9. Not that hard to cover if you are also accounting for 4:3, but worth mentioning.
  • Multiple monitors. A few years ago large monitors were expensive, and it was pretty common for serious gamers to have 3x monitors mapped in the drivers to appear as a single display. This leads to some fantastic display resolutions like 5760x1080 (16:3 aspect ratio!). Still fairly popular among racing and simulation fans.
  • Vertical monitors. Programmers in particular have this habit of buying fancy IPS-based displays and mounting them vertically to increase the visible lines of text... Many games don't operate very well like this.

Share this post


Link to post
Share on other sites
39 minutes ago, Mike2343 said:

Yes, 8k is a thing now too.  Though currently expensive, much like 4x was only a year or two ago.

Thank you, geeze, when does it end?  I was calculating earlier and something like a 15" monitor with 4K would produce a 3.25" by 1.8" display.  

So, there is no way for me to do 8k with my assets, even with scaling.  Unless they do otherwise, natively.

So how popular are 4k and 8k and do they work with only this K and resolution natively?

I am just using bitmaps and/or pings.

 

Thank you once again,

Josheir

 

Edited by Josheir

Share this post


Link to post
Share on other sites

I'm not sure why scaling wouldn't work for you - that's how pretty much all other raster-art 2D games work. Typically you pick a "base" resolution to produce all your assets at (for a retro game, 1024x768 is perfectly fine), and then you write a little bit of code to scale it to the smallest of (width, height) of the display. Bonus points if you make your assets cover enough off-screen area to avoid the black bars on widescreen displays.

Obviously things are going to get a little pixelated on an 4k display. But that's less of an issue than you might think - pixels are really tiny on displays with resolutions that high. Plus you can experiment with adding some post-process smoothing on the GPU.

If pixelation really bothers you, then you typically need to switch to vector-art, or play with things like distance fields.

54 minutes ago, Josheir said:

So how popular are 4k and 8k

Pretty popular. Every Mac sold in the last 5 years has a "retina" display, going all the way up to 5K on recent iMacs. PC laptops keep pace. High-end standalone PC displays have been at least 1440p for the last few years, 4k is now pretty standard in that market segment. That said, the majority of folks still game on 1080p displays, and at least for older laptops, that runs all the way down to 720p.

54 minutes ago, Josheir said:

do they work with only this K and resolution natively?

For the most part, no. However, the native scaling has limits, and most panels won't scale down as far as 1024x768 anymore. 1080p is probably pretty safe, 720p in a pinch. Supporting the matching aspect ratio may be more important that the specific resolutions on some displays.

However, keep in mind that monitor scaling only typically kicks in for exclusive fullscreen modes. If you want to be able to play in windowed mode, you typically have to take care of scaling yourself.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


  • Advertisement
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By fishyperil
      I'm looking for some references that could help me learn how to program some really basic 2D enemy behaviours.
      I wasn't sure whether to post this here or in the AI section but I think it might be more suitable to be posted here since it has more to do with basic maths than any AI related algorithms.
      Could anyone help recommend some resources (books, posts, videos) that could help me understand how to properly implement the basics of enemy movement in 2d games ? So far I've only managed to get them to chase the player character and to stop moving on collision, but the movement is pretty unrealistic and once the collision occurs the enemies all "pile up" on the player character. I'm doing this in C++ so no guides that explain how to script this using an engine api please.
    • By MochiArtist
       draw stuff like this 
       
      Okay, so I am an artist and have been for 6 years. However, I struggle to write code. I'd like to make a small demo of a game I'd like to make one day. If your willing to help it'd be much appreciated. so here is the concept: it's a survival game that involves cute characters that are mochi. 
      Mochi Universe
      Draft version 0.01 (24 December, 2015)
       
      Concept
      The game concept revolves around city building and exploration. The target audience will be age 9+ (most likely because of the possibility of fighting). The cute graphics should appeal to all audiences male and female. The gameplay includes elements of real-time strategy games (such as warcraft ) with faster paced action (such as clash of clans). In order to build your city, you will need to explore the surrounding environment and collect items (such as in minecraft). The gameplay will less intense than warcraft and clash of clans, so the focus will be more on casual gamers than hardcore gamers.
    • By steve negrin
      hello, i'm steve and im designer, i can design any idea and i'm looking for projects to help, if you are interesting write and we can talk about it
    • By Terry Jin
      Hi everyone! 

      I am from an indie studio that has received funding for our concept and is ready to create the next generation 2D Pokemon-inspired MMORPG called Phantasy World. This ad is for a volunteer position but hopefully will transition into something more. Our vision is to create a game that draws inspiration from the series but is dramatically different in both aesthetics and gameplay as the work would be our own.
       
      We are hoping that you can help us make this a reality and are looking for game developers familiar with the unreal engine and would be happy to work on a 2D top down game. Sprite artists are also welcome as we are in desperate need of talented artists! Join our discord and let's have a chat! https://discord.gg/hfDxwDX

      Here's a teaser as to what our in game characters look like when moving in the game world! Hope to see you soon!
       

    • By Ovicior
      Hey,
      So I'm currently working on a rogue-like top-down game that features melee combat. Getting basic weapon stats like power, weight, and range is not a problem. I am, however, having a problem with coming up with a flexible and dynamic system to allow me to quickly create unique effects for the weapons. I want to essentially create a sort of API that is called when appropriate and gives whatever information is necessary (For example, I could opt to use methods called OnPlayerHit() or IfPlayerBleeding() to implement behavior for each weapon). The issue is, I've never actually made a system as flexible as this.
      My current idea is to make a base abstract weapon class, and then have calls to all the methods when appropriate in there (OnPlayerHit() would be called whenever the player's health is subtracted from, for example). This would involve creating a sub-class for every weapon type and overriding each method to make sure the behavior works appropriately. This does not feel very efficient or clean at all. I was thinking of using interfaces to allow for the implementation of whatever "event" is needed (such as having an interface for OnPlayerAttack(), which would force the creation of a method that is called whenever the player attacks something).
       
      Here's a couple unique weapon ideas I have:
      Explosion sword: Create explosion in attack direction.
      Cold sword: Chance to freeze enemies when they are hit.
      Electric sword: On attack, electricity chains damage to nearby enemies.
       
      I'm basically trying to create a sort of API that'll allow me to easily inherit from a base weapon class and add additional behaviors somehow. One thing to know is that I'm on Unity, and swapping the weapon object's weapon component whenever the weapon changes is not at all a good idea. I need some way to contain all this varying data in one Unity component that can contain a Weapon field to hold all this data. Any ideas?
       
      I'm currently considering having a WeaponController class that can contain a Weapon class, which calls all the methods I use to create unique effects in the weapon (Such as OnPlayerAttack()) when appropriate.
  • Advertisement