Radiosourcegear

sourcegear  时间:2021-02-19  阅读:()
Beginning.
NETGameProgramminginenDAVIDWELLER,ALEXANDRESANTOSLOBAo,ANDELLENHATTONAPressMedia,LLCBeginning.
NETGameProgramminginC#Copyright@2004byDavidWeller,AlexandreSantosLobao,andEllenHattonOriginallypublishedbyAPressin2004Allrightsreserved.
Nopartofthisworkmaybereproducedortransmittedinanyformorbyanymeans,electronicormechanical,includingphotocopying,recording,orbyanyinformationstorageorretrievalsystem,withoutthepriorwrittenpermissionofthecopyrightownerandthepublisher.
ISBN978-1-59059-319-6ISBN978-1-4302-0721-4(eBook)Trademarkednamesmayappearinthisbook.
Ratherthanuseatrademarksymbolwitheveryoccurrenceofatrademarkedname,weusethenamesonlyinaneditorialfashionandtothebenefitofthetrademarkowner,withnointentionofinfringementofthetrademark.
TechnicalReviewers:AndrewJenks,KentSharkey,TomMillerEditorialBoard:SteveAnglin,DanAppleman,GaryCornell,JamesCox,TonyDavis,JohnFranklin,ChrisMills,SteveRycroft,DominicShakeshaft,JulianSkinner,JimSumser,KarenWatterson,GavinWray,JohnZukowskiAssistantPublisher:GraceWongProjectManager:SofiaMarchantCopyEditor:AmiKnoxProductionManager:KariBrooksProductionEditor:JanetVailProofreader:PatrickVincentCompositor:ContentWorksIndexer:RebeccaPlunkettArtist:KineticPublishingServices,LLCCoverDesigner:KurtKramesManufacturingManager:TomDebolskiTheinformationinthisbookisdistributedonan"asis"basis,withoutwarranty.
Althougheveryprecautionhasbeentakeninthepreparationofthiswork,neithertheauthor(s)norApressshallhaveanyliabilitytoanypersonorentitywithrespecttoanylossordamagecausedorallegedtobecauseddirectlyorindirectlybytheinformationcontainedinthiswork.
DOI10.
1007/978-1-4302-0721-4ParaAna:Miesperanza,micorazon,mitesoro,miamiga,miamor.
-DavidWellerContentsataGlanceForewordxiAbouttheAuthorsxiiiAbouttheTechnicalReviewersxvCreditsxviAcknowledgmentsxviiPrefacexixIntroductionxxiChapter1Chapter2Chapter3Chapter4Chapter5Chapter6Chapter7EpilogueBonusChapterAppendixAAppendixBAppendixCAppendix0Nettrix:GDI+andCollisionDetection1.
Netterpillars:ArtificialIntelligenceandSprites65ManagedDirectXFirstSteps:Direct3DBasicsandDirectXvs.
GDI+139SpaceDonuts:SpritesRevisited207Spacewar!
243Spacewar3D:MeshesandBuffersandTextures,OhMy!
269AddingVisualEffectstoSpacewar3D325TakingYourNextSteps341PortingNettrixtoPocketPC349SuggestedReading369MotivationsinGames373HowDoIMakeGames379GuidelinesforDevelopingSuccessfulGames.
.
389Index397vContentsForewordxiAbouttheAuthorsxiiiAbouttheTechnicalReviewersxvCreditsxviAcknowledgmentsxviiPrefacexixIntroductionxxiChapter1.
Nettrix:GDI+andCollisionDetection.
.
.
.
1BasicGDI+Concepts2PerformingGraphicOperationswithaGraphicsObject4CreatingGradients7CollisionDetection8OptimizingtheNumberofCalculations17ExtendingtheAlgorithmstoAddaThirdDimension21TheGameProposal23TheGameProject24TheCodingPhase30FinalVersion:CodingtheGameFieldClassandtheGameEngine51AddingtheFinalTouches59Summary63Acknowledgments64BookReference64Chapter2.
Netterpillars:ArtificialIntelligenceandSprites.
65Object-OrientedProgramming66ArtificialIntelligence69SpritesandPerformanceBoostingTricks76TheGameProposal85TheGameProject86viiContentsTheCodingPhase99AddingtheFinalTouches134Summary138Acknowledgments138Chapter3ManagedDirectXFirstSteps:Direct3DBasicsandDirectXvs.
GDI+.
.
.
.
139DirectXOverview1403-DCoordinateSystemsandProjections151DrawingPrimitivesandTexture158TheApplicationProposal166TheApplicationProject166TheCodingPhase168AddingtheFinalTouches202MoreAboutDirectXandGDI+203Summary204Acknowledgments205Chapter4SpaceDonuts:SpritesRevisited207Sprites208SpaceDonuts223Summary242Acknowledgments242Chapter5Spacewar!
243AboutSpacewar244Methodology:ChallengesofWorkingwithSomeoneElse'sCode246UsingtheApplicationWizard247DirectPlay259Summary267Acknowledgments268Chapter6Spacewar3D:MeshesandBuffersandTextures,OhMy!
269DirectXBasics:TheApplicationWizardRevisited270Spacewar3D282viiiContentsTheGameProposal282TheGameProject283Summary323Acknowledgments323Chapter7AddingVisualEffectstoSpacewar3D.
.
.
.
.
.
325PointSprites325Step10:AddingThrustEffectstoSpacewar3D327Step11:AddingExplosionEffectstoSpacewar3D335Step12:AddingaShockwaveEffecttoSpacewar3D336Summary338EpilogueTakingYourNextSteps.
341MovingOn341HabitstoBuild342ThingsWeNeglectedtoTellyou346HappyTrails348BonusChapterPorting.
NettrixtoPocketPC349ProgrammingforMobileDevices350RunningDesktopPCProgramsandOperatingSystemsonMobileDevices354TheGameProposal355TheGameProject355TheCodingPhase356AddingtheFinalTouches366Summary367AppendixASuggestedReading369GameProgramming369MathandPhysics370ComputerGraphics370WebSitesandOnlineArticles370OnlineArticlesandBlogs371AppendixBMotivationsinGames.
373ixContentsAppendixCHowDoIMakeGames379AppendixDGuidelinesforDevelopingSuccessfulGames389Index397xForewordBACKAFEWYEARSAGOIHADANIDEA.
WhatifIcouldmakethepoweroftheDirectXAPIavailabletothedeveloperswhoweregoingtobeusingthenewsetoflan-guagesandcommonlanguageruntimethatMicrosoftwasdevelopingTheideawasintriguing,andopeningupalargerportionoftheworldtoDirectXwasagoalIwasonlytoohappytoendorse.
Besides,whatdeveloperdoesn'twanttowritegamesItseemsthatatleastonceaweekIamansweringquestionsdirectlyregard-ingtheperformanceofmanagedcode,andManagedDirectXinparticular.
OneofthemorecommonquestionsIhearissomeparaphraseof"Isitasfastasunmanagedcode"Obviouslyinageneralsenseitisn't.
RegardlessofthequalityoftheManagedDirectXAPI,thefactremainsthatitstillhastorunthroughthesameDirectXAPIthattheunmanagedcodedoes.
Thereisnaturallygoingtobeaslightoverheadforthis,butdoesithavealargenegativeimpactonthemajorityofapplicationsOfcourseitdoesn't.
Nooneissuggestingthatoneofthetop-of-the-linepolygonpushinggamescomingouttoday(say,HalfLife2orDoom3)shouldbewritteninManagedDirectX,butthatdoesn'tmeanthatthereisn'tawholeslewofgamesthatcouldbe.
I'llgetmoretothatinjustafewmoments.
Therealityisthatmanyofthedevelopersouttheretodaysimplydon'tknowhowtowritewell-performingmanagedcode.
Thisisn'tthroughanyshortcomingofthesedevelopers,butratherthenewnessoftheAPI,combinedwithnotenoughdocumentationonperformance.
andhowtogetthebestoutoftheCLR.
Forthemostpart,we'reallnewdevelopersinthisarea,andthingswillonlygetbetteraspeoplecometounderstandtheprocess.
It'snotatalldissimilartothechangefromassemblertoCcodeforgames.
Itallcomesdowntoasimplequestion:DothebenefitsoutweighthenegativesAreyouwillingtosacrificeasmallbitofperformancefortheeasierdevelopmentofmanagedcodeThequickertimetomarketThegreatersecurityTheeasierdebuggingAreyouevensurethatyouwouldseeadifferenceinperformanceLikeImentionedearlier,therearecertaingamestodaythataren'tgoodfitsforhavingthemainenginewritteninmanagedcode,butthereareplentyoftitlesthatare.
ThetoptensellingPCgamesjustafewmonthsagoincludedtwoversionsoftheSims,ZooTycoon(+expansion),BackyardBasketball2004,andUru:AgesBeyondMyst,anyofwhichcouldhavebeenwritteninmanagedcode.
Anyonewhohastakenthetimetowritesomecodeinoneofthemanagedlanguagesnormallyrealizesthebenefitstheplatformoffersprettyquickly.
UsingxiForewordxiithisbook,youshouldbeabletopickupthebeginningconceptsofgamedevel-opmentprettyeasily.
Ittakesyouthroughthesimplesprite-basedgames,allthewaythroughabasic3-Dgameimplementation.
It'sanexcitingtimetobeadeveloper.
TomMillerLeadDeveloperfortheManagedDirectXLibrary,MicrosoftCorporationAbouttheAuthorsSomewherearound1974,DavidWellerdiscoveredacoin-operatedPonggameinapizzaparlorinSacramento,California,andwasinstantlyhookedoncom-putergames.
Afewyearslater,hewasintroducedtotheworldofprogrammingbyhisgodfather,wholethimusehisRadioShackTRS-80computertolearnaboutprogramminginBASIC.
David'sfirstprogramwasasimpledicegamethatgraphicallydisplayedthedieface(hestillhasthefirstversionheoriginallywroteonpaper).
HequicklyoutgrewBASICthough,andsoondiscoveredtheamazingspeedyoucouldgetbywritingvideogamesinassemblylanguage.
Hespenttheremainderofhishighschoolyearsgettingbadgrades,butwritingcoolsoftware,noneofwhichmadehimanymoney.
Hespentthenext10yearsinthemilitary,learningdetailsaboutcomputersystemsandsoftwaredevelop-ment.
Shortlyafterheleftthemilitary,DavidwasofferedajobtohelpbuildtheSpaceStationTrainingFacilityatNASA.
Fromthatpointon,hemerrilyspenttimeworkingonvisualsimulationandvirtualrealityapplications.
HemadetheoddshiftintomultitierITapplicationdevelopmentduringtheInternetboom,ultimatelylandinginsideofMicrosoftasatechnicalevangelist,wherehespendstimeplayingwithallsortsofnewtechnologyandmerrilysayingunderhisbreath,"Ican'tbelievepeoplepaymetohavethismuchfun!
"AlexandreSantosLobaogothisfirstcomputerin1981,whenhewas12,andimmediatelystartedtocreatesimplegamesinBASIC.
Sincethen,computershaveevolvedmassively,andsohashe.
Graduatingwithabachelor'sdegreeincomputersciencein1991,Alexandre,togetherwithsixfriends,foundedthatsameyearacompanythatcametobeknownasasynonymforhigh-qualityservicesinBrasilia,Brazil:HeptaInformatica.
Besideshisexcellentworkinmanysoftwaredevelopmentareas,fromfinancialtotelecommunication,heneverforgothisfirstpassion,andhasalwaysworkedasanonprofessionalgameprogrammer.
From1997to1999healsoworkedatVirtuallyReal(http://www.
vrea1ware.
com),avirtualAustralianamateurgameprogrammingcompanyfoundedbyCraigJardine.
Attheendof2000,Alexandrestartedsearchingfornewhorizonsand,leavingthecompanyhehelpedtocreate,enteredMicrosoftasaconsultant.
Lookingatthenewandextremelyinterestingpossibilitiesofferedbythe.
NETFramework,hedecidedtotakeeverythinghe'slearnedoverthelastdecadeandapplyittothisnewdevelopmentplatform.
xiiiAbouttheAuthorsxivEllenHattonisacomputerscienceundergraduateatEdinburghUniversity.
Shewasexposedtocomputersataveryearlyageandhasbeenfascinatedwiththemeversince.
HerfirstexperienceofcomputergameswasplayingDreadDragonDoom,atwhichshequicklyexcelledattheageof5.
She'sbeenhookedongameseversince.
Ellenisnotonlyinterestedincomputers.
Sheskisfrequently,amongothersports,andenjoysgeneralstudentlifeinthebustlingScottishcapital,Edinburgh.
Asherchoiceofdegreesuggests,Ellenstillfindscomputersveryinterestingandisconstantlylookingfornewchallenges.
Thisbookisthelatest.
AbouttheTechnicalReviewersAndrewJenksbeganwritingcodewhenhisparentsboughthimaTI99-4AforaChristmaspresent.
Astapedriveswerehardtouse,andthemediaresultingwasoftenoverwrittenbysingingsiblings,hisfatherbroughthometheirfirstfamilycomputerin1985.
AndrewlearnedtowriteBASICandassemblyprogramsthrougholdSanyomanualsandwhateverhecouldfindinthelibrary.
ThisprovedhandywhenhefoundhimselfbrokeattheGeorgiaInstituteofTechnologyanddiscov-eredthatpeoplewouldpayhimtoteachcomputingclasses.
Hewentontoactasadeveloperforanartificialintelligencecompany,managerforacommunicationcompanyatthe1996Olympics,andtechnicaladvisorforseveralpoliticalcam-paigns.
AndrewjoinedMicrosoftasaprogrammanagerin2000andcancurrentlybefoundworkingonMSNMmigrationissueswhenhe'snotoffskiingordiving.
DuringAndrew'sillustriouscareerasaprofessionalgeek,hehaswrittencodethatcausedseveralgraphicscardstomakeprettybluesparks,lostonemonitorduetoalongfall,andsetonemachineonfire.
Heismostproudofthefire.
Thatwasgoodcode.
KentSharkeyistheVisualStudioandASP.
NETcontentstrategistforMSDN,managingthecontentappearingonthosetwosites.
Whennotkneedeepinmeetingsande-mail,hespendstimewithhiswife(Margaret)andstopsfightsbetweenhistwocats(SquirrelandCica).
TomMilleristhedesigneranddevelopmentleadfortheManagedDirectXAPI.
HehasworkedatMicrosoftsince1997,wherehestartedontheVisualBasicteambeforehisloveofgamesandgameprogrammingtookhimtotheDirectXteam.
HehasbeenontheDirectXteamsincelate1999,andhasworkedtobringtheDirectXAPI(andgameprogrammingingeneral)toawideraudience.
xvxviCreditsFigure6-13:SerousSam2001isatrademarkofCroteamLtd.
Allrightsreserved.
FigureC-1:QuakeisatrademarkofIdSoftware.
Allrightsreserved.
FigureC-4:PAC-MAN1980NameoLtd.
Allrightsreserved.
CourtesyofNameoHoldingCorp.
FigureC-5:SuperMarioBros.
21988byNintendoofAmericaInc.
FigureC-6:GALAGA1980NameoLtd.
Allrightsreserved.
CourtesyofNameoHoldingCorp.
FigureC-7:GAUNTLETDARKLEGACYTM1998-2000MidwayGamesWestInc.
GAUNTLETDARKLEGACYisatrademarkofMidwayGamesWestInc.
Allrightsreserved.
AcknowledgmentsToolsandTunesTobeginwith,nodevelopmenteffortcanbedonewithouttools.
Thesetoolswereinvaluabletome,andIheartilyrecommendthemas"musthave"tools:IDE:VisualStudio.
NETProfessional2003(http://www.
microsoft.
com/catalog/display.
aspsubid=22&site=11513&X=30&y=4)Sourcecontrol:SourceGear'sVault(http://www.
sourcegear.
com/vault)Refactoring:XtremeSimplicity'sC#Refactory(http://www.
xtreme-simplicity.
net/CSharpRefactory.
html)SDK:DirectX9SDK(http://www.
microsoft.
com/directx)WealsowanttogiveextraspecialthankstoATITechnologiesforprovidinganATIRadeon9800Proandtechnicalsupportwhilethisbookwasbeingwritten.
Ialsowanttothankthosewhokeptmerockingwhiletyping:Prodigy,GhettoBoys,Radiohead,Everclear,ACIDC,ChristopherParkening,ElliotFisk,JimmyBuffett,FleetwoodMac,thecastofthemovieChicago,Shakira,NorahJones,AlejandroSanz,Juanes,andmany,manymore.
PeopleWhoReallyMadeThisHappenFewauthorscanwriteabookcompletelybythemselves,andI'mnoexceptiontothisrule.
Firstandforemost,thisbookcouldnothavebeendonewithoutthecodingwisdomofScottHaynie.
HeconvertedtheSpacewargameandwrotethebulkofthecodefortheSpacewar3Dgame.
Inaddition,hegladlycontributedthe3-DmodelsfortheSpacewar3Dgame.
Thisbookwouldhavebeenverydif-ferentwithouthishelpandideas,andhehasmyundyinggratitude.
Inaddition,otherpeoplehelpedbycontributingcodeorofferingsugges-tions.
TristianCartony(.
Nettrix),StephenToub(.
Netterpillars),CaroleSnyder,andFranklinMunoz.
ForanybodyelsewhocontributedthatIforgottocalloutbyname,pleaseacceptmyapologiesinadvance.
xviiAcknowledgmentsxviiiTherearetwootherpeopleI'despeciallyliketothank:TomMiller,theprin-cipaldeveloperoftheManagedDirectXlibraries,graciouslywhackedmeovertheheadseveraltimessaying,"Whatwereyouthinking!
"Withouthis(ifyou'llpardonthepun)directinput,wemighthavetaughtsomebeginnerssomeverybadManagedDirectXhabits.
And,ofcourse,SofiaMarchant,theprojectman-agerforthisbook,whodidagreatjobofbeingmy"velvet-glovedtaskmaster"aswell,makingsureIwasstayingonscheduletogetthisbookdoneontime(inspiteofmakingherrewritetheschedulenolessthanfourtimes).
Lastlyonthelistarethepeoplewhohavequietly(ornotsoquietly)influ-encedthisbook:Mygodfather,CharlesPlott,whoopenedupmyeyestotheworldofcomputersandcomputergames.
Myhighschoolmathteacher,DuanePeterson,wholetmetakeacomputerprogrammingclassinspiteofnotknowingenoughmath-theresultofwhichinspiredmetogetadegreeincomputersciencewithamathminor.
Mymomanddad,whoputupwithmyintensepassionforcomputersduringmyadolescence,inspiteofnothavingenoughmoneytobuymethemainframesystemIwantedtoputinourgarage.
Mykids,ErichandGretchen,andtheirmother,Nancy,whopatientlytoleratedmypassionforcomputergamesformanyyears.
Lastly,Iwanttothankmygirlfriend,Ana,whohasmadesomeverygloomydaysformemuchbrighter,andwhogavemeallthesupportshecould,eventhoughshewas2000milesawaymostofthetime.
-DavidWellerPrefaceIAPPROACHEDALEXANDREABOUTAYEARAGOtoofferhimcommentsonhisfirstbook,.
NETGameProgrammingwithDirectX9.
0.
MerIpresentedhimwitharatherlonglistofwhatIwouldhavedonedifferently,Alexgraciouslysuggestedcollaboratingonanewbook.
Wedecidedearlyintheprocesstoreusesomeofthegameexamplesfromhisbook(specifically.
Nettrixand.
Netterpillars),althoughsomepartshavebeenheavilymodified.
Wedidthisfortworeasons:Thegamesaregood,simpleexamplesthatcanstandthetestoftimewhenitcomestolearninggameprogramming.
Therewasnosensecreatingadifferentgamejusttoconveythesameconcept.
Writingdifferentgamesfromscratchwouldtaketimeawayfromaddingnewergamesattheendofthebookthatchallengedthebeginner.
Ofcourse,myyouthfulmemoriesoftheearlycomputergamesinfluencedmetochooseaspacethemeforthelatergames,leaningonthewell-knowngamesofAsteroidsandSpacewar.
ButIwantedtotakethingsastepfurther,toshowhow2-Dgamingknowledgecanquicklyscaleinto3-Dgames.
Ihadneverseenabooktakesuchastep,andwasfranklyworriedthatitcouldn'tbedoneeffectively.
However,thebookyou'reholdingisthebestattemptIcanputfor-ward,andhopefullyyou'llfindtheprogressionsimpleaswellasinstructional.
Duetomydistasteforgamingbooksthatdoubleasgymnasiumfreeweights,Iwantedtocreateabookthatavoidedthelong,pointlesschaptersthatexplainedC#,object-orientedprogramming,howtouseVisualStudio,etc.
Thisbookgetsrighttothegames,andassumesyouhavearudimentaryknowledgeofC#.
IfyouneedtogetuptospeedonC#,IrecommendEricGunnerson'sAProgrammer'sIntroductiontoC#,SecondEdition(Apress,2001).
FordeveloperswhoarealreadyfamiliarwithC++andbasicgamingcon-cepts,thisbookwillservewellasahigh-speedintroductiontoC#and,inlaterchapters,ManagedDirectX.
Ifyou'realreadyintimatelyfamiliarwithDirectXgamedevelopmentandarelookingforabookfocuseddirectlyonManagedDirectX,IrecommendManagedDirectXKickStart(SAMS,2003)writtenbyTomMiller.
Ofcourse,Iwouldloveforyoutobuythisbookaswell,butI'mmoreinterestedingettingyoutowritegamesinManagedDirectXthanIaminmak-ingabuckortwobyconvincingyoutobuythisbook.
Thewholebookisdesignedtobereadinacontinuousway.
InChapter1,westartbycreatingaverysimplegamewhilepresentingthebasicsofcollisionxixPrefacexxdetection.
Chapter2showshowtobuildanewgame,usingtheconceptspre-sentedinChapter1andaddingnewexplanationsandexamplesaboutartificialintelligenceingames.
Inthefollowingchapters,wecontinuetobuildnewgamesandexplorenewtopicsrelatingtogameprogramming,suchasthebasicsofspritecreation,mul-tiplayerfeatures,3-Dgraphics,portingagametoPocketPC,andmuchmore.
Westartwiththebasicsandincreasethecomplexityaswegoalong,sothatbythetimeyoucometotheadvancedtopics,youhaveallthebackgroundyouneedtogainthemostfromthem.
Neartheendofthebook,westickourtoesinthedeeperDirectXwatersbyinvestigatingpointsprites.
Ihaveyettoseeabookthatdiscussespointspritesinagood,introductorystyle,soevenintermediategamedevelopersshouldfindthispartinteresting.
Pleasekeepinmindthoughthatthisbookisn'tintendedtoprovidearoutetotheprofessionalgameprogrammingworld,becausewedon'tgodeepenoughintosomeessentialaspectsprofessionalgamedevelopersneedtoknow.
However,youcanthinkofthisbookasafirststepintothisworld,sincewedoprovideinsightsintoimportantconceptssuchastheneedtocreateagoodgameprojectandorganizingthegame'steam,aswellasappendixeswrittenbyprofessionalsfromthegameindustrythatserveasguidestogamecreation.
-DavidWellerIntroductionAGameStartswithaGoodIdeaAlthoughthegamesreleasednowadaysaremoreandmoregraphicsintensive,themainpointinagameissometimesforgotten:theplayability.
Youseegameswithbreathtakinggraphics,amazingcut-scenes,and3-Dworldstomakeyoureyespopout,butmanyofthemarereallyannoyingtoplay.
Evenwhenagame'sresponsivenessisokay,sometimesthegameplayisn'tclearorfair.
WhataboutplayinganoldPac-MangameWithallthesegorgeousgamesaround,Pac-ManandtheearlierversionsofMarioBrothersonNintendoarestillsuccesseswithkids.
Wearen'theretotellyoutoforgeteverythingandgetbacktobasics.
Instead,rememberthatagoodgamealwaysstartswithagoodidea,andsometimesthat'senough.
Oneofthemostclonedgamesever,Tetris,wasdesignedbyasingleman,aRussianprogrammer.
It'sstillinterestingtoplayafteralltheseyears,and,ofcourse,wehaveaTetriscloneheretoo-ourversionofa"HelloWorld"programinthefirstchapter.
YoucouldsaythatTetrisisoneinamillion,andwe'dagree.
Butifyouweretosaythatcreatingagoodgamebyyourselfisonlypossibleifit'sassimpleasTetris,thenwe'dhavetodisagree.
OlderguyswillrememberAnotherWorld,agamethathasasequelcalledFlashBack.
Thegamehadverygoodgraphicsandsoundforitstime,withverynicecharacteranimationandvariouscut-scenesthatcompletedthegamestorybyshowingthecharactersandafantasticworldfrommanydifferentpointsofview.
Well,asingleperson,aFrenchprogrammer,designedthisgame.
TodaywecanseemanysitesontheWebwithgamesfromamateurgameprogrammers.
Someofthemarereallygood,withhigh-qualitygraphicsandsound;and,mostimportantofall,almostallareveryplayabletoo,maybebecausetheyweredesignedbypeoplewholovetocreateandplaygamesbutdon'thavetheurgetomakemoney.
Inthisbook,you'llseemanytipsandtricksthatwillhelpanyonetodesigntheirowngamesalone.
However,ifyoucancountonsomeonetohelpyou,do.
Afterall,there'smoretoagamethanjustagoodidea.
.
.
.
xxiIntroductionxxiiAGameIsMoreThanJustaGoodIdeaAlthoughagamemuststartwithagoodidea,thereisalotmoretothegameprogrammingworldthanourhumblemindscanimagine.
Let'slookatsomepointsyoumustkeepinmindwhenyoustartyourgameproject:Music:Althoughyoucanalwaysmakeagameusingonlybleepsandbloops,goodbackgroundmusicandnicesoundeffectsforgameactions(shooting,dying,earningbonuspoints,etc.
)makeyourgamesbetter.
Evenifyoudon'tplantohaveamusicexpertonyourstaff,youcan'tforgetthatit'lltakealotoftimetolookformusicwiththecorrectambianceandthebestsoundeffectsamongthemillionsyou'llfindontheInternetorinCDlibraries.
Drawing:It'snotgoodpracticetousegraphicsrippedofffromsomeoneelse'sgame,becauseyourgamewilllackoriginalityandyou'remostlikelybreakingcopyrightlaws.
Sincenoteveryonecandrawanythingbetterthanasquarehouseandasmileysun,you'llwantagoodartist(orseveralofthem)onyourgameteam.
Colors:Coloringthingsonthecomputerisverydifferentfromcoloringitonpaper.
Ifyourartistscan'tcolorusingagraphicstool,you'llneedsome-onewhocan.
Animation:Creatinganimatedgraphicsisslightlydifferentfromcreatingstaticones.
Almosteveryonecandrawanicetree,forexample,buttodrawawalkingmanoraflyingbirddemandssomeonewithanimationexperience.
Evenwhenyourgamesdon'tuseanimatedsprites,don'tforgetthatyoumayneedananimatedintroductionorcut-scenes.
Code:Well,withoutthisoneyouwouldbereadingaboardgamebook.
Leveldesign:Theleveldesignersaretheoneswho'llalwaysbeworkingtoensureoptimumgameplayandthemostenjoyableplayingexperienceforplayers.
Qualityassurance:Ifyoucan'taffordtohaveaverygoodqualityassuranceteam,you'rebetteroffnotbotheringtomakegames.
Abuggygameisbyfartheworstthingthatcanhappeninagamecompany'sprofile.
Projectmanagement:Workingwithmanypeoplewithdifferentskillsandpersonalitiesrequiresanorganizedwaytogetthebestfromeachofthem.
Evenwhenyou'reworkingalone,youmustn'tunderestimatetheimpor-tanceofagoodproject:Ifyoudon'tsetsomemilestonestocontrolyourproject,youmayworkonitforeverandneverseeanygoodresults.
It'sfarbeyondthescopeofthisbooktoteachyouhowtomanageaproject,butwestronglysuggestyoutakealookatsomestuffonthistopic,ifyou'veneverhadtheopportunityofworkingwithanorganizedteam.
Mostimportantly,youshouldlearngooddevelopmentdisciplinethatwillhelpyouworkaspartofateam.
Etc.
:There'llbelotsmoretoo,butingeneralyoumustbereadytodealwithanynewandunexpectedproblems.
Thetaskofcreatingacommercialgamenowadaysisanythingbutsimple.
Thetimewhenthe"lonewolf"programmercouldcreateanewhitandevengetrichwithitismostcertainlyover.
Nevertheless,let'skeeponethinginmind:Thisbookisforthosewholovegamedesign,whowillbehappywithmakinggamesjusttohavethepleasureofseeingpeopleenjoytheirideas.
Ifyouwanttomakeprofessionalgames,orifyouwanttolearnManagedDirectX,thisbookisareallygoodstartingpoint,butthere'salotmoreyouneedtostudybeforeenteringthegameindustry.
Aswe'veseen,ittakesalotofhardworkandcoordinatedefforttomakeablockbustergamenowadays,butdon'tbescaredoffbythesizeofthemountainyou'reabouttoclimb.
Remember:MaybeyourgamewillbethenextPac-Man,Tetris,orFlightSimulator.
Justkeepinmindonething:Agreatgamestartswithagoodidea!
HowtoReadThisBookThisbookaimstobeapracticalguideforgameprogramming,andtogetthemostoutofit,wesuggestthatyoustarteachchapterbyrunningthechapter'ssamplegamefromthedownloadablecodeontheApressWebsite(http://www.
apress.
com).
OpentheprojectinVisualStudio.
NET,andcompileandrunit.
Playforawhile,lookingatthedetailsofthegame,sothatwhenyoustartreadingeachchapteryou'llknowwhatthechapterisabout.
C#StyleConventionsThestyleweuseisslightlymodifiedfromconventionalC#codingstyle.
Althoughweusetypicalcapitalizationconventions,weturnonthe"LeaveopenbracesonIntroductionxxiiiIntroductionxxivsamelineasconstruct"option(Tools~Options~TextEditor~C#~Format-ting).
ThisisthestyleusedinmostoftheexamplesonMicrosoft'sMSDNWebsite(http://msdn.
microsoft.
com).
Allthisdoesismovetheopeningbraceofacodeblocktotheendofthepreviousline.
Thisalsoletsusconservealittlewhitespaceinthebook(becausewepersonallyhatebooksthathavepagesandpagesofsourcecodeinlargefontsandlotsofverticalwhitespace).
BookContentsInthisbook,we'llcreatefourdifferentgamesspanningsevenchapters,plusabonuschapterattheend.
Thecodeisalsoorganizedbychapter,andinmanycasesisorganizedinincrementalsteps.
TheprogramswerecreatedandtestedwithDirectX9.
0(Summer2003Update)andVisualStudio2003.
You'llneedtodownloadseparatelytheDirectXSDKfromhttp://msdn.
microsoft.
comldirectx,andifyoudecidetouseadifferenteditor,you'llhavetocreateprojectfilesinwhicheverformatthattoolsupports.
It'sentirelypossibletoedit/runallthesegameswithonlythe.
NETandDirectXSDKs,plusasimpletexteditorlikeNotepad,butwerecommendusingVisualStudio,orsomeotherintelligentedi-tor,ifpossible.
Inthenextsections,wegiveabriefdescriptionofthecontentsofeachchapter.
Chapter1:.
Nettrix:GDI+andCollisionDetectionInthefirstchapter,weintroducetheconceptofcollisiondetectioningames,presentsimplealgorithmstomanagethedetectionofcollisionbetweenobjectsinagame,andintroducebasicconceptsabouttheGDI+,thegraphicallibraryusedbythe.
NETFrameworktoperformsimplegraphicaloperations.
Inthischapter,wecreateaTetrisclonecalled.
Nettrixtoillustratetheuseoftheseconcepts.
Chapter2:.
Netterpillars:ArtificialIntelligenceandSpritesHereweexaminetheconceptofobject-orientedprogramming,alongwithaglossaryofrelatedterms.
Wealsoexplaintheideaofcreatingalibraryofgameclasses,whichcanbeusedinfurthergamedevelopmentstoimprovethegamequalityandthegameprojectschedule.
Inthischapter,wealsoprovideabriefintroductiontoartificialintelligenceingames,presentingsomeclassicalproblemsyouneedtodealwithinyourgamesalongwithsomesuggestionsabouthowtosolvethem.
Thechapter'ssamplegame,.
Netterpillars,isaSnakesclonethatexplorestheconceptspresentedinthechapter.
Hereweshowyouhowtocreatethefirstreusableclassofthisbook-aGDI+-basedsprite.
Chapter3:ManagedDirectXFirstSteps:Direct3DBasicsandDirectXvs.
GDI+Chapter3presentsManagedDirectX9.
0,exploringthebasicssuchastheuseofmatrixtransformations,transparenttexturing,andcoloredlights.
Herewealsodiscusshowtodecidewhichgraphicslibrary(DirectXorGDI+)tousedependingonthegametype.
Inthischapter,wehavenogame,justasimpleapplicationthatwillexerciseeachofthischapter'sconcepts.
Chapter4:SpaceDonuts:SpritesRevisitedInChapter4,wediscussthecreationofspritesusingaspecialclassfromManagedDirectX.
WealsointroducethebasicconceptsofDirectSoundandDirectInput.
Usingtheclassesandconceptsdiscussedinthischapter,wewalkyouthroughthecreationofanAsteroidsclonecalledSpaceDonuts.
Chapter5:Spacewar!
HerewelookatadditionaltechniquesofrewritingcodethatusedearlierversionsofDirectX,payingparticularattentiontotheDirectDrawlibraries.
Inaddition,weintroducetheconceptsofDirectPlay,whichgivesyoutheabilitytowritenet-worked,multiplayergames.
ThischaptercreatesanimplementationoftheSpacewargame,oneofthefirstgamesevercreatedonacomputer,andstillenjoyabletothisday.
Chapter6:Spacewar3D:MeshesandBuffersandTextures,OhMy!
WenowtaketheSpacewargameandlaunchourselvesintotheworldofDirect3D.
Thischaptercoversmanynew3-Dconcepts,butalsoshowshowtocarryovercodethatexistedinthe2-DversionofSpacewar.
IntroductionxxvIntroductionxxviChapter7:AddingVisualEffectstoSpacewar3DThischaptergoesintothedetailsofwritinggamesthatusepointsprites,arela-tivelyadvancedconcept,butonethatyieldssignificantvisualbenefits.
BonusChapter:Porting.
NettrixtoPocketPCInthisbonuschapter,wediscusstheproblemsdevelopersfacewhenportinggamestodifferentdevices,andpresentthe.
NETCompactFramework.
Usingtheseconcepts,weshowyouhowtocreateasecondversionofyourTetrisclonebyportingthesamplegamecreatedinChapter1torunonaPocketPC.
AppendixesInordertogiveyouasenseofwhatprofessionalgamersthinkaboutgamecreation,we'veincludedasappendixesarticlesfromthreeprofessionalswhoalreadyworkinthegameindustry,plusasectiononrecommendedbookstoread:AppendixA:SuggestedReadingAppendixB:"MotivationsinGames,"bySarbasstHassanpourAppendixC:"HowDoIMakeGames"byGeoffHowlandAppendixD:"GuidelinesforDevelopingSuccessfulGames,"byBruceShelley

随风云-内蒙古三线BGP 2-2 5M 25/月 ,香港CN2 25/月 ,美国CERA 25/月 所有云服务器均支持5天无理由退款

公司成立于2021年,专注为用户提供低价高性能云计算产品,致力于云计算应用的易用性开发,面向全球客户提供基于云计算的IT解决方案与客户服务,拥有丰富的国内BGP、三线高防、香港等优质的IDC资源。公司一直秉承”以人为本、客户为尊、永续创新”的价值观,坚持”以微笑收获友善, 以尊重收获理解,以责任收获支持,以谦卑收获成长”的行为观向客户提供全面优质的互...

HostKvm开年促销:香港国际/美国洛杉矶VPS七折,其他机房八折

HostKvm也发布了开年促销方案,针对香港国际和美国洛杉矶两个机房的VPS主机提供7折优惠码,其他机房业务提供8折优惠码。商家成立于2013年,提供基于KVM架构的VPS主机,可选数据中心包括日本、新加坡、韩国、美国、中国香港等多个地区机房,均为国内直连或优化线路,延迟较低,适合建站或者远程办公等。下面列出几款主机配置信息。美国洛杉矶套餐:美国 US-Plan1CPU:1core内存:2GB硬盘...

Friendhosting四五折促销,VPS半年付7.5欧元起

Friendhosting发布了针对“系统管理日”(每年7月的最后一个星期五)的优惠活动,针对VPS主机提供55%的优惠(相当于四五折),支持1-6个月付款使用,首付折扣非永久,优惠后最低套餐首半年7.18欧元起。这是一家保加利亚主机商,成立于2009年4月,商家提供VDS和独立服务器租用等,数据中心目前可选美国洛杉矶、保加利亚、乌克兰、荷兰、拉脱维亚、捷克和波兰等8个地区机房。下面以最低套餐为例...

sourcegear为你推荐
google竞价排名Google的竞价排名是怎么计费的手游运营手册2019新个税主要内容有哪些?可以简单说明一下吗?人人时光机寻时光机歌词湖南商标注册湖南长沙怎么注册商标天天酷跑刷积分教程最近一直有人说天天酷跑刷积分,怎么刷的。今日热点怎么删除如何彻底删除今日热点安卓应用平台app应用平台有哪些 应用平台哪些奇虎论坛360有论坛中心?小米手柄小米蓝牙游戏手柄怎么连接游戏如何清理ie缓存怎么样清理IE缓存?
中文域名申请 轻博 win8升级win10正式版 ubuntu更新源 xen 租空间 国外在线代理 怎样建立邮箱 静态空间 paypal注册教程 爱奇艺会员免费试用 闪讯官网 香港亚马逊 独享主机 丽萨 东莞服务器托管 论坛主机 百度云空间 中国域名 阿里dns 更多