0
GraphicsWindow.Width = 1080
GraphicsWindow.Height = 607.5

gw = 1080
gh = 607.5
GraphicsWindow.Left = 0
GraphicsWindow.Top = 0

dw = Desktop.Width
dh = Desktop.Height

WidthMod = dw / gw
HeightMod = dh / gh

newWidth = 1080 * WidthMod
newHeight = 607.5 * HeightMod

distanceWidth = newWidth - gw
distanceHeight = newHeight - gh

 LDGraphicsWindow.Reposition(WidthMod, HeightMod, distanceWidth / 2, distanceHeight / 1.3, 0)

The reposition command has the syntax: reposition(scaleX, scaleY, panX, panY, angle).
I do not understand why dividing the distanceWidth (this is the difference between the old screen and the new screen's size) by 2 or dividing the distanceHeight by 1.3 pans the game to the topmost corner where I need it. I want to pan it so that the game has the same view only dependent on a 16:9 ratio.

Sep Roland
  • 33,889
  • 7
  • 43
  • 76
Caleb
  • 1

1 Answers1

0

LDGraphicsWindow.Reposition doesn't actually move or scale the window at all, it just moves all the shapes inside the window. It's probably not what you're looking for.

If you're just trying to create and center the largest GraphicsWindow for a given aspect ratio, that can easily be done with pretty standard code:

textRatio = "16:9"

ratioArr = LDText.Split(textRatio, ":")

ratio = ratioArr[1] / ratioArr[2] ' Get the numerical ratio from the text
curRatio = Desktop.Width/Desktop.Height ' Get the current ratio

GraphicsWindow.Show()

If curRatio > ratio Then 'Screen is too wide
  GraphicsWindow.Width = Desktop.Height * ratio
  GraphicsWindow.Height = Desktop.Height
ElseIf curRatio < ratio Then 'Screen is too tall
  GraphicsWindow.Height = Desktop.Width / ratio
  GraphicsWindow.Width = Desktop.Width
EndIf

'Center the window
GraphicsWindow.Left = (Desktop.Width/2)-(GraphicsWindow.Width/2)
GraphicsWindow.Top = (Desktop.Height/2)-(GraphicsWindow.Height/2)
Sep Roland
  • 33,889
  • 7
  • 43
  • 76
Zock77
  • 951
  • 8
  • 26
  • but i want to scale the shapes using reposition for the new size, without ldgraphicswindow.reposition, is this possible in small basic? – Caleb Dec 08 '21 at 03:00
  • like lets say there is a 100x100 room in a 600x600 room. The view should be the same i.e a bigger screen is not advantageous. I am a bit of a newbie so I am sorry if my questions are hard to understand but if you understand what I mean, how can it be scaled in small basic? – Caleb Dec 08 '21 at 03:11