Adventures in Game Development -- Day 6



Another day, another C++ lesson.

Today was a bit of a miss for learning C++. I'm still very motivated to learn, but other, more important things got in the way. Despite that, I did learn two new things.

The first was functions. In my previous programming experience with RobotC, we called these sub-routines. Basically, functions allow you to constuct some code and call on it easily throughout your program with a simple declaration statement. This makes pieces of code that need to be repeated throughout a program much easier to write and manage.

The second thing I learned, which is tied to functions, is recursion. Recursion isn't very easy to explain, so I won't bother trying. The concept is fairly easy to pick up, but it's one of those things that I'm not really confident in my knowledge of it. Tomorrow I'm going to go over recursion once again and make sure it sticks in my head.

The amount of stuff that I'm eager to learn is a bit overwhelming, but I just have to keep reminding myself: "slow and steady wins the race".

10 comments:

Jack Burton said...

Wow, this stuff is way over my head. Almost intimidates me about taking programming in a few weeks. I swapped that class out for a Logic and reasoning class.. I figure since you're updating pretty regularly I can keep reading this (as well as my handy "for dummies" book and next semester when I take the class you'll be confident enough to help me out when I bombard you with questions haha, Right?

Pool Fool said...

nice I always thought to learn c++

baka1236 said...

goodluck m8. i'm glad to see you're so motivated. I wanna learn a programming language soon too

Whitelight said...

Sweet post! :)

Miyamoto Karyuu said...

im afraid of learning it, xD good thing i wont learn it in my course

pietah said...

recursion: method that calls itself. Done :D

Xenototh said...

So basically functions reduce the inevitable redundancy that is involved in programming? Sounds like a sanity saver.

Th1s_1s_R4z0r said...

I'm useless at C++ -.-

Anonymous said...

lol programming its so hard i dont have time for this. others do that for us haha

happyhacker said...

The important thing to understand with recursion is that function calls are "pushed" to the stack.

I recommend learning what a Computer Science "stack" is right about now, it can most easily be imagined as a stack of books, when you want to get to the middle book you must first take off or "pop" each book on top of it.

Recursion is a function calling it's self multiple times, and each function call pushes the function to the stack, and in this way the last function call must return before each previous call to the function can return.

If your function recurses infinitely you will get a stack overflow error and your program crashes.

When writing recursive functions the base case is important.

http://en.wikipedia.org/wiki/Recursion_(computer_science)#Recursive_algorithms

Why not give writing a recursive for loop a go?

Post a Comment