• 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

    • Ahh, I didn't know that. It makes sense. I was thinking I would be fine with 50 hours, but 100 is close enough that I wouldn't feel like I am paying for more than I am using. I might check it out sometime.
    • Google's next-gen Tensor AI chips might be produced by Samsung, report says by Hamid Ganji Image via Google Google’s Tensor Processing Unit (TPU) is produced in collaboration with companies such as Broadcom and TSMC, but a recent report suggests that the search giant is in talks with Samsung to hand over part of the production to the Korean tech company. According to a report by The Information, citing people familiar with the matter, Google has begun talks with Samsung about using its chip manufacturing capacity for the next generation of Tensor AI chips. Google’s upcoming TPUs are reportedly codenamed “Icefish” and will be produced using Samsung's 2-nanometer process technology. Meanwhile, Samsung is expected to produce only a portion of the next-generation Tensor chips, with most of the production remaining at TSMC. The Information says the new Tensor chips are currently in the design stage and are scheduled to enter mass production in 2028. TSMC is generally considered one of the most reliable chip manufacturing partners and is trusted by tech giants such as Apple and Google. However, the growing demand for TSMC’s AI chips, combined with the company’s focus on meeting demand from AI data centers, has reportedly prompted Google to seek additional manufacturing partners for its next-generation TPUs. Besides Samsung and TSMC, Intel could also be assigned part of the production. The Information reported this week is that Google has begun talks with Intel to produce up to three million TPUs in 2028. However, this is not the first time Google has partnered with Samsung on chip production, as Samsung has previously manufactured Tensor chips for Pixel smartphones. Google’s Tensor Processing Unit is used in cloud data centers and competes with NVIDIA’s chips, which currently dominate the market. By relying on in-house chips, Google can not only reduce its dependence on third-party providers but also create new revenue opportunities. The company has already supplied its TPUs to the AI firm Anthropic.
    • Reminder that the Premium and Ultimate plans already come with a 100 hour per month limit, which you then have to pay more to increase in 15 hour blocks.
    • It does invite Linux because MS should have been improving their products all along these years instead chose to ignore the users now this year they’re making all of these improvements to their products where as Linux doesn’t have this kind of problems in fact it has gotten so good I can even play Windows games in Steam that I no longer ever needed Windows to carry on with my life, unlike you still use Windows and chose to try beat down down those who don't use Windows because they love their LG TV. (Surprisingly I actually own a 55” LED LG TV and it has been going strong for almost 14 years, longer than any Sony TV”)
    • As much as I love owning my own hardware, it's hard to argue with the value. I'm not a huge gamer, I'd actually be interested in a cheaper plan with limited monthly hours, or even a pay-by-the-hour plan.
  • Recent Achievements

    • Week One Done
      FBSPL earned a badge
      Week One Done
    • One Year In
      Jim Dugan earned a badge
      One Year In
    • One Month Later
      Tommi118 earned a badge
      One Month Later
    • One Month Later
      sjbousquet earned a badge
      One Month Later
    • Week One Done
      sjbousquet earned a badge
      Week One Done
  • Popular Contributors

    1. 1
      +primortal
      487
    2. 2
      PsYcHoKiLLa
      196
    3. 3
      +Edouard
      155
    4. 4
      Steven P.
      84
    5. 5
      ATLien_0
      69
  • Tell a friend

    Love Neowin? Tell a friend!