您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 公司方案 > DotNET.Game.Programming.with.DirectX.9.0
.NETGameProgrammingwithDirectX9.0ALEXANDRESANTOSLOBÃOANDELLENHATTON*0511_ch00_FINAL2/18/034:58PMPageiwinxos11-01-28winxos11-01-28.NETGameProgrammingwithDirectX9.0Copyright©2003byAlexandreSantosLobãoandEllenHattonAllrightsreserved.Nopartofthisworkmaybereproducedortransmittedinanyformorbyanymeans,electronicormechanical,includingphotocopying,recording,orbyanyinformationstorageorretrievalsystem,withoutthepriorwrittenpermissionofthecopyrightownerandthepublisher.ISBN(pbk):1-59059-051-1PrintedandboundintheUnitedStatesofAmerica12345678910Trademarkednamesmayappearinthisbook.Ratherthanuseatrademarksymbolwitheveryoccurrenceofatrademarkedname,weusethenamesonlyinaneditorialfashionandtothebenefitofthetrademarkowner,withnointentionofinfringementofthetrademark.TechnicalReviewer:DavidJungEditorialDirectors:DanAppleman,GaryCornell,SimonHayes,KarenWatterson,JohnZukowskiManagingEditor:GraceWongProjectManager:SofiaMarchantCopyEditor:AmiKnoxProductionManager:KariBrooksCompositor:DianaVanWinkle,VanWinkleDesignGroupArtistandCoverDesigner:KurtKramesIndexer:LynnArmstrongManufacturingManager:TomDebolskiDistributedtothebooktradeintheUnitedStatesbySpringer-VerlagNewYork,Inc.,175FifthAvenue,NewYork,NY,10010andoutsidetheUnitedStatesbySpringer-VerlagGmbH&Co.KG,Tiergartenstr.17,69112Heidelberg,Germany.IntheUnitedStates,phone1-800-SPRINGER,emailorders@springer-ny.com,orvisit@springer.de,orvisit:510-549-5939,emailinfo@apress.com,orvisit“asis”basis,withoutwarranty.Althougheveryprecautionhasbeentakeninthepreparationofthiswork,neithertheauthornorApressshallhaveanyliabilitytoanypersonorentitywithrespecttoanylossordamagecausedorallegedtobecauseddirectlyorindirectlybytheinformationcontainedinthiswork.*0511_ch00_FINAL2/18/034:58PMPageiiCHAPTER4RiverPla.Net:TiledGameFields,Scrolling,andDirectAudioINTHISCHAPTERwe’llapplytheconceptslearnedinthepre-viouschapteraboutDirect3DtoimplementDirectXgamingclasses(suchasGameEngineandSprite),sowe’lleasilybeabletocreatehigh-speedgraphicsgames.We’llalsointroducebasicDirectAudioconceptsthatwillallowustoincludesoundeffectsandbackgroundmusicinourgames.We’llalsoexaminetheconceptoftiledgamefieldsandscrollingingames,andstartimplementingacloneofActivision’sRiverRaidgame,apopulartitleforAtari2600andVCS.Oursamplegame,showninFigure4-1,willbefinishedinthenextchapter,wherewe’llintroduceDirectInputandtheuseofforce-feedbackjoysticks.Scrollinggamesandtile-basedgameshavebeenaroundsinceearliervideogameconsolesandhomecomputershittheshelves,andweoftenseegamesthatusebothtechniques.We’lldiscusssomeinterestingpointsabouteachinthenextsections.211Figure4-1.RiverPla.Net,aRiverRaidclone,isthischapter’ssamplegame*0511_ch04_FINAL2/18/037:47PMPage211ScrollingGamesAlthoughthebasicconceptofscrollinggamesisverysimple,therearemanyinter-estingvariationswemustconsiderwhenwestartcreatinganewgame.Wecandefinescrollinggamesasthegamesinwhichthebackgroundmovesinacon-tinuousway.It’saveryloosedefinition,butit’llsufficeforourgoalshere.Someofthetypicalchoiceswemustmakewhencodingscrollinggamesarediscussednext.ScrollingDirectionAllscrollinggamesareeitherverticalscrollers,horizontalscrollers,orfullscrollers,meaningthatthebackgroundonthesegamesscrollinaverticaldirection,inahorizontaldirection,orinanydirection.We’lldiscusssomevariationsofthesemovementsinthissection.Themostcommonchoiceistoimplementvertical“up-down”scrollers(asdoesthesamplegameforthischapter),wherethebackgroundmovesfromthetoptothebottomofthescreen,andhorizontal“right-left”scrollers,wheretheback-groundmovesfromrighttoleft.Wedon’tseemanyscrollinggamesusingtheoppositedirectionschemesbecauseusingthesedirectionsmakesourgamesseemmorenaturaltoplayers.Fullscrollersarehardertoimplementandtoplay,butwhenmadecorrectly,theycanleadtoveryinterestinggameplay.Justimagineagameinwhichplayerscanmovetheircharacterinanydirection:Thismightbeaninterestingfeature,buttheplayercouldbecomedisorientated,andthegameobjectivewouldbelessclear.ParallaxScrollingParallaxscrollingisaningenioustrickthatgivesplayersthefeelingofbeingina3-Denvironment,evenwithflatimages.Thebasicideaistocreatedifferentlayersofbackgroundobjects,eachonemovingatdifferentspeeds.Forexample,ifwearecontrollingamonkeyinajungle,wecancreatesomebushesandtreesthatscrollatthesamespeedastheterrain,treesalittlefartheroffthatmovealittleslower,distantmountainsthatmoveveryslowly,andmaybeafixedmooninthesky.Chapter4212*0511_ch04_FINAL2/18/037:47PMPage212Thisapproachcreatesamorelifelikegame,butmustbeusedwithcarebecauseitcanleadtovisualclutterandconfusionfortheplayer.Agoodtipistomakedistantobjectswithlessvividcolors.Thisaddstotheambiencewithoutdistractingtheplayer.PlayerorEngine-ControlledScrollingWhencodingthescrollingforourgame,weneedtodecidewhethertheback-groundwillalwaysbemoving(except,perhaps,whe
本文标题:DotNET.Game.Programming.with.DirectX.9.0
链接地址:https://www.777doc.com/doc-4916917 .html