Sign in to follow this  
Justindano

SDL Co-ordinates

Recommended Posts

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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
[quote name='JustinDaniel' timestamp='1318598107' post='4872505']
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.
[/quote]

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.

Share this post


Link to post
Share on other sites
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:

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

Share this post


Link to post
Share on other sites
[quote name='ravinDavin' timestamp='1318614989' post='4872610']
The way I remember the Y direction is:

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


lol

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

Sign in to follow this