Jump to content


Photo

Get screen resolution


  • Please log in to reply
9 replies to this topic

#1 rye

rye

    GMC Member

  • New Member
  • 14 posts
  • Version:Mac

Posted 20 July 2012 - 10:59 PM

Hello,

How can I make my game check the screen resolution to be able to decide which images (the appropriate size for each screen resolution) to use?

Maybe it could read this information from the same source as "About this Mac / Graphics/Displays" gets that informtion?

I hope this is possible somehow. It's really urgent.

Many thanks!!!
  • 0

#2 Jobo

Jobo

    No neurons left today

  • GMC Member
  • 2405 posts
  • Version:GM:Studio

Posted 20 July 2012 - 11:11 PM

globalvar DISPLAY_WIDTH, DISPLAY_HEIGHT;

DISPLAY_WIDTH = display_get_width();

DISPLAY_HEIGHT = display_get_height();

  • 3

#3 rye

rye

    GMC Member

  • New Member
  • 14 posts
  • Version:Mac

Posted 24 July 2012 - 09:44 PM

Hello,

Thanks for your answer.

I made my game in 1920 x 1080 screen resolution. It runs fine on my Mac, and I have also tested it successfully on a larger Mac (2560 x 1440). Now I would like to run it on a smaller MacBook, but the resolution is - predictably - all messed up: the rooms are not resizing and are therefore partially outside of the screen!

Is there a way to make the game set its resolution to the screen's resolution (resizing itself)?

If that's not possible, the other idea is - related to my original question and the above answer - to somehow integrate a "second version" for MacBooks in my game, with additional pictures... in lower resolution, and to somehow switch between both versions according to the current screen size.

Has anyone done something like this before?
Is there more information about HOW to achieve this?

BTW: I read the beginning of an interesting thread on this matter in the forum some days ago but it's just gone now!

Many thanks.
  • 0

#4 Tha_14

Tha_14

    GMC Member

  • New Member
  • 174 posts
  • Version:GM8.1

Posted 25 July 2012 - 02:36 PM

Hello,

Thanks for your answer.

I made my game in 1920 x 1080 screen resolution. It runs fine on my Mac, and I have also tested it successfully on a larger Mac (2560 x 1440). Now I would like to run it on a smaller MacBook, but the resolution is - predictably - all messed up: the rooms are not resizing and are therefore partially outside of the screen!

Is there a way to make the game set its resolution to the screen's resolution (resizing itself)?

If that's not possible, the other idea is - related to my original question and the above answer - to somehow integrate a "second version" for MacBooks in my game, with additional pictures... in lower resolution, and to somehow switch between both versions according to the current screen size.

Has anyone done something like this before?
Is there more information about HOW to achieve this?

BTW: I read the beginning of an interesting thread on this matter in the forum some days ago but it's just gone now!

Many thanks.


I am having the exact problem but on Windows. I tried to run my game on different computers with different resolutions and only on some of them the mouse was going to the correct x and y and the images where exactly where I wanted. If anyone can give us a clue on how to fix that please do. Thanks
  • 1

#5 rye

rye

    GMC Member

  • New Member
  • 14 posts
  • Version:Mac

Posted 29 July 2012 - 08:52 AM

I'm still trying to find a solution for automatically selecting different backgrounds, buttons, player pics, speeds... according to the detected screen resolution, but still to no avail. Is this possible? Any tips? Many thanks.
  • 0

#6 michael pw

michael pw

    GMC Member

  • GMC Member
  • 1488 posts
  • Version:GM8.1

Posted 29 July 2012 - 10:05 AM

You cannot set the size of a room whilst you are in it. (same goes for views)

So perhaps have a little quick room at the start

room_set_width(game_room,display_get_width(),display_get_height());

if you are using views

view_wview[0] = display_get_width();
view_hview[0] = display_get_width();
room_set_width(game_room,display_get_width(),display_get_height());


(Not sure if this actually works on Mac, but if it works the same way as windows then you need to resize the room window before you are in that room, then it should work.)
  • 1

#7 rye

rye

    GMC Member

  • New Member
  • 14 posts
  • Version:Mac

Posted 29 July 2012 - 01:28 PM

Hi Michael,

and thanks for your answer.

I just need the script for the rooms.
Should I put it into the room script or in a code or in a normal script?
If a code or a normal script - in which event should I put it?

Thanks again!!!
  • 0

#8 satyre

satyre

    GMC Member

  • GMC Member
  • 138 posts
  • Version:GM8

Posted 30 July 2012 - 07:15 PM

Hi Michael,

and thanks for your answer.

I just need the script for the rooms.
Should I put it into the room script or in a code or in a normal script?
If a code or a normal script - in which event should I put it?

Thanks again!!!


Put it in the room's creation code. If you don't want to do that for whatever reason, put it in the create event of an object.
  • 1

#9 1 Shogun

1 Shogun

    GMC Member

  • GMC Member
  • 40 posts
  • Version:Mac

Posted 30 July 2012 - 07:56 PM

Create an "Initial Room" and place the following in the Room's Creation Code:

room_set_width(room_TitleScreen,display_get_width());
room_set_height(room_TitleScreen,display_get_height());
room_goto(room_TitleScreen);

The "room_TitleScreen" can be what ever room the player actually sees first. You will also have to use "room_set_width" and "room_set_height" for each room or level in this Creation Code as well. By the way, I'm just assuming that you want the game to be full screen? If you do it this way, rather than by the Global Game Settings, you won't have to worry about the annoying Hertz refresh rate when using an external monitor, especially when constantly testing. And yes, you must resize a room before entering it on Mac just like in Windows. Oh and, I tried setting Global Game Settings to allow the user to change window size, along with a little room at the bottom to do so, but I can't get that to work. The sprites resized like they were supposed to, but the background images would not scale. Just letting you know I tested this myself and what I've found.

P.S. You may have to resize the sprite images relative to the room size:

Draw Event(Applies to both 2D and 3D examples.)

2D Example: draw_sprite_ext(sprite_index,-1,x,y,xscale based on room_width, yscale based on room_height, 0,c_white,1); //Some values are assumed.
3D Example:
if (point_distance(x,y,obj_cam.x,obj_cam.y) > 1000) exit; <-- Stops performing current Event (Draw) if sprite is 1000 pixels away.
var tex;
tex = sprite_get_texture(sprite_index,image_index);
d3d_draw_wall(x-15*global.camsin,y-15*global.camcos,84,x+15*global.camsin,y+15*global.camcos,-60,tex,1,1); <-- Doom-like, camera-facing, 3D sprite. You can use constant values instead.

It's better to decrease the size of a large image than to increase the size of a small one. Hope this helps.
  • 1

#10 rye

rye

    GMC Member

  • New Member
  • 14 posts
  • Version:Mac

Posted 10 August 2012 - 04:42 PM

Hi Shogun,

Your method works but then I realized that objects which were placed near the borders of a room would be OUTSIDE of the room on smaller screens.

Thanks!
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users