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

Pia云服务商春节6.66折 美国洛杉矶/中国香港/俄罗斯和深圳机房

Pia云这个商家的云服务器在前面也有介绍过几次,从价格上确实比较便宜。我们可以看到最低云服务器低至月付20元,服务器均采用KVM虚拟架构技术,数据中心包括美国洛杉矶、中国香港、俄罗斯和深圳地区,这次春节活动商家的活动力度比较大推出出全场6.66折,如果我们有需要可以体验。初次体验的记得月付方案,如果合适再续约。pia云春节活动优惠券:piayun-2022 Pia云服务商官方网站我们一起看看这次活...

桔子数据58元/月 ,Cera美西云服务器 2核4G 50G数据盘 500M带宽 1000G流量

桔子数据(徐州铭联信息科技有限公司)成立于2020年,是国内领先的互联网业务平台服务提供商。公司专注为用户提供低价高性能云计算产品,致力于云计算应用的易用性开发,并引导云计算在国内普及。目前公司研发以及运营云服务基础设施服务平台(IaaS),面向全球客户提供基于云计算的IT解决方案与客户服务,拥有丰富的国内BGP、双线高防、香港等优质的IDC资源。 公司一直秉承”以人为本、客户为尊、永...

Sparkedhost($8/月)美国迈阿密AMD Ryzen高性能VPS;免费100G高防

sparkedhost怎么样?sparkedhost主机。Sparkedhost于2017年7月注册在美国康涅狄格州,2018年收购了ClynexHost,2019年8月从Taltum Solutions SL收购了The Beast Hosting,同年10月从Reilly Bauer收购了OptNode Hosting。sparkedhost当前的业务主要为:为游戏“我的世界”提供服务器、虚拟...

sourcegear为你推荐
免费开通黄钻花钱开通黄钻和免费开通有什么区别?办公协同软件免费的多人协同办公软件哪些,我了解的有钉钉、企业微信,其他的还有么?天天酷跑刷金币天天酷跑怎么刷金币?腾讯文章怎样才能在手机腾讯网上发表文章?开机滚动条电脑开机有滚动条的画面怎么点亮qq空间图标怎样点亮qq空间的图标数据库损坏数据库坏了,怎么修复?人人逛街人人逛街评论怎么不显示链接了?好像4月28日就不能显示了。是什么原因呢?人人逛街为什么女人都喜欢逛街?谢谢了,大神帮忙啊bt封杀北京禁用BT下载,是真的吗?为什么?
免费com域名注册 虚拟主机服务商 网站虚拟主机空间 国外vps租用 万网域名解析 dreamhost blackfriday 59.99美元 ssh帐号 免费网络电视 最好的免费空间 双十一秒杀 东莞数据中心 免费测手机号 银盘服务是什么 带宽租赁 购买空间 电信主机托管 香港ip 腾讯服务器 更多