Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 [C++ Help (SDL)] How do I know what coordinate to draw things to?
Index -> Programming, C++ -> C++ Help
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Shinobu




PostPosted: Thu Sep 12, 2013 4:22 pm   Post subject: [C++ Help (SDL)] How do I know what coordinate to draw things to?

http://lazyfoo.net/SDL_tutorials/lesson02/index.php
I get everything he says in there, after reading it a lot of times. But how did he know where to draw his coordinates? He drew his to (0,0), (320,0), (0,240), and (320,24).
I just made a random picture to practice with, but how do I know what coordinates to draw to? I mean if I just copy his coordinates, I'm not going to learn where to draw things if I wanted to make a game.
Will I learn that later on? Should I care about it yet? Sad
Sponsor
Sponsor
Sponsor
sponsor
Insectoid




PostPosted: Thu Sep 12, 2013 5:03 pm   Post subject: RE:[C++ Help (SDL)] How do I know what coordinate to draw things to?

He set his window size to 640x480. 320x240 is simply 1/4 of that (half of each dimension).
Shinobu




PostPosted: Thu Sep 12, 2013 5:34 pm   Post subject: Re: RE:[C++ Help (SDL)] How do I know what coordinate to draw things to?

Insectoid @ September 12th 2013, 5:03 pm wrote:
He set his window size to 640x480. 320x240 is simply 1/4 of that (half of each dimension).

Dang, that's kinda confusing Sad
So to know where to draw things, I will have to always do something like that? Crying or Very sad
Insectoid




PostPosted: Thu Sep 12, 2013 5:38 pm   Post subject: RE:[C++ Help (SDL)] How do I know what coordinate to draw things to?

Well, if you know the size of your window, you can roughly approximate where a coordinate is. The top-left of the screen is (0,0) and the bottom right is (width, height). You will have to experiment with values a bit if you want precise placement, but it's really not that hard.
Shinobu




PostPosted: Thu Sep 12, 2013 5:41 pm   Post subject: Re: RE:[C++ Help (SDL)] How do I know what coordinate to draw things to?

Insectoid @ September 12th 2013, 5:38 pm wrote:
Well, if you know the size of your window, you can roughly approximate where a coordinate is. The top-left of the screen is (0,0) and the bottom right is (width, height). You will have to experiment with values a bit if you want precise placement, but it's really not that hard.


So I'll have to always guess? Sad
Dang, 3d games must be really hard to make then.

Just wondering, what if I don't know the size of the window (just pretend I don't). Then what? XD

I'm just curious Wink
Nathan4102




PostPosted: Thu Sep 12, 2013 6:20 pm   Post subject: RE:[C++ Help (SDL)] How do I know what coordinate to draw things to?

In 3d games, you're never using hard numbers, its all done with calculations and crazy wizardry. Wink

If you don't know the size of your window, there's always a function to find the size of your window, so that shouldn't be a problem. If you can't do that, assume you have a 2x2 window, and do your best to get your point across using that.
Shinobu




PostPosted: Thu Sep 12, 2013 7:04 pm   Post subject: Re: RE:[C++ Help (SDL)] How do I know what coordinate to draw things to?

Nathan4102 @ September 12th 2013, 6:20 pm wrote:
In 3d games, you're never using hard numbers, its all done with calculations and crazy wizardry. Wink

If you don't know the size of your window, there's always a function to find the size of your window, so that shouldn't be a problem. If you can't do that, assume you have a 2x2 window, and do your best to get your point across using that.


Arghhhhhhhh making games just becomes 1000 times harder than before now -_-
Guess I'll just continue LazyFoo's tutorials now xD
Thanks guys
Nathan4102




PostPosted: Thu Sep 12, 2013 8:30 pm   Post subject: RE:[C++ Help (SDL)] How do I know what coordinate to draw things to?

Don't worry about 3d games right now! I've been programming for a couple years now and I've never tried anything 3D. I remember one time I looked at some code of a 3D engine, and I realied it's WAY past me, both programming wise and math/physics wise.

Making games isn't THAT hard, you just need to be a good problem solver, and be persistent enough to keep trying until you finally get the result you want. Oh, and you should know the basic syntax of your language, how to draw stuff to the screen, and how to recieve input from the user via mouse clicks and key presses.
Sponsor
Sponsor
Sponsor
sponsor
Raknarg




PostPosted: Thu Sep 12, 2013 9:40 pm   Post subject: RE:[C++ Help (SDL)] How do I know what coordinate to draw things to?

3D engines aren't as hard as they looks, it's more of a matter of wrapping your head around converting 3d to 2d. Once that makes sense, they're no different. Imagine, people use 4 dimensions sometimes when programming in 3d Wink

As for the graphics, it's not really hard, just very, very time consuming if you hard code everything. In most cases, you can use sprites or pictures for everything, the only thing you need to hard code is menu screens and HUD interfaces, which are much simpler.
Shinobu




PostPosted: Sat Sep 14, 2013 10:05 am   Post subject: Re: RE:[C++ Help (SDL)] How do I know what coordinate to draw things to?

Nathan4102 @ September 12th 2013, 8:30 pm wrote:
Don't worry about 3d games right now! I've been programming for a couple years now and I've never tried anything 3D. I remember one time I looked at some code of a 3D engine, and I realied it's WAY past me, both programming wise and math/physics wise.

Making games isn't THAT hard, you just need to be a good problem solver, and be persistent enough to keep trying until you finally get the result you want. Oh, and you should know the basic syntax of your language, how to draw stuff to the screen, and how to recieve input from the user via mouse clicks and key presses.

Haha, that's what I'm doing Smile I finally learnt how to make the 'X' button close the window lol (the start of handling events).

Raknarg @ September 12th 2013, 9:40 pm wrote:
3D engines aren't as hard as they looks, it's more of a matter of wrapping your head around converting 3d to 2d. Once that makes sense, they're no different. Imagine, people use 4 dimensions sometimes when programming in 3d Wink

As for the graphics, it's not really hard, just very, very time consuming if you hard code everything. In most cases, you can use sprites or pictures for everything, the only thing you need to hard code is menu screens and HUD interfaces, which are much simpler.

I thought people hard coded the whole game, like Diablo 3 for example. So they use level editors or something? XD
Insectoid




PostPosted: Sat Sep 14, 2013 1:43 pm   Post subject: RE:[C++ Help (SDL)] How do I know what coordinate to draw things to?

They absolutely use level editors. Once you have an engine, the editor can be built on top of it relatively quickly, especially compared to coding the levels by hand.
Shinobu




PostPosted: Sun Sep 15, 2013 6:12 pm   Post subject: Re: RE:[C++ Help (SDL)] How do I know what coordinate to draw things to?

Insectoid @ September 14th 2013, 1:43 pm wrote:
They absolutely use level editors. Once you have an engine, the editor can be built on top of it relatively quickly, especially compared to coding the levels by hand.


What are engines? LazyFoo's tutorials didn't mention that... at least I don't think so when I just checked lol.
I found in article of his talking about level editors, which I'll take a look at that later Razz

I have a question that's bothering me right now, if you'd like to help Smile
Let's say we have an add function that returns the variables x and y.
Does the way I code it matter?
The way I see all the time:
c++:
int add (int x, int y) {
        return x + y;
}

The way I do it (more clear in my opinion):
c++:
int add (int x, int y)
{
        return x + y;
}

And the way the professional teacher in a DVD my dad gave me does it:
c++:
int add (int x, int y) { return x + y }

The last way is the worst way to do it in my opinion, but my dad keeps saying he's professional and everything, and I'm wondering if companies actually care about which way you make your programs.
Does it really matter about just saving a few lines but deleting spaces like that?
It really confuses me when I read code like that. Sad

Thanks Smile
DemonWasp




PostPosted: Sun Sep 15, 2013 7:38 pm   Post subject: RE:[C++ Help (SDL)] How do I know what coordinate to draw things to?

Teams will usually choose one standard and will expect all programmers on that team to stick to that standard (usually the first one you listed, though there are tons of variations). The most organized teams will have some established way of having the computer format your code for you.

The last example you listed is usually frowned upon and may be used only because it neatly fits on one line, which is important in (for example) presentations with limited screen space.
Shinobu




PostPosted: Sun Sep 15, 2013 8:11 pm   Post subject: Re: RE:[C++ Help (SDL)] How do I know what coordinate to draw things to?

DemonWasp @ September 15th 2013, 7:38 pm wrote:
Teams will usually choose one standard and will expect all programmers on that team to stick to that standard (usually the first one you listed, though there are tons of variations). The most organized teams will have some established way of having the computer format your code for you.

The last example you listed is usually frowned upon and may be used only because it neatly fits on one line, which is important in (for example) presentations with limited screen space.

Ah, no wonder the person in the video used the last way. The screen was limited, and he wanted to fit the whole code without having to scroll down and up I think.
I wish people liked the second way, it's more readable in my opinion XD
I'm always trying to make my code as readable as it can be Razz

Thanks Smile
Insectoid




PostPosted: Sun Sep 15, 2013 8:21 pm   Post subject: RE:[C++ Help (SDL)] How do I know what coordinate to draw things to?

There's no real consensus about which of the two formats to use. All of my teachers have always used the 2nd format, but I prefer the first. I find it more difficult to find the indents in the 2nd format, and all the extra whitespace really bothers me.
Display posts from previous:   
   Index -> Programming, C++ -> C++ Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 24 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: