do not respond

Pages: 12
closed account (N8MNAqkS)
I was never trying to argue. let me clarify some things. I do write my own code. I never said watching people did not work. I never said all I could do was copy and paste. I learn the way that I feel works for me, and that is fine. I am trying to learn hence the posts I have on the forums.

furry guy and repeater I would appreciate it if you never respond to one of my posts again.
Last edited on
Is there any part of game programming that isn't copy and paste?

As an editing tool, copy/cut/paste is fine: moving text around is often useful when editing source code. But it is not a design tool - it will not program your computer for you.

Repetition in source code has its own cost: copy-pasting the same block of code more than once is potentially expensive and may lead to an end product which is worse:
https://en.wikipedia.org/wiki/Don%27t_repeat_yourself

One should not write code that they can't understand. Much less copy-paste it: that's complete insanity.

Good software of any significance only appears when some degree of engineering discipline is applied.

(The answer is "yes", there's plenty of work that isn't just copy-paste. Even if it's just gluing together code that's already been written.)
Last edited on
copy paste to build a toy, disposable tool, prototype, etc is a valuable skill to have. You can slap together a working useful program in a few min if you understand this approach. The key is understanding what you get out too.. the source code and resulting program will become bug ridden junk at an increasing rate directly tied to the size of the program. More than a few pages of this kind of code tends to have problems at an alarming rate, and by the time you can fix all the issues, you could have done a better job on it writing it from scratch yourself (at least you should have been able to do that). It can give you a starting point to learn a library or something too.

What you have learned to do is a useful skill. Now you need to learn other useful skills, and when to apply them.

Game programming is difficult. C++ is said to take 2-3 years to master. You are just getting started, and you are trying to do a difficult thing with insufficient background and skillset. Be patient, keep learning, and you will get there.
Last edited on
I have been trying to learn c++ for maybe over 4 months now

When you've been plugging away at it for 15+ years like I've done, without any formal training, reading books good & bad and code samples scattered across the internet, then get back to me how hard learning C++ is.

Programming for me is a hobby, nothing else.

Self-teaching makes for a lot of mistakes, a lot of frustration and a lot of "eureka!" moments when a concept that seemed would be impossible to grasp suddenly makes sense.

After 15+ years I still consider myself a beginner. There is still lots to learn. And improve on what I already know.
Last edited on
Furry Guy wrote:

After 15+ years I still consider myself a beginner. There is still lots to learn. And improve on what I already know.

“The more I learn, the more I realize how much I don't know.” -- Albert Einstein

I started out learning programming in high school as a hobby because I took an interest in making video games and because I already had an interest in computers. C++ was my first language and it beat me up so much, but I still very slowly continued with it. When naive 15 year old me first discovered the beginner's forums, I already knew the basic building blocks and syntaxes of C++, but I was still surprised by the questions being asked on the beginner's forum. I thought to myself "there's no way these are beginner questions" because I honestly didn't know what any of the code posted on the beginner's forum meant.

Fast forward a few years and I'm college. I'll come on here if I truly have time to lurk around and see what's hot in the lounge. If I'm very bored or just not doing my homework, I'll perhaps help a few peeps out in the beginner section. I consider myself to be able to program, but I still consider myself to be a pretty big noob. C++ has revisions, and there will always be new technology. There's so much to learn and so much to improve. Time is so finite...

HueMungus wrote:

because I literally suck at everything.

Here is a nice quote:
"Dude, sucking at something is the first step towards being sorta good at something." -- Jake the Dog (Adventure Time)
My father was a programmer software engineer since before I was born (early 70s).

He has written stuff that would blow your mind.

For example, remember the old teletype TV channels? Like, when you changed to channel 18 (or whatever it was for you) and it was just text that told you the weather and school closings and stuff?

My father wrote that.

I remember when I was little he was always playing with some Fourier transform for audio processing... He found that more interesting than the stuff he was writing for use in friggin’ outer space (well, orbit).


Anyway, here’s the point: My father once said to me something like:

There was a time when you could know everything about [computer science]. These days, it’s impossible. I only know a small part of it.

There is such a vast amount of information out there it seems overwhelming and impossible.

We have all had to get past that to become good programmers.
A lot of the people here have been programming for years. I’ve been going at it nearly 30 years now. And I’m still learning stuff.

For example, I just learned about the “as-if” rule, which says (among other things) that C++ does not have to call your destructors if they have no observable effect — which is a headache when they do actually have an effect but the compiler cannot see it. Makes some RAII hard...


The real master programmers are not people who have memorized some language, or can quote some standard or programming principle, or produce pretty code. They are the people who have learned how to learn.

When confronted with something new and confusing, they read about it and mess with it and struggle until it makes sense. And once something is learned, it becomes easy.

Don’t give up. I’m playing with SDL2 right now (it’s nice!) and learning all kinds of stuff. (SDL2 is for game programming.)

You have asked good questions, and seem to have a brain. The struggle is part of it.

Do you have any good tutorials for starting game programming? There is a lot to learn, but a good tutorial will get you through the basics without becoming overwhelming.

A really easy way to start is with PyGame|https://www.pygame.org/
Python + SDL2 = quick and easy to get running with basic concepts.

If you want to continue with C++, SDL2 is good for that too.
https://wiki.libsdl.org/Tutorials

All of these resources come with easy-to-follow tutorials + code you can download and compile and mess with.

Hope this helps.
Adding to other comments here, I don't bother learning the syntax. If I pick it up by using it, that's great, but I can always look it up. What I learn is what the language facilities and libraries allow me to do conceptually; this allows me to think about the problem in a way that takes advantage of the facilities of C++ and associated libraries. I don't bother with syntax until all the hard part - the thinking and problem solving - has been done and all that's left is to physically type code.

Is there any part of game programming that isn't copy and paste?

Basically all of it. It seems that you've accidentally mistaken the part you can easily see (the bit where some code gets typed into an editor) for the part you can't easily see - the act of understanding the facilities offered by the language and libraries and the act of thinking about the problem in terms of those facilities.

A rough analogy would be to watch Will Shakespeare writing some lines of Hamlet with a quill, and thinking that's his art and skill - the writing on paper - and that all you need to do to be as good as him is be able to use a quill. The genius was not in using the quill; the genius was in the thinking inside his head.

To give a trivial example, a person who can understand looping can write a loop for anything, anywhere, so long as they can dig out the syntax. Forwards, backwards, different strides, reversing direction, loops inside loop, early exits, it all flows naturally in their mind. Such a person can think about problems and apply the idea of operating on a sequence of objects in a controlled loop to places where it's a great solution to whatever particular problem (from the infinity of possible problems) they have at hand; the right loop, in the right place at the right time, in any language that has support for looping. Looking up the syntax is the trivial part, done after the actual programming has been done inside this person's head.

A person who focusses on the syntax can only write loops they've seen someone else use before, in languages they've seen the syntax for, because they haven't internalised the concepts and what they're actually doing. It would be like trying to be a novelist by copying out paragraphs from other books and then tweaking the character names.

The person who understands looping can program; the person who memorises syntax without internalising the concept cannot program and can only copy other people's code.
Last edited on
closed account (N8MNAqkS)
@Furry guy. im doing the same thing. I have been learning on my own, with nothing but tutorials on YouTube from a guy named Chilli tomato, and a half outdated c++ book. What is ur point?
I have been learning on my own, with nothing but tutorials on YouTube from a guy named Chilli tomato, and a half outdated c++ book.


You need to write your own programs. You won't learn how to program by watching other people do it, and if you don't learn to program, you'll never be able to do more than just copy other people's code.
My point is giving up so soon, 4 month/a year, is a self-fulfilling, self-defeating prophesy.

a half outdated c++ book.

One book. My programming library has 50 currently because I decided to prune the really outdated or known bad ones.

At least with books, multiple, I get a range of what is good code and what isn't.

Learning what is good code and is not happens when one writes their own code that isn't just copy 'n' paste.

There isn't a single book written even today that isn't outdated the moment it is written. How many books deal IN-DEPTH with C++14. Not a one that I can find. Forget about C++17 or known constructs of what will be in C++20.

Too many even recently published books don't really grasp what C++11 added to the language. STL containers? Nah, let's stick with C style arrays. Need random numbers? rand()/srand() when C++ now has very robust architecture for generating random numbers. Both for trivial uses and serious needs.

tutorials on YouTube from a guy named Chilli tomato

Watching video from ONE guy. Wow.

I've seen some of this guy's videos, and frankly IMO he ain't that good. Decent grasp of some of the concepts of the language without any real depth of what is available.

Obviously you will say otherwise.

If you want to watch videos don't go with just one source.

And don't give up so quickly or easily. I've stuck with playing around with C++ for 15+ years, a good amount of that time thinking I was never learning anything.

A lot of the progress happened when I started hanging out here at cplusplus back in 2014, looking at code written by a number of experts. Each one with a different style.

Different styles that in their own way peeled back the layers of the C++ onion.

Compiling code samples at cppreference were also helpful in understanding language concepts.

And with understanding I wrote mini test-bed programs from scratch to solidify my understanding. And then wrote larger programs that pulled together more language features.

Recently I was playing around with 2 dimensional vector containers, how to create and use them effectively, passing 2D vectors into functions, etc.

I wanted, if possible, a way of outputting the contents of a 2D container as easily as doing Plain Old Data like an int or double. Adapting the idea of overloading the std::ostream operator>> into two functions, one for the rows and the other for columns.

Worked great, but for each data type I had to write overloaded functions. A-HA! Templates!

I had earlier used templates to write output functions for 1D & 2D containers of any data type. I combined two different concepts previously learned separately into one package.

The programs also used different ways of looping through containers.

This is ONE of my Frankenstein's monster of program code, put together piece by piece until I got the following:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#include <iostream>
#include <vector>
#include <numeric>

template<typename T>
void Print1DArray(std::vector<T> const&);

template<typename T>
void Print2DArray(std::vector<std::vector<T>> const&);

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v);

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<std::vector<T>>& v);

int main()
{
   // creating a sized vector
   std::vector<int> a1DVector(5);

   std::cout << "Displaying a sized 1D vector:\n";
   std::cout << a1DVector.size() << '\n';

   for (size_t itr = 0; itr < a1DVector.size(); itr++)
   {
      std::cout << a1DVector[itr] << ' ';
   }
   std::cout << "\n\n";

   // creating a sized vector filled with a value other than zero
   std::vector<int> another1DVec(8, 100);

   std::cout << "Displaying a filled 1D vector:\n";
   std::cout << another1DVec.size() << '\n';

   for (auto& itr : another1DVec)
   {
      std::cout << itr << ' ';
   }
   std::cout << "\n\n";

   std::cout << "Let's display that 1D vector again:\n";
   std::cout << another1DVec.size() << '\n';
   Print1DArray(another1DVec);
   std::cout << "\n\n";

   std::cout << "Let's display that 1D vector yet again:\n";
   std::cout << another1DVec.size()  << '\n' << another1DVec<< "\n\n";

   std::cout << "Creating a 2-dimensional vector, enter row size: ";
   int row_size;
   std::cin >> row_size;

   std::cout << "Enter column size: ";
   int col_size;
   std::cin >> col_size;

   std::cout << "\n";

   // create a 2 dimensional int vector with known dimensions
   std::vector<std::vector<int>> a2DVector(row_size, std::vector<int>(col_size));

   // initialize the vector with some values other than zero
   int start  = 101;
   int offset = 100;

   // step through each row and fill the row vector with some values
   for (auto& itr : a2DVector)
   {
      std::iota(itr.begin(), itr.end(), start);
      start += offset;
   }

   // let's display the filled 2D vector
   std::cout << "Displaying the filled 2D vector:\n";
   Print2DArray(a2DVector);
   std::cout << '\n';

   std::cout << "Let's display that 2D vector again:\n";
   std::cout << a2DVector;
}


template<typename T>
void Print1DArray(std::vector<T> const& a1DVec)
{
   for (size_t itr = 0; itr < a1DVec.size(); itr++)
   {
      std::cout << a1DVec[itr] << ' ';
   }
}


template<typename T>
void Print2DArray(std::vector<std::vector<T>> const& a2DVec)
{
   for (const auto& row_itr : a2DVec)
   {
      for (const auto& col_itr : row_itr)
      {
         std::cout << col_itr << ' ';
      }
      std::cout << '\n';
   }
}


template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v)
{
   for (auto const& x : v)
   {
      std::cout << x << ' ';
   }

   return os;
}


template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<std::vector<T>>& v)
{
   for (auto const& x : v)
   {
      std::cout << x << '\n';
   }

   return os;
}
Displaying a sized 1D vector:
5
0 0 0 0 0

Displaying a filled 1D vector:
8
100 100 100 100 100 100 100 100

Let's display that 1D vector again:
8
100 100 100 100 100 100 100 100

Let's display that 1D vector yet again:
8
100 100 100 100 100 100 100 100

Creating a 2-dimensional vector, enter row size: 3
Enter column size: 4

Displaying the filled 2D vector:
101 102 103 104
201 202 203 204
301 302 303 304

Let's display that 2D vector again:
101 102 103 104
201 202 203 204
301 302 303 304
Another of my Frankenstein's monster coding, this time dealing with a 3D container:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
#include <iostream>
#include <vector>

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& v)
{
   for (auto const& x : v)
   {
      std::cout << x << ' ';
   }

   return os;
}

template <typename T>
std::ostream& operator<<(std::ostream& os, const std::vector<std::vector<T>>& v)
{
   for (auto const& x : v)
   {
      std::cout << x << '\n';
   }

   return os;
}

int main()
{
   std::cout << "Creating a 3-dimensional vector, enter depth size: ";
   int depth;
   std::cin >> depth;

   std::cout << "Enter row size: ";
   int row;
   std::cin >> row;

   std::cout << "Enter column size: ";
   int col;
   std::cin >> col;

   std::cout << "\n";

   // create a 3 dimensional int vector with known dimensions
   using std::vector;
   vector<vector<vector<int>>> aVector(depth, vector<vector<int>>(row, vector<int>(col, 0)));

   // let's display the initial 3D vector
   std::cout << aVector << '\n';

   // initialize the vector with some values
   for (int depth_loop = 0; depth_loop < depth; depth_loop++)
   {
      for (int row_loop = 0; row_loop < row; row_loop++)
      {
         for (int col_loop = 0; col_loop < col; col_loop++)
         {
            aVector[depth_loop][row_loop][col_loop] = (((depth_loop + 1) * 100)
                                                       + ((row_loop + 1) * 10)
                                                       + col_loop + 1);
         }
      }
   }

   // let's display the filled 3D vector
   std::cout << aVector << '\n';
}
Creating a 3-dimensional vector, enter depth size: 3
Enter row size: 4
Enter column size: 5

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0

0 0 0 0 0
0 0 0 0 0
0 0 0 0 0
0 0 0 0 0


111 112 113 114 115
121 122 123 124 125
131 132 133 134 135
141 142 143 144 145

211 212 213 214 215
221 222 223 224 225
231 232 233 234 235
241 242 243 244 245

311 312 313 314 315
321 322 323 324 325
331 332 333 334 335
341 342 343 344 345

Whoa! Using the templated std::ostream operator>>() overloads that work for 2D vectors works for 3D vectors without any apparent change! Code Reusable!

It was fun mucking around with this writing my own code, as well as instructive. For me it was a great learning experience.

Something more experienced programmers would have already learned and understood without thinking about it.
I recall seeing Veldhuizen's description of expression templates: http://www.drdobbs.com/cpp/scientific-computing-c-versus-fortran/184410315
That was 1997. First C++ Standard was published 1998. The "experienced programmers" who wrote the standard might not have envisioned all the template metaprogramming that the language allows.

Woot! You can do that too! How about ...?
closed account (N8MNAqkS)
bro I don't just watch one guy, I watch different tutorials all day, from chilli tomato and others whos youtube names I cant remember. btw im 16 and don't have the money to buy 50 books on programing. And I didn't mean I was really gonna give up. its hard to convey across text but that was more comedic then serious. I was saying this is hard and confusing sometimes. and stop trying to compare how hard it was for you, and how hard it is for me and tell me I shouldn't complain about it being hard because you had a harder time. we all learn differently. and no one came to you directly about how hard c++ can be, you came here.

I am about done with forums like this because its just full of people who either want to show off how much better they are or tell you that you will be fine because they had a harder time then you.


and to the guy whos like, you have to write your own programs, watching other people do it will get you no where.


um excuse me, how do you think learning works. you watch other people do it and gather knowledge. when you want a toddler to learn how to count and read, you cant just expect them to figure it out on their own. you have to show them how, and explain it to them how it works. you cant just expect a toddler to figure out a numeric system works on his own. and you cant expect him to learn to read on their own. You make no sense bro.
Last edited on
um excuse me, how do you think learning works. you watch other people do it and gather knowledge.


You're here having this conversation because watching other people didn't work. The evidence of your own experience disagrees with your statement.

Have you not been trying that for four months? You could watch someone program for a lifetime and still have no understanding and no idea what you're doing, while someone with a day's worth of practice and understanding would program circles around you. If you don't like that, your choices are to slope off in a huff, or to put your ego back in a box and do better. Remember, we are anonymous strangers on the internet and we don't care what you do. The only person who you can damage or assist is yourself.


I am about done with forums like this because its just full of people who either want to show off how much better they are or tell you that you will be fine because they had a harder time then you.

You come here and you say you're having trouble learning. We tell you that in programming, you learn by doing. You then turn around and say that's wrong and you're not prepared to learn by doing. You know that what you're doing right now isn't working, but then when we tell you what to change, you refuse? You want to keep on not learning? That's your actual plan? Instead of changing things so that you learn, you're going to keep on doing the exact same thing, and get the exact same results?

You've been doing this for four months. So by now, you should be fully capable of creating a window on screen, making every pixel white, and moving a single red pixel from one side to the other. Can you do that?

If you can't do that, then get to it. Look up how to make the window. Make the window. Look up how to set pixel colour. Then do it. Look up how to set one red pixel. Then do it. This is how to learn. You'll learn more in a day than you will by watching someone else type into a screen for a month. Just do it.
Last edited on
how do you think learning works. you watch other people do it and gather knowledge.

You completely missed the next, not to skipped, step. DOING YOUR OWN CODE.

Without that no matter what you see won't do you a bit of good.

I learn because I write code. The two examples I posted are what I learned BY DOING.
Some learn by reading, some by seeing, some by doing.

If I watch how Usain Bolt runs, do I learn to run like him?
If I read how many times Usain Bolt has won a race, do I learn to run like him?
If I watch chess Grand Masters' play, do I learn to think like them?

Some activities require different method of learning than others.


16? There are things that you don't know yet. For example, you don't know what things you don't know. I was a bit older when I realized how little I knew.
I literally suck at everything.

Why are you hanging around arguing with people when they try to help you? If you really believe you suck at C++ then just go away.

I'll help someone who wants to learn. Someone who stays to continue arguing after saying they are quitting puts them on my ignore list.

Which will you be?

I know I don't have the talents or the drive to make programming a profession, I would be outclassed from the start.

I don't care. I enjoy playing around with the code, learning what I can.
Last edited on
closed account (N8MNAqkS)
Look IMO programing is just one of those thing you have to SEE to really understand. and I am not saying that I will not write my own code. I am saying that I cant write my own code if I don't understand what I am writing. like I said, you cant just expect me to know what I am doing. Like most things in life, you have to learn what you are trying to do before you do it. I have to watch how people use code, and I have to learn the code (e.g. for/while/if/switch) before I start doing it, I don't just know this crap guys. I have to learn a statement or function, and then learn what it does, and then I experiment with it. I cant just type random words and hope it does something. cuz more often then not its gonna end in and error, and im not gonna learn anything.

and obviously there are things I don't know yet, I know that much I am not that stupid. your probably 50 somethin and still don't know everything. I really don't understand what that last part was about. of course I don't know things that I dont know.
Last edited on
Your opinion is proven to be in error, by your own admission.

Whatever, I'm done trying to teach someone who only wants to argue, someone who stated they want to quit and doesn't.

You don't want to learn. You've made that crystal clear.
Last edited on
closed account (N8MNAqkS)
@repeater when did I say watching other people didn't work, I am still doing it. I meant in the business of programing, all I see is people reusing code that someone else made. I have heard programmers on youtube complain about how a lot of what new programmers do is copy what others have done and use it without really understanding the code. that was the whole point in this thread. I wasn't saying I wasn't learning, or that watching was not working for me. quite the opposite actually if you pay attention. I have been saying watching has helped me and that's what I do. and people came at me saying I will never be a good programmer if I learn the way that I do. I am just doing what works for me, and people dont seem to like that.
Last edited on
Pages: 12