• 0

How to be a game programmer and developer?


Question

Hello :) .I am new in this forum and i am really interested in programming.I really want to learn to program with Cuda, C++ you know. I want to make my own game engines and 3D games with stunning grafiks. I saw really interesting things in the Nvidia developer zone like Nvidia PhysX SDK, OpenGL, OpenCL, DirectX and many other stuff. I want to learn how to program with them and for what and how can i use it? What i must learn first? From what i must start? What book's i must read of i am new to software and game programming? I am really confused. Thank's :D .

Recommended Posts

  • 0

No, it must check if it's not 1, 2................ And for that it must return false every time of it is a 1, 2.................., but it don't works with the !=. I don't now why.

Well lets think about this logically. Your statement

               if(input==0||input==1||input==2||input==3||input==4||input==5||input==6||input==7||input==8)
                {
                }
                else
                        goto input;

says ?If input is equal to 0 or if input is equal to 1 or? or if input is equal to 8: do nothing. Otherwise: goto input?.

If you change the statement to be

               if(input!=0||input!=1||input!=2||input!=3||input!=4||input!=5||input!=6||input!=7||input!=8)
                               goto input;

it says ?If input is not equal to 0(in other words, if input is any number but 0) or if input is not equal to 1 ? or if input is any number but 8: goto input?. Since any number but 0 makes the statement true and any number but 1 makes the statement true, any number makes the statement true and will always execute the goto. So, this is not correct.

Here's a hint:

Consider the way that an if else statement works. If a statement is true, a block of code in your if (your empty code block) will execute. If a statement is false, a block of code in your else(your goto) will execute.

To switch the code blocks but maintain the same logic, you have to have the new if statement be false when the original would be true and have the new if statement be true when the original would be false, because you would want it to act like the original else.

Do you know an operation you could apply to the original condition of your if statement to do this?

  • 0

Well lets think about this logically. Your statement

               if(input==0||input==1||input==2||input==3||input==4||input==5||input==6||input==7||input==8)
                {
                }
                else
                        goto input;

says ?If input is equal to 0 or if input is equal to 1 or? or if input is equal to 8: do nothing. Otherwise: goto input?.

If you change the statement to be

               if(input!=0||input!=1||input!=2||input!=3||input==4||input==5||input==6||input==7||input==8)
                               goto input;

it says ?If input is not equal to 0(in other words, if input is any number but 0) or if input is not equal to 1 ? or if input is any number but 8: goto input?. Since any number but 0 makes the statement true and any number but 1 makes the statement true, any number makes the statement true and will always execute the goto. So, this is not correct.

Ok this:

if(input!=0||input!=1||input!=2||input!=3||input==4||input==5||input==6||input==7||input==8) 
                               goto input;

isn't the code that i have. If it is then i have made a msitake. I must be:

if (input!=0||input!=1||input!=2||input!=3||input!=4||input!=5||input!=6||input!=7||input!=8)
    goto input;

This must be the code. I have no idea what you mean. If the input is 0,1,2,3,4,5,6,7 and 8 then it must return false, because it will return true when it isn't 0,1,2,3,4,5,6,7 and 8.

  • 0

Ok this:

if(input!=0||input!=1||input!=2||input!=3||input==4||input==5||input==6||input==7||input==8) 
                               goto input;

isn't the code that i have. If it is then i have made a msitake. I must be:

if (input!=0||input!=1||input!=2||input!=3||input!=4||input!=5||input!=6||input!=7||input!=8)
    goto input;

This must be the code. I have no idea what you mean. If the input is 0,1,2,3,4,5,6,7 and 8 then it must return false, because it will return true when it isn't 0,1,2,3,4,5,6,7 and 8.

Sorry about that, I meant to finish changing all the == to !=. Reread my last post. The statement will always be true.

Say input is 1. Your statement asks "is it not 0?", it isn't, so the statement is true. Since only one part of an OR needs to be true to make the entire statement true, we get true and your goto runs.

Say input is 0. Your statement asks "is it not 0?", it is, so that part of the statement (input!=0) is false. Then you have || (an OR), so your statement asks "is it not 1?", it isn't, so the statement is true. Since only one part of an OR needs to be true to make the entire statement true, we get true and your goto runs.

  • 0

Sorry about that, I meant to finish changing all the == to !=. Reread my last post. The statement will always be true.

Say input is 1. Your statement asks "is it not 0?", it isn't, so the statement is true. Since only one part of an OR needs to be true to make the entire statement true, we get true and your goto runs.

Say input is 0. Your statement asks "is it not 0?", it is, so that part of the statement (input!=0) is false. Then you have || (an OR), so your statement asks "is it not 1?", it isn't, so the statement is true. Since only one part of an OR needs to be true to make the entire statement true, we get true and your goto runs.

Oh of course.Yes you are right. I must thing again.

  • 0

Ah i have no idea how to make it without leaving the if statement empty. Any suggestions? And i am still thinking for the AI code. I saw the exmaple and i understand it a little, but i need some time to thing more on it.

My hint should be helpful, if you didn't read it (I added it after I edited my post), I'll repost it:

Consider the way that an if else statement works. If a statement is true, a block of code in your if (your empty code block) will execute. If a statement is false, a block of code in your else(your goto) will execute.

To switch the code blocks but maintain the same logic, you have to have the new if statement be false when the original would be true and have the new if statement be true when the original would be false, because you would want it to act like the original else.

Do you know an operation you could apply to the original condition of your if statement to do this?

  • 0

My hint should be helpful, if you didn't read it (I added it after I edited my post), I'll repost it:

Consider the way that an if else statement works. If a statement is true, a block of code in your if (your empty code block) will execute. If a statement is false, a block of code in your else(your goto) will execute.

To switch the code blocks but maintain the same logic, you have to have the new if statement be false when the original would be true and have the new if statement be true when the original would be false, because you would want it to act like the original else.

Do you know an operation you could apply to the original condition of your if statement to do this?

I know how the if statement works and how to switch it, but i don't know how to do it in this case. It's really confusing.

  • 0

I know how the if statement works and how to switch it, but i don't know how to do it in this case. It's really confusing.

Have you heard of negation?

You want to negate the entire statement.

if(!(input==0||input==1||input==2||input==3||input==4||input==5||input==6||input==7||input==8))
               goto input;

When your original statement was false (and your original else was triggered), your new if is true and will trigger.

Now you should have something in your code like:

input:
                cout<<"Input:";
                cin>>input;
                if(!(input==0||input==1||input==2||input==3||input==4||input==5||input==6||input==7||input==8))
                                goto input;
                if(board[input]=='X'||board[input]=='O')
                                goto input;

This can (and should) be converted to a loop. First step is to combine the two if statements, since the both have the same body. The structure of the loop should pop out at you after that.

  • 0

Have you heard of negation?

You want to negate the entire statement.

if(!(input==0||input==1||input==2||input==3||input==4||input==5||input==6||input==7||input==8))
               goto input;

When your original statement was false (and your original else was triggered), your new if is true and will trigger.

Now you should have something in your code like:

input:
                cout<<"Input:";
                cin>>input;
                if(!(input==0||input==1||input==2||input==3||input==4||input==5||input==6||input==7||input==8))
                                goto input;
                if(board[input]=='X'||board[input]=='O')
                                goto input;

This can (and should) be converted to a loop. First step is to combine the two if statements, since the both have the same body. The structure of the loop should pop out at you after that.

Thank you. I haven't heard for negation before. And what's the plus for making the goto to a loop? Better speed?

  • 0

And what's the plus for making the goto to a loop? Better speed?

Goto is bad. Unless you have a large structure of loops and switches with all sort of crazy conditions going on and you need to break out of it you shouldn't be using it at all. It makes things unmanageable very quickly.

  • 0

Goto is bad.

A lot of people have the wrong impression about goto. I use it often to eliminate clean-up repetition. I think the misrepresentation stems from the overuse/abuse of it instead of applying other more appropriate constructs to certain situations. Keeping the size of a function to manageable levels and implementing pragmatic conditional statements prevent the aforementioned abuse. However, goto has its uses and I would never label it 'bad'. Any construct can be 'bad' if the programmer misuses it.

Besides, when you get down to it, a loop is compiled to a loop <label> or jmp <label>, which acts just like a goto, in x86/x86_64 assembly format anyway.

  • 0

if(!(input==0||input==1||input==2||input==3||input==4||input==5||input==6||input==7||input==8))
   			goto input;

This statement can also be condensed by using greater than and less than.

if (input &lt; 0 || input &gt; 8) { goto input; }

or

if (!(input &gt; 0 &amp;&amp; input &lt; 8)) { goto input; }

You could also wrap the user input section in a do-while loop.

do
{
 	//get user input
} while (/*some condition here*/);

Your program will keep asking for input until they enter valid input. The difference between a do-while loop and a while loop is that a do-while executes the the code inside of its braces at least once. You use the do-while when the evaluated condition is determined inside the do-while itself.

  • 0

Goto can be a useful tool if you know what you're doing. emilxp learned loops yesterday. :rolleyes: It's a bit early to start using goto when you're barely aware that safer constructs exist. In this particular case, the use of goto simply shows that he's not familiar with the while loop, rather than the carefully weighed decision of an experienced developper.

Not using goto will also force him to structure his programs in more intelligent ways than spaghetti. An experienced developper knows how to avoid spaghetti code, even with a few gotos here and there; emilxp doesn't.

One thing at a time.

  • 0

Goto can be a useful tool if you know what you're doing. emilxp learned loops yesterday. :rolleyes: It's a bit early to start using goto when you're barely aware that safer constructs exist. In this particular case, the use of goto simply shows that he's not familiar with the while loop, rather than the carefully weighed decision of an experienced developper.

Not using goto will also force him to structure his programs in more intelligent ways than spaghetti. An experienced developper knows how to avoid spaghetti code, even with a few gotos here and there; emilxp doesn't.

One thing at a time.

Of course i know what's a while loop. This was the first loop that i have learned. I learned it before a few months. Yesterday i learned the for loop. The do while loop i have learned with the while loop.

  • 0

Ok sorry I assumed you had just learned the while loop. However, your use of a goto there shows you're not very familiar with loops in general. What most programmers would do there is use a while loop; a goto is a bizarre way of achieving what you're trying to do. As others have said, it's better to avoid the goto if you can, because it'll lead to better organized, easier to understand code. That doesn't mean it has no use, but those uses are far and few between, i.e. when using a more robust loop would not be feasible. This is not such a case.

If you read the cplusplus.com tutorial, you'll see that it says:

The goto statement

(...) You should use this feature with caution since its execution causes an unconditional jump ignoring any type of nesting limitations.

(...) Generally speaking, this instruction has no concrete use in structured or object oriented programming aside from those that low-level programming fans may find for it.

  • 0

Ok sorry I assumed you had just learned the while loop. However, your use of a goto there shows you're not very familiar with loops in general. What most programmers would do there is use a while loop; a goto is a bizarre way of achieving what you're trying to do. As others have said, it's better to avoid the goto if you can, because it'll lead to better organized, easier to understand code. That doesn't mean it has no use, but those uses are far and few between, i.e. when using a more robust loop would not be feasible. This is not such a case.

If you read the cplusplus.com tutorial, you'll see that it says:

I think i am familiar with how to use loops, but for when to use loops and from time to time how to use them i am not.I think goto is just easier to use, but if it isn't so much used then i will use loops. And can i see a code example of a real life situation of using a goto?

  • 0

I think i am familiar with how to use loops, but for when to use loops and from time to time how to use them i am not.I think goto is just easier to use, but if it isn't so much used then i will use loops. And can i see a code example of a real life situation of using a goto?

When you end up with something like this:

for (...) {
   for (...) {
    	while (...) {
             	if (should_exit_loops) {
                     	goto the_end;
              	}
     	}
   }
}
the_end:
MessageBoxW("The end", "", MB_OK);

  • 0

When you end up with something like this:

for (...) {
   for (...) {
    	while (...) {
             	if (should_exit_loops) {
                     	goto the_end;
              	}
     	}
   }
}
the_end:
MessageBoxW("The end", "", MB_OK);

Ou yes you are absolutely right. This is the best method in this situation, but it is possible to be made without the goto, but why to make it without the goto when the goto exist :) . Ok i thing i am learning really slowly, because i know people who make game engine from the ground and they are just a few years older than me.

  • 0

Ok we are talking for a Tic-Tac-Toe game more than 10 pages! The good thing is that there is now a topic specialy for Tic-Tac-Toe games now :) . Ok really this topic isn't for programming Tic-Tac-Toe. Lets talk about the subject of this topic?

  • 0

Ok we are talking for a Tic-Tac-Toe game more than 10 pages! The good thing is that there is now a topic specialy for Tic-Tac-Toe games now :) . Ok really this topic isn't for programming Tic-Tac-Toe. Lets talk about the subject of this topic?

You?re right. Tic-Tac-Toe was a nice project, but it doesn?t let you focus on the fundamentals. I posted the a while ago in this thread but it didn?t get noticed, I?m going to give you some of the assignments I was given in one of my high school courses. Hopefully they won?t be so hard, but help you get some of the fundamentals. Here are 3 separate assignments.

  • Populate an array with 10 random numbers. Print out those numbers, then ask the user if they want to search for a value (printing out it?s index), find the max value, find the minimum value, or to quit and have the program respond appropriately.
  • Populate an array with the following values ?a?, ?b?, ?c?, ?d?, ?e?. Ask the user for a number value and preform a right shift operation on the array and prints the new array. For instance a value of 1 would produce the output ?eabcd? and 2 would be ?deabc?.
  • Preform a Selection Sort on an array of 5 random integers, printing out the array at each step. For example:
    5 2 7 4 1
    1 2 7 4 5
    1 2 7 4 5
    1 2 4 7 5
    1 2 4 5 7
    1 2 4 5 7

  • 0

Once you've been through the cplusplus.com tutorial, make sure to check out How To Think Like a Computer Scientist, C++ edition. This is a very solid, comprehensive course on all the basic concepts of computer science, with exercices.

  • 0

Aham. Ok what do you thing about this:

1st: C++ Primer Plus

2nd: The C++ Programming Language Special Edition

3th:Effective C++ and STL books

I thing this is the perfect path for learning C++. C++ Primer Plus covers so many stuff. I haven't hear more than 50% from them. The second book and the effective C++ and STL books help you master the language. What do you thing about my choice?

  • 0

Once you've been through the cplusplus.com tutorial, make sure to check out How To Think Like a Computer Scientist, C++ edition. This is a very solid, comprehensive course on all the basic concepts of computer science, with exercices.

Aham. Ok what do you thing about this:

1st: C++ Primer Plus

2nd: The C++ Programming Language Special Edition

3th:Effective C++ and STL books

I thing this is the perfect path for learning C++. C++ Primer Plus covers so many stuff. I haven't hear more than 50% from them. The second book and the effective C++ and STL books help you master the language. What do you thing about my choice?

I've been lurking this thread a while, haven't read all pages but most people that give you advice point you to online resources that are great at teaching you programming.

The three books that you suggests are no doubt good books, but what is wrong with for instance cplusplus.com? The BIG important thing when you pick up programming is to teach yourself the principles and thinking like a computer scientist. The language you write your programs in when you learn the principles are largely irrelevant. It's the logic behind how programs are made that are important. Once you master one language, learning the next one is easy, and the next one after will be even easier. The thought processes behind writing code will be about the same in any language.

Look, you've been asking about books since December, and you only recently seem to have grasped the basics of logical statements and loops. In the same time you could've finished several courses of computer science. I understand your desire to read up on the subjects, but trust me, without lots and lots of practice at coding principles you will get stumped even trying to draw a teapot with C++ and OpenGL.

  • 0

I've been lurking this thread a while, haven't read all pages but most people that give you advice point you to online resources that are great at teaching you programming.

The three books that you suggests are no doubt good books, but what is wrong with for instance cplusplus.com? The BIG important thing when you pick up programming is to teach yourself the principles and thinking like a computer scientist. The language you write your programs in when you learn the principles are largely irrelevant. It's the logic behind how programs are made that are important. Once you master one language, learning the next one is easy, and the next one after will be even easier. The thought processes behind writing code will be about the same in any language.

Look, you've been asking about books since December, and you only recently seem to have grasped the basics of logical statements and loops. In the same time you could've finished several courses of computer science. I understand your desire to read up on the subjects, but trust me, without lots and lots of practice at coding principles you will get stumped even trying to draw a teapot with C++ and OpenGL.

Ok you said that you haven't read the whole topic. Yes i think it's true, because there are many reasons why i haven't started a course of computer science of something other.You will se in the topic the reasons, but i will tell them in this post: 1st: I am 13 years old so i can't go to college or univercity, 2nd: in december i had to go to school. I am in vacation from i can say the begginning of july, but we've finished the year in thr 15 of june, but i had work so my vacation started from the bugginning of july, 3th: I have no idea where in Bulgaria are good courses for computer science, programming etc. 4th: I don't have the money for that.

And i thing the books are great. Why you don't like them? Ok for effective c++ and/or stl it is possible, because you can learn these things from other books or alone i thing, but the books from the creator of c++? And C++ Primer Plus for me is not so bad. It covers so many stuff, but for now i am 100% sure if it's good or not. I thing i will understand the stuff in the book, because you see i can program alone a tic-tac-toe and the new version of it with the help of the forum :) .

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Posts

    • It is silly there is no simple way to check whether this profile has been activated. CFRs are normal, but trying to even hide the fact if it's on / off seems silly, especially for something so user-facing. Surely Microsoft is "proud" of their engineering efforts on this one and ought to display it somwhere in the GUI.
    • Many Linux distros are not known for excellent battery life, so I'm not sure that is the best example. A more apt example may be Apple, but Apple's CPUs are simply far more efficient than Intel & AMD at single-threaded tasks like these, so "boosting" is not as power-hungry and less heat-inducing. Not to mention Apple will hardly engage P-cores for basic UI tasks; they use a pretty complicated QoS scheme to only activate P-cores for more serious workloads like HTML / JS execution or decompression or application launch. Microsoft is (smartly) doing it for launch, but also for UI tasks, which is the more nonsensical part: why ... do Windows 11's UIs need modern CPUs to boost? It should load so quickly that there's not even time for the CPU to boost.
    • I've not seen any controlled testing and, judging by Microsoft's mentality, within a year, they'll have added so much more bloat, it'll undo any perceptible latency benefit and we'll have boosted the CPU clocks for nothing.
    • It depends: heat soak is a thing. Initially on cold boot-up, the heatsinks & heatpipes are at ambient temp. After heatsinks & heatpipes warm up (through normal usage), they don't immediately cool to ambient temp when the load goes away. So their baseline is higher and the trigger point for fans is much less stress. Add a few more CPU spikes → it's too hot to stay at the same fan RPM → fans get triggered to start up up much sooner / get triggered to ramp much more quickly.
    • Can LibreOffice just shut up and worry about themselves and stop comparing themselves? Do we see Microsoft complaining about euro office?
  • Recent Achievements

    • One Year In
      slackerzz earned a badge
      One Year In
    • One Year In
      highriskpaym earned a badge
      One Year In
    • One Month Later
      highriskpaym earned a badge
      One Month Later
    • Week One Done
      highriskpaym earned a badge
      Week One Done
    • Week One Done
      FBSPL earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      501
    2. 2
      PsYcHoKiLLa
      198
    3. 3
      +Edouard
      156
    4. 4
      Steven P.
      84
    5. 5
      ATLien_0
      71
  • Tell a friend

    Love Neowin? Tell a friend!