Go Back   Zune Boards > Zune Discussions > Zune Games > Development Discussions > Development Help

Development Help For help from coding to error finding to that one thing you just can't get right

Reply
 
LinkBack Thread Tools
Old 08-29-2008, 11:44 PM   #1 (permalink)
Experienced Member
 
Tiptup300's Avatar
 
Join Date: Apr 2008
Posts: 808
Tiptup300 has disabled reputation
Default Getting started with programming

BEFORE YOU READ: This read is just to inform people of how to start off, you shouldn't only read this. Read this then read other tutorials, or just go read other tutorials, this will sorta cover a lot of stuff, most likely not very efficiently.

Okay, to start off, I'll start simple with some Q&A:

Q: What is a game?
A: A Program geared towards being game.

Q: What is a program?
A: A set of instructions a computer can understand.

To show a very basic program which will print out from 1 to 10, here would be one in "Pseudo Code", "Pseudo Code" is just a fake made up language usually just to show how something will work, kind of like a flowchart.

EG: (Pseudo Code)
Code:
01 Create new variable called "N"
02 Set "N" to "1"
03 While "N" is less than "10", Write "N" and add "1" to it
04 Clear "N"
05 Exit
Now, lets write this out in C# (the line numbers are just for reference)
Code:
01 int N;
02 N = 1;
03 while(N < 10)
04 {
05 Print(N);
06 N = N + 1; // Can also be written as "N += 1;" or "N++;"
07 }
08 N = 0;
Okay, lets piece this apart.

"int N" creates a variable called "N" which is the type of "int", there are two different types of...types. Primitive types and Object Types. More about object types later.

The main primitive data types you need to know are byte, int, float, char, bool, & string.

byte - whole number from 0-255 (Ex. 2, 0, 25, 255)
int - whole number (Ex. 25, -25, 20000, 9001)
float - number with decimals with high precision (Ex. 0, 1.005405045f, 2.54f)
char - pretty much a letter (Ex. 'a', 'q' )
bool - true/false (Ex. true, false, maybe)
string - It's actually an object type, but C# uses it as a primitive, it's a list of chars, so just text

Now, back to the code. A variable is a saved "thing" on the computer. It's saved in memory. So when you allocate "int N", you will have opened a spot up in memory to keep this variable there for later use. Luckily since we're using C# I won't have to talk about managing memory.

Well, we create variable "N", so it's there. The next line "N = 1;" sets that variable in memory to "1", 1 is an integer. So, as of right now, our little "N" is currently 1. We'll hit the next line which is "while(N < 10)", this line is a little more complex. Let's piece it apart.

"while" is a keyword for a loop. A loop is something that happens multiple times. In C# braces ("{" }") tell where a loop is active, if that make sense? Technically all a while requires is a bool in the parenthesis. "N < 10" is a bool value. So we could have a variable being a bool that is set to "N < 10".

So "while(true)" would go forever doing the loop. Meaning the lines
Code:
05 Print(N);
06 N = N + 1; // Can also be written as "N += 1;" or "N++;"
would repeat as long as while is getting true.

Well, lets go through the loop... First it hits the loop as 1, it goes in since N is indeed less than 10. So it goes into the loop, it prints "N". The next line increases N to 2. This will keep going until lets say N is finally added up to 10. Well, if you do notice we have a problem. N is 10, the last thing printed was "9", so it would hit the while(N < 10), and N would be 10. So it would kick out and exit. We would only have 123456789, this is bad. So, lets change "N < 10" to "N <= 10" which means "N is less than or equal to 10."
That fixed our problem.

Well, that's lesson 1. I guess I will add more stuff. Next I may go into objects and classes. I dunno, I'm tired and it's 3AM. I hope the other programmers find mistakes so I can correct em.



Tiptup300 is offline   Reply With Quote

Advertisement [Remove Advertisement]
Old 08-30-2008, 12:00 AM   #2 (permalink)
Purger of Ignorance
zB Programmer
Retired Staff
Expert Zuner
 
Netrix's Avatar
 
Join Date: Jun 2008
Location: In my own world
Posts: 2,804
Netrix is a name known to allNetrix is a name known to allNetrix is a name known to allNetrix is a name known to allNetrix is a name known to all
Send a message via MSN to Netrix
Default

Stickied. Great idea.
__________________
"Against logic there is no armor like ignorance." - Laurence J. Peter

Solitaire for your Zune! http://www.zuneboards.com/forums/dow...ne-v2-0-a.html

Zune Book Reader! http://www.zuneboards.com/forums/app...ew-thread.html




Netrix is offline   Reply With Quote
Old 08-30-2008, 05:43 AM   #3 (permalink)
Experienced Zuner
 
kanyefalloutboy's Avatar
 
Join Date: Jul 2008
Location: Tulsa
Posts: 218
kanyefalloutboy is on a distinguished road
Send a message via Yahoo to kanyefalloutboy
Default

Good sticky.





kanyefalloutboy is offline   Reply With Quote
Old 08-30-2008, 06:24 AM   #4 (permalink)
Jr. Member
 
Anachostic's Avatar
 
Join Date: Jun 2007
Posts: 407
Anachostic will become famous soon enough
Default

+rep

Looking forward to seeing the progress.




Anachostic is offline   Reply With Quote
Old 08-30-2008, 06:30 AM   #5 (permalink)
Experienced Zuner
 
narutor22's Avatar
 
Join Date: Jun 2008
Location: The Magical Land of Zewbie Slayers
Posts: 186
narutor22 is on a distinguished road
Send a message via Yahoo to narutor22
Default

Genius!




narutor22 is offline   Reply With Quote
Old 08-30-2008, 08:53 AM   #6 (permalink)
Experienced Member
 
ShotgunSnipist's Avatar
 
Join Date: May 2008
Location: Colorado
Posts: 803
ShotgunSnipist has a spectacular aura aboutShotgunSnipist has a spectacular aura about
Send a message via AIM to ShotgunSnipist
Default

Yeah! This was a great idea!
Keep those Zewbies from asking questions.


+Rep
__________________
Invisible Text. =P



ShotgunSnipist is offline   Reply With Quote
Old 08-30-2008, 09:20 AM   #7 (permalink)
catnat109
Guest
 
Posts: n/a
Default

Great Idea



  Reply With Quote
Old 08-30-2008, 09:45 PM   #8 (permalink)
Experienced Zuner
 
blackwood550's Avatar
 
Join Date: Mar 2008
Location: North Las Vegas
Posts: 206
blackwood550 is on a distinguished road
Default

hell yes...the more i read the better




blackwood550 is offline   Reply With Quote
Old 08-31-2008, 01:49 PM   #9 (permalink)
Experienced Zuner
 
Join Date: Aug 2008
Posts: 236
GameStudio is an unknown quantity at this point
Default

Good job. You should make a bunch of tutorials like this and put them on a website, and have the link in your signature.
__________________
GameStudio




GameStudio is offline   Reply With Quote
Old 08-31-2008, 07:30 PM   #10 (permalink)
Experienced Member
 
Tiptup300's Avatar
 
Join Date: Apr 2008
Posts: 808
Tiptup300 has disabled reputation
Default

ZuneApps, did you learn anything from Lesson 1?



Tiptup300 is offline   Reply With Quote
Old 10-30-2008, 10:02 AM   #11 (permalink)
Zuner
 
BaboonOfTheYard's Avatar
 
Join Date: Oct 2008
Posts: 94
BaboonOfTheYard is on a distinguished road
Default

Nice, I was especially glad to learn that you could use '+=' to increment with a specified number. I was trying to do things like

Code:
N = N + 10
which is how you do it in DarkBasic. Thanks, can't wait for more .
__________________





BaboonOfTheYard is offline   Reply With Quote
Old 10-30-2008, 11:21 AM   #12 (permalink)
Zewbie
 
darkdonut's Avatar
 
Join Date: Oct 2008
Location: Mountain Home, ID
Posts: 6
darkdonut is on a distinguished road
Default

Good job on the starters guide. Will look forward to reading this guide as it progresses. Reminds me of my C++ class when I was in high school.




darkdonut is offline   Reply With Quote
Reply

Bookmarks

Thread Tools