Centering existing coordinates after switching from set resolution to max
Author |
Message |
Srlancelot39
|
Posted: Sat Jan 28, 2012 3:28 pm Post subject: Centering existing coordinates after switching from set resolution to max |
|
|
What is it you are trying to achieve?
I have a game that currently has set window resolutions. Since I would have to completely redesign the game to make it playable in max resolution, I would like to instead make the window fullscreen and leave the playing area the current size so that it is centered on a black background.
What is the problem you are having?
I cannot think of a variable value (equation) that can be added onto every x/y value in the code that will leave it in the same position as before, but on a different window resolution. If I were to just simply change the resolution to max;max and do nothing more, the game would end up being drawn in the bottom left corner of the screen.
Describe what you have tried to solve this problem
I have tried designing equations that will centre the existing coordinates of x/y values, but I haven't found anything that works yet. Another way to solve this that I can think of would be to have a fullscreen window opened behind the playing screen. I'm not sure how to go about doing that either though...
Please specify what version of Turing you are using
4.1
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Tony
|
Posted: Sat Jan 28, 2012 3:39 pm Post subject: RE:Centering existing coordinates after switching from set resolution to max |
|
|
(maxx - game_width) gives you the size of the extra space you have to fill. Half of that would center the content horizontally.
|
Tony's programming blog. DWITE - a programming contest. |
|
|
|
|
Srlancelot39
|
Posted: Sat Jan 28, 2012 4:52 pm Post subject: RE:Centering existing coordinates after switching from set resolution to max |
|
|
Thanks, but my friend and I just realised that there are tens of thousands of instances where this would have to be implemented...not worth the tedious work just to have a black background behind the game lol
We're planning on rebuilding the game in Java at some point, so we'll just make sure we code it to be fullscreen and centered when we rebuild it.
But thanks again for your help!
P.S. It's Coldkick and SNIPERDUDE that have been working on this with me if you're curious
|
|
|
|
|
|
Aange10
|
Posted: Sat Jan 28, 2012 5:36 pm Post subject: RE:Centering existing coordinates after switching from set resolution to max |
|
|
Quote: Thanks, but my friend and I just realised that there are tens of thousands of instances where this would have to be implemented
I usually just do things in percents.
EX:
I have a 1000 X 1000 resolution, and I decide I want to put my box at 150,200. Instead of drawing it at 150,200, I draw it at (maxx * .15), (maxx * .2). That away is I change the result ion later It would be the same.
Yeah there are some glitches in this method. Tinkering with alignment can get tricky. But it makes it much easier to change the dimension in a fly.
|
|
|
|
|
|
Srlancelot39
|
Posted: Sun Jan 29, 2012 7:02 pm Post subject: RE:Centering existing coordinates after switching from set resolution to max |
|
|
Wouldnt that mean that if you ran the same program on a 500x500 resolution, it would draw things half as big as before?
If so, I wouldnt be able to use that because nothing would line up properly :s
|
|
|
|
|
|
Aange10
|
Posted: Sun Jan 29, 2012 7:10 pm Post subject: RE:Centering existing coordinates after switching from set resolution to max |
|
|
Yes it'd be smaller, but it wouldn't fall out of alignment. You can even resize pictures in Turing, so that's not a problem either.
EDIT: If it is any proof, I've taken a program and rewrote it to work at any size, without things going out of line.
|
|
|
|
|
|
Srlancelot39
|
Posted: Sun Jan 29, 2012 7:18 pm Post subject: RE:Centering existing coordinates after switching from set resolution to max |
|
|
Hmm, so theoretically I could make my game run fullscreen, but I'd still be faced with the issue of "there are tens of thousands of instances where this would have to be implemented". :\
Thanks though - I actually just finished writing a program to test out what you explained:
code: |
loop
for i : 200 .. 500 by 10
setscreen ("position:middle,centre,graphics:" + intstr (i) + ";" + intstr (i) + ",nobuttonbar,offscreenonly")
cls
drawfillbox (round (maxx * 0.25), round (maxy * 0.25), round (maxx * 0.75), round (maxy * 0.75), black)
View.Update
Time.DelaySinceLast (300)
end for
for decreasing i : 500 .. 200 by 10
setscreen ("position:middle,centre,graphics:" + intstr (i) + ";" + intstr (i) + ",nobuttonbar,offscreenonly")
cls
drawfillbox (round (maxx * 0.25), round (maxy * 0.25), round (maxx * 0.75), round (maxy * 0.75), black)
View.Update
Time.DelaySinceLast (300)
end for
end loop
|
EDIT: WARNING - It's difficult to stop the program once it's running...
|
|
|
|
|
|
Aange10
|
Posted: Sun Jan 29, 2012 7:44 pm Post subject: Re: Centering existing coordinates after switching from set resolution to max |
|
|
Here, just try it with this. This is the program I rewrote (it's a database I use for Maplestory) to be realizable. Just change the screenx/y variables at the top, and see it work. Just go into the search bar and search for something to see how the text changes alignment, etc.
Description: |
|
Download |
Filename: |
MaplePrices.rar |
Filesize: |
610.66 KB |
Downloaded: |
74 Time(s) |
|
|
|
|
|
|
Sponsor Sponsor
|
|
|
Srlancelot39
|
Posted: Tue Jan 31, 2012 8:36 pm Post subject: RE:Centering existing coordinates after switching from set resolution to max |
|
|
So I should be using Pic.Scale instead of Pic.Draw, and then use the same scaling on the collision detection and code-drawn images?
|
|
|
|
|
|
Aange10
|
Posted: Tue Jan 31, 2012 8:44 pm Post subject: RE:Centering existing coordinates after switching from set resolution to max |
|
|
Well, Pic.Scale is like Pic.FileNew, except that it takes a picture and re sizes it. It doesn't draw it to the screen like Pic.Draw.
I'm not sure what you mean by scaling, but you can use (maxx * ?) instead of hard coded numbers.
But I've found that it makes it MUCH more compatible at different sizes, but you still need to tinker things a bit, even if you have percentages of the screen instead of hard coded digits.
|
|
|
|
|
|
Raknarg
|
Posted: Wed Feb 01, 2012 5:14 pm Post subject: RE:Centering existing coordinates after switching from set resolution to max |
|
|
I haven't bothered to read all the posts, so I'll try something here...
Have you tried taking a picture of the screen, then resizing it and drawing it? You can use Pic.New, then rescale the image, then draw the image to the screen again. Only problem is that you's have to view.update twice to accomplish.
|
|
|
|
|
|
Srlancelot39
|
Posted: Wed Feb 01, 2012 11:12 pm Post subject: RE:Centering existing coordinates after switching from set resolution to max |
|
|
@Aange10 by scaling I mean % of original size. (and i did end up finding out that Pic.Scale is used between Pic.FileNew and Pic.Draw lol)
@Raknarg sounds possible, but I'd imagine that'd cause a lot of lag. The collision detection would still be an issue as well.
|
|
|
|
|
|
Raknarg
|
Posted: Thu Feb 02, 2012 8:15 am Post subject: RE:Centering existing coordinates after switching from set resolution to max |
|
|
Yup, and it would be annoying. I'm just saying that if you dont want to have to rescale everything (which, as you said, would take forever), then you can do that.
And I don't see why. You're not using pictures for collision, you're using calculations.
Unless im mistaken and you use whatdotcolour or something
|
|
|
|
|
|
|
|