Skip to main content
GameDev.net gamedev.net
🔒 Locked

SDL Co-ordinates

Started by Justindano Oct 14, 2011 at 10:19 AM 4 replies 2.4k views
Original Post
Justindano
Justindano
Hey Guys,
My major problem is I always get confused when drawing a image onto the screen in SDL, I know that SDL coordinates are not as regular as in the real world, But my doubt is suppose, if i draw a square onto SDL coordinates in x and y axis. How will i calculate its offsets, This confuses me alot sometimes.
Could someone please help me ,
Thanks in advance.
chosenkill6
chosenkill6
SDL coordinates are like most graphic engine coordinates, they start at the top left corner of your screen/window. The more you go down the screen the Y increases and as you go across to the right the X increases

Ex. If you want an image in the top left corner set its X to 0 and it's Y to 0
This way the top left corner of the image will be at the top left corner of te screen.
Justindano
Justindano
Thanks,
But i know that the co ordinates start from the top left corner, What im asking is, if i place a square say at ( 200, 200 ) will it have the same offset as the screens offset or different.
Ectara
Ectara

Thanks,
But i know that the co ordinates start from the top left corner, What im asking is, if i place a square say at ( 200, 200 ) will it have the same offset as the screens offset or different.


Not sure if by "screen" you mean the physical display, or the window in which you are drawing. If you mean the window, placing a square at (200, 200) will appear at (200, 200) in the window, as long as the square's coordinates are zero indexed. If you mean the display, then unless the SDL screen surface is fullscreen, you are constrained by drawing in the window. All coordinates are relative to the window's origin.
ravinDavin
ravinDavin
And also, If you draw a Sprite at position (200,200) for example, That means that the images top left corner is set at that position. Unless you transform it's origin.

The way I remember the Y direction is:


A girl goes down in front of you = positive
[/quote]
DaveMS
DaveMS

The way I remember the Y direction is:


A girl goes down in front of you = positive

[/quote]


lol

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.