Endless Paradigm

Full Version: Zinga's quick C tutorial
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4
Awesome zinga!  

I am so upset with myself for not attending any classes in college. :(   Instead i paid people in beer to do my projects and i just skirted by with guesses on the tests :(  

(come to me for suggestions on how to earn a 0.8 GPA in college)

I never would have thought I would want to program anything in my life..now it is something i want to do alot, but have managed to get hibbyware to make the one program i realy needed created (hwhex.exe for prx updating from 3.90 to 3.95 and 4.01) :)  

Hopefully your tutorials continue, I promise to pay attention to your classes!
PSPkiller Wrote:
Mc Cabe Wrote:woot i understood that :P

I've  had a go at  the C++ video tut's on 3D Buzz. they sort of  made sense and were slightly funny and entertaining, but  by the 3rd video i was completely lost...

SchmilK Wrote:Awesome zinga!  

I am so upset with myself for not attending any classes in college. :(   Instead i paid people in beer to do my projects and i just skirted by with guesses on the tests :(  

(come to me for suggestions on how to earn a 0.8 GPA in college)
Lol at above two posts :P



Thanks for the comments everyone. :)  Just wondering, has anyone managed to actually get the program running?
Alright, since I didn't really get many confirmations of success, I'll continue on, but I'll formalise some concepts without going much into code at the moment.



Don't worry too much if you don't really understand most of this - it's not terribly important, so as long as you get the general gist of what I'm trying to say, you should be fine.

Computer Programs
All a computer CPU does (for the most part) is execute instructions.  Thus, all you give it, when you write a program, is a series of instructions, ie, do this, followed by that, then that... (and so on).
However, there exists control flow statements which allow your program to jump to various places - this stops programs from being just a static set of instructions.

Here's an example of what I mean (this isn't real code, duh):

Code:
Stand up.
Walk towards ball.
Bend over.
Pick up ball.

(^ Above are "static" instructions - now we'll stick in a "control flow" statement)

If the ball is red,
   throw it at the nearest person.
Otherwise,
   drop it on the floor.

(note the use of full-stops in the above - these typically translate to the semicolons that typically end C statements (see first post) - also recall that the if statement doesn't have a semicolon after it (you don't stick a full stop after an if))

Note the "if" statement above - if the condition (ball is red) is true, the person will (or should) "execute" the next statement, "throw it at the nearest person", and then skip the statement defined in the "otherwise" clause.

Control flow is a very important concept in programming, as you typically write a program to adapt to different conditions.
(if you've ever tried making some games with Game Maker, or even something like Starcraft's Campaign Editor, you've probably come across conditionals; this is basically the same thing, though a little more formal)

The if statement is probably by far, the most widely used control flow statement.  Wee'll look at the while statement (this basically allows a set of instructions to keep being executed whilst the condition is true, aka a loop) later on, along with functions.


Variables
Probably the other fundamental component of programs, along with control flow, is variables.  I'm sure you've all experienced variables before, either in maths, or if you've tried making a game before - you'll typically want your program to, a) record information, and b) adjust to different inputs.

A programming variable isn't much different - all it really is, is just a bit of memory where you can store some info.  The variable can be changed and read from.


Wee'll focus on integer type variables mainly - it's the most widely used type anyway.  Integer variables can only be used to store integer number values.

Necro-Bot

[Image: gd9au.jpg]
Nice tutorials Zinga, they're pretty easy for beginners, I am sure a lot of people will read them and find them useful. I'd stick this thread if I were you
/pastes boogers on it

lol

Hi Nervo
^ Lol.


Thanks for the compliments :P
/stickies...

wait...

/can't

Necro-Bot

[Image: Necropost.jpg]
Necro! :D
Pages: 1 2 3 4
Reference URL's