Post Reply 
Zinga's quick C tutorial
Author Message
ZiNgA BuRgA
Smart Alternative

Posts: 17,023.4213
Threads: 1,174
Joined: 19th Jan 2007
Reputation: -1.71391
E-Pigs: 446.0333
Offline
Post: #13
RE: Zinga's quick C tutorial
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:
1
2
3
4
5
6
7
8
9
10
11
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.

01/10/2008 06:25 PM
Visit this user's website Find all posts by this user Quote this message in a reply
Post Reply 


Messages In This Thread
Zinga's quick C tutorial - ZiNgA BuRgA - 30/09/2008, 05:57 AM
RE: Zinga's quick C tutorial - Slushba132 - 30/09/2008, 06:06 AM
RE: Zinga's quick C tutorial - Mc Cabe - 30/09/2008, 07:25 AM
RE: Zinga's quick C tutorial - LaneLander - 30/09/2008, 07:53 AM
RE: Zinga's quick C tutorial - roberth - 30/09/2008, 08:41 AM
RE: Zinga's quick C tutorial - LaneLander - 30/09/2008, 08:49 AM
RE: Zinga's quick C tutorial - boogschd - 30/09/2008, 08:56 AM
RE: Zinga's quick C tutorial - PSPkiller - 30/09/2008, 12:57 PM
RE: Zinga's quick C tutorial - SchmilK - 30/09/2008, 03:37 PM
RE: Zinga's quick C tutorial - ZiNgA BuRgA - 01/10/2008, 01:19 AM
RE: Zinga's quick C tutorial - ZiNgA BuRgA - 01/10/2008 06:25 PM
RE: Zinga's quick C tutorial - boogschd - 14/02/2009, 01:26 PM
RE: Zinga's quick C tutorial - ZiNgA BuRgA - 14/02/2009, 08:55 PM
RE: Zinga's quick C tutorial - feinicks - 16/02/2009, 05:58 AM
RE: Zinga's quick C tutorial - Joom - 17/10/2009, 01:35 PM
RE: Zinga's quick C tutorial - Mickey - 17/10/2009, 03:47 PM
RE: Zinga's quick C tutorial - Mickey - 23/06/2011, 07:16 PM
RE: Zinga's quick C tutorial - mime - 23/06/2011, 08:24 PM
RE: Zinga's quick C tutorial - Cirehpsa - 23/06/2011, 10:54 PM
RE: Zinga's quick C tutorial - Cirehpsa - 24/06/2011, 07:24 AM
RE: Zinga's quick C tutorial - whjms - 24/06/2011, 07:47 AM
RE: Zinga's quick C tutorial - Cirehpsa - 24/06/2011, 07:59 AM
RE: Zinga's quick C tutorial - whjms - 24/06/2011, 08:08 AM
RE: Zinga's quick C tutorial - Cirehpsa - 24/06/2011, 08:41 AM
RE: Zinga's quick C tutorial - Grey Ghost - 24/06/2011, 12:05 AM
RE: Zinga's quick C tutorial - ZiNgA BuRgA - 27/06/2011, 01:23 AM
Thread Revived!!! - Necro-Bot - 14/02/2009, 01:17 PM
Thread Revived!!! - Necro-Bot - 17/10/2009, 01:35 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)

 Quick Theme: