Anda di halaman 1dari 5

Hello and welcome to Lesson 2 of Learn to Program with C#: From

a Gaming Perspective
So by now you've got your software and a desire to program. Good. Believe it or not taking the
first step is one
of the harder ones. But aside from wanting to know how to program you might have a few other
!uestions so
"'ll try to get those out of the way now.
Which programming language is the best? Why C#? etc...
"n the end there is no #best programming language#. $ight now the industry standard for games
is %&&. However
there is no guarantee what language will be the one of choice in a year or five years. ' popular
game
%ivili(ation ) was written in *ython which is fairly new. +he idea is to learn a language. 'ny
language will do
because once you learn one picking up another is fairly easy to do. "'m using %, because it's
fairly easy to learn
it's very close to %&& and because it's the language that -.' uses which makes game
programming much easier.
/ore on -.' later.
+he difference between languages is fairly close. 0hile they are usually built from the ground
up independantly they are all kept similar solely for the reason that programmers would be more
familiar and of
course certain concepts are kept because they work through trial and error. 1ust like most
2western3 spoken
languages came from latin programming languages also have a similar origin.
Honestly calling them different languages is almost the wrong term. +hey would more easily be
called dialects.
/ost of it's similar but some ad4ustments need to be make for things to work. +hink 56 7nglish
to 'merican
7nglish. 8r %entral 'merican Spanish to Spain Spanish and you'll begin to see what " mean.
"n %, everything is an ob4ect which means learning in %, uses 8b4ect 8rriented *rogramming
2which we'll refer
to now as 88*3 more fre!uently which can lead to better programming habits. 'n ob4ect is 4ust
something thats
created than can be manipulated in some way. 'n ob4ect can be a bo9 a ship a number...... and
it can be
changed moved or have anything done with it that you want. %, is also a #managed language".
Basically this
means that a lot of overhead such as memory allocation and other crap that you don't want to
deal with
right now is take care of.
X!? What is it? Why "o # want to use it?
-.' stands for.......um -.'. "t's a programming environment by /icrosoft that makes
programming for windows and the -bo9 :;< much easier. =es " said the -bo9 :;<. =ou need a
%reators %lub subscription to program and run games on the :;< but it's 4ust like programming
for 0indows. Learn all about it at> %reators.-.'.com. " fre!uent this site and the forums and it's
a great place to learn all about game programming and -.'. 1ust please read the forums before
you ask !uestions because it's probably been
asked at some point. 8ne thing to note is that it allows you to play the games on the :;< but you
cannot create -bo9 live games with it yet and you have to have a contract to publish commercial
games for the :;< and the -bo9 live arcade.
7ven if you don't have a :;< or don't want to program for it -.' does something wonderful. "t
allows you to easily add content to you game and manipulate it. "t also has a strong built in
gaming loop ready for you to create games. "t is not an engine but it's pretty cool once you
figure it out. "t cuts out the initial programming headache to get a graphical game going.
What is a game?
Seems like a dumb !uestion but it's not. ' game is a loop 2will be e9plained more later3 that runs
until a condition is met. 0ether it's the player dying or mario beating bowser.... ' true game isn't
finished until it has sound a title screen and credits as well as a gaming loop. 0e won't be done
with our *ong game later on until that's finished.
What about technical issues? Processors$ memory$ "ual cores$
%& vs '( bit?
0ell as stated before between %, and direct- most of these issues are already handled for you.
's far as :2 bit vs ;) bit the answer is that it's been decided for us by -.'> :2 bit. ;) bit
programming has to do with using ;) bit variables which usually only are beneficial for very large
numbers and using more than ) gig of memory. =ou can do some research on these things and
probably should know more about them. However if you need more than ) gig to run your game
you're well beyond the scope of this tutorial and -.'.
's for mulitple core processors they are taken advantage of by multithreading. Basically this is
where you seperate your game into multiple chunks that both processors can work on at the
same time. "f you 4ust have a single program only one processor can work on it at a time.
However again this is well beyond our scope however not outside of the scope of -.'. 0hen
you're ready 2much much later3 you can do some research on this.
+he gaming industry has only recently started to work on these things themselves so don't think
at any point
that you should know them in the near future. ?o some research to understand them a little
better
but don't worry about them.
# want to ma)e a **+,PG or the ne-t great FP.. /ow "o # "o
that?
"f you ask this !uestion the scoffs and laughing is coming from everyone else. *robably cause
they thought the same thing at some point too. /ainstream games are made with multiple people
and @ figure plus budgets taking months to years to build. .ow -.' does make things a lot
easier to do but you need to learn to program go through the #evolution# of games starting from
where we'll leave off to 2? games like the old 'tari ones then to side scroller games then to
simple :d games and then from there who knows. =ou don't have to make clones of old games.
/ost people do that because they are 4ust trying to figure out how to do certain things but a great
game does not re!uire :d graphics huge e9plosions and a si(e to fill up 2 ?A?'s. Some of the
most profitable games are in the #casual# market. Some of the greatest games are not all that
comple9 they 4ust have a great idea.
"f after you've worked your way up seen what it takes to make other games you still want to
tackle a B*S or a //8$*G and prove us all wrong have at it but make sure you can finish what
you start and don't bite off more than you can chew.
/ow har" is programming? What s)ill sets are nee"e"?
Let's try all of them. 8kay not really but there is a lot to know depending on your program. "f
you're making accounting software you better know accounting. "f you're making a game you
better know games. "f you're making a game about trains you better know something about
trains. +he point is to know what about what you're programming and program what you know at
least to some e9tent. ?o some research. 'ny programming should really start long before you sit
down in front of the computer. Give yourself time to think and imagine. ?evelop the game into
it's own entity that needs to get out in some way. +hen you can take a
digital dump onto the computer and into other people's homes.
's " said before a good game re!uires graphics music and sound and of course programming.
=ou probably don't posses all those skill sets on your own which is why sometimes you need to
find people to work with you at some point. " wouldn't worry about it right now but something to
think about in the future. =ou don't have to do everything on your own.
's for how hard it is it takes some math some patience some common sense and creativity. "t
can be a lot of fun and !uite rewarding as well. 1ust remember that there is no right way to
program. " will probably say this a lot. "n the end if you get what you want you did it right. +here
may be more efficient ways to do certain things but there'll never be a #right# way.
=ou will make mistakesC 'nd " hope you make a lot of them. +his may sound cruel especially
from the guy helping you but you will learn more from your mistakes than from anything else. ?o
not loose hope because the answer is there you'll come out of it wiser and you probably will
never make that mistake again. ?on't doubt yourself because it's probably a simple mistake.
$ule out the easy ones first.
/ow "oes a computer wor)?
+his is a very brief synopsis of how a computer works. +his is important to know even though
this is being handled for you. 0hyD /ainly because you need to think about where the
bottleneck of your program lies. Bottleneck refers to the choke point of your program. "magine
your computer is a coke bottle. +he neck is the smallest point of bottle and therefore the most
limiting factor to your output. +he bottleneck could be the processor the memory the graphics
card....'nything.
So let's imagine that our computer is a store for a moment. "t could be a Best Buy 0al/art
+arget or a grocery store.
+ur Players 0computer parts1
/ar""riveE +he harddrive is the shelves the data on the H? is the items on the shelf.
*emory0,!*12 /emory is like a shopping assistant with a shopping cart for our program. 8ur
program is an invalid that can only give orders. +he si(e of the memory determines how big the
#shopping cart# is while the speed of the memory determines how fast our #shopping assistant#
goes.
CP32 +he %*5 is the checkout isle. +he faster the processor the more data it can process in a
second. +he bigger the memory cache the bigger the conveyor belt is. "t's important to note the
difference between '/? and "ntel advertised speeds. +o read past the BS go to a site like
/otherboards.org. that compares the two using scientific methods. +his gives a better idea of
how they perform.
*otherboar" E +he mobo is like our floor and layout of the store itself. ' good mobo can
improve flow and a bad one can muck things up. /obo's usually determine the true lifespan of a
computer between how it handles power and how upgradeable it is. 0hile it does have an effect
on performance lifespan is the biggest concern in mobo's.
+utputE 8utput is like the end product. 5sually this means the monitor but can include rumble
packs and the like. +his would be like the car or truck that gets the end products loaded into it.
Graphics Car"E ' graphics card has two parts> it's core and it's memory. +he graphics card
works like a sacker in our store and also brings it out to the car 2the monitor3 that's parked in the
load (one.
P.3 E +his is our power for the store and all of the other players. 's long as our players are
getting the power they need they will run like they should regardless of the *S5's watts
2assuming it's sufficient3. .ow a low !uality *S5 could feed #4unk food# to your parts making
their life span shorter but they generally will perform the same in the end.
8verclocking is #force feeding# your players to make them perform faster. Gluttany can shorten a
persons life span and the same could be said for computer parts as well. "t's important to
remember the difference between a high watt *S5 and a high clock speed.
#nputE +his is our mouse keyboard %?'s etc. +his data gets routed through the %*5 2cashier3
and tells our memory 2shopping assistant3 where to put it. 2ie in our programs shopping cart to
the Hard ?rive 2shelves3 etc
ProgramE Binally our program is the last one to cover. 's " said this is like an invalid customer
who cannot touch a thing only give orders. +he program can be our game our 8S the virus
scan or all of the above and more. +here can any number of customers in our store.
.ow that our parts are assigned let's look at how they interact. Birst on boot up our first
customer of the day is our 8S. +he 8S is also like a manager who helps decide where things are
going. 'fter our manager has his cup of coffee he opens up the doors for the morning regulars
the start up programs. +hey all pile in at once giving orders to our cashier at the same time. 8ur
%*5 cashier can handle millions of lines of code a second so if they are not too many regulars
things get underway pretty !uickly. +he more start up programs we have the longer our day takes
to get underway. "t is important to note that there is no #line# in our store and everyone is
checking out at the same time.
.ow that our regulars are served their needs are not as great since their shopping baskets are
pretty well set 2+hey are all chilling at the starbucks3. 0e as owners can of course kick out any
regulars that are being too much of a hog 2ie virus scan3. +he computer checks in on our
regulars to make sure things are going alright. .ow we are at our base operating level with our
base memory and cpu power available. 8nce we load up our program we want to run we're
adding a huge load onto our employees depending on our program. Games are a resource hog
after all. 8ur manager 8S tells what goes where our cashier checks out millions of lines a code
for our game every second while still checking in on our regulars to make sure they don't want
anything. 8ur shopping assistant and it's very large shopping cart is serving our programs needs.
'll the while the cashier is also throwing out output to our sackerFloader the graphics card which
is setting everything up to our programs needs while the cashier is also taking in input and telling
our shopping assistant where to put it or who's cart it goes to. +his all happens millions of times
a second.
Where4s the bottlenec)?
+he bottle neck is dependant on the computer and the program. 0here's the strain in relation to
the needsD 8ur first few programs put hardly any strain on the sackerFloader graphics card and
!uite a bit more strain on the %*5 and memory. ' B*S with millions of particles of dust and
e9plosions put !uite a bit of strain on the graphics card. 't first there probably won't be a bottle
neck on your computer if it's only a few years old. But you need to think about what's being used
the most and the limitations on not only your computer but also on your target audience's
computer.
What4s this mean to me really?
's " said the computer handles all of this stuff for us. +his is more to keep in the back of your
mind when you're making programming decisions. Bor instance loading all of your items right
away vs when you need them. 'lso keeping this in mind you can think of what upgrades you
might do on your own computer or when choosing parts for building a new one. "n regards to
dual processors as a programmer dual cores do make more sense to use. ' dual core adds
another #cashier# to the store 2a !uad core adds ) to your store etc3. +his means one can run the
8S the other programs and the compiler while the other one works on your game. 0hile we're
on the sub4ect multiEthreading refered to earlier is like a husband and wife team that splits up their
shopping list to get things done more efficiently. +his is only true with multiple cores.
G3#$#56$ 6ngines7 What4s this stu88
! G3# stands for Graphical 5ser "nterface. "n programming this means you can see what you're
working with and visually make changes to the program and the code will be updated. -.' is
does not currently have a G5". Aisual %, has a G5" for 0indows apps but again right now -.'
does not include this.
!n #56 stands for "ntegrated ?eveloper 7nvironment. Aisual %, and -.' include this. +his
means you can program run and debug all in one program
!n 6ngine is typically the base gaming loop like -.' but also usually includes a prewritten G5"
and physics component. +he plus side is that a lot of your base work has been eliminated
shortening development time and allows a person focus more on content. +he down side is that
since it is meant to be more universal it is not optimi(ed for your code. /any engines are not
free or carry the price of non commercial use. "t's up to you to decide what's the best for you.
7ither way learn %, first then decide which way to go.
General tips 8or programming
+his list is a combination of my e9perience as well as input from other game designers.
9: Plan out your gameE /ake a list of things to do things you want in your game and things you
need in your game
&: Get it up an" runningE Birst and foremost is to get your game playable in some form. Being
able to see what you have and testing out changes is crucial for development
%: Focus on what nee"s to be thereE ?o the important stuff first. 5se placeholder graphics if
need be. Get your game right before the animations.
(: 5on4t get "istracte"E "f you're working on one problem don't get sidetracked with some other
idea that pops in your head. 0rite it down so you don't forget but focus on what your current
problem is.
5o4s an" 5on4ts
' few !uick do's and don'ts before we dive into programming
5o E read code and look at other people's pro4ects for inspiration and to learn
5on4t E rip off someone's code. "f they're open about allowing others to use it give them credit.
?on't steal a generous license and repackage it to make a !uick buck.
5o E ask for help when it's needed. 'lso do ask !uestions that are well thought out.
5on4tE ask for help until you've looked it over and done some of your own research. 'lso don't
e9pect people to finish your code for you
5o E the lessons and take a stab at applying new code and ideas in your own programs.
5on4t E copy and paste code. "t's tempting " know but you'll retain more by typing it out which is
the whole point.
5o E find people to work with you on your games and find people that work together well.
5on4t E e9pect people to rally around you because you have this really great idea for a game.
+here's a lot of great ideas around. "t's a give and take with people. 0ork with them and they'll
work with you.
5o E *lay games. *lay lots of games. *lay indie games play mainstream games. *lay new
games play old games. 's you're learning programming you'll get some ideas and you'll start to
understand what they did and why they did it.
.ow on to programming and learning %,

Anda mungkin juga menyukai