使用何种语言编写游戏gbxb.docx

上传人:you****now 文档编号:48084137 上传时间:2022-10-05 格式:DOCX 页数:29 大小:93.44KB
返回 下载 相关 举报
使用何种语言编写游戏gbxb.docx_第1页
第1页 / 共29页
使用何种语言编写游戏gbxb.docx_第2页
第2页 / 共29页
点击查看更多>>
资源描述

《使用何种语言编写游戏gbxb.docx》由会员分享,可在线阅读,更多相关《使用何种语言编写游戏gbxb.docx(29页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。

1、我该使用用何种语语言这是是每个游游戏编程程FAQQ里都有有的问题题。这个个问题每每星期都都会在游游戏开发发论坛上上被问上上好几次次。这是是个很好好的问题题,但是是,没人人能给出出简单的的答案。在在某些应应用程序序中,总总有一些些计算机机语言优优于其他他语言。下下面是几几种用于于编写游游戏的主主要编程程语言的的介绍及及其优缺缺点。希希望这篇篇文章能能帮助你你做出决决定。Thhis is a qquesstioon tthatt beelonngs in eveery gamme pproggrammminng FFAQ. Itt seeemss too bee asskedd inn a gam

2、me ddeveeloppmennt fforuum sseveerall tiimess a weeek. Its aa goood queestiion, thhouggh, andd noot oone witth aan eeasyy annsweer. Theere aree coompuuterr laanguuagees tthatt woork bettterr foor ssomee apppliicattionns tthann ottherrs. Herre iis aa liist of thee maajorr prrogrrammmingg laanguuagees

3、 uusedd too wrritee gaamess allongg wiith desscriiptiionss, aadvaantaagess, aand dissadvvanttagees. Hoppefuullyy thhis lisst wwilll heelp youu maake a ddeciisioon.1、C语语言如果果说FOORTRRAN和和COBBOL是是第一代代高级编编译语言言,那么么C语言言就是它它们的孙孙子辈。CC语言是是Dennniss Riitchhie在在七十年年代创建建的,它它功能更更强大且且与ALLGOLL保持更更连续的的继承性性,而AALGOOL则是

4、是COBBOL和和FORRTRAAN的结结构化继继承者。CC语言被被设计成成一个比比它的前前辈更精精巧、更更简单的的版本,它它适于编编写系统统级的程程序,比比如操作作系统。在在此之前前,操作作系统是是使用汇汇编语言言编写的的,而且且不可移移植。CC语言是是第一个个使得系系统级代代码移植植成为可可能的编编程语言言。Iff FOORTRRAN andd COOBOLL weere thee fiirstt coompiiledd hiigh-levvel lannguaagess, tthenn C is theeir graandcchilld. It wass crreatted in the

5、e 700s by Dennniss Riitchhie as a ttighhterr annd mmoree cooherrentt suucceessoor tto AALGOOL, whiich wass a strructtureed ssucccesssor to COBBOL andd FOORTRRAN. Itt waas ddesiigneed tto bbe aa smmalller andd siimpller verrsioon oof iits preedeccesssorss, ssuittablle ffor wriitinng ssysttem-levvel p

6、roograams, liike opeerattingg syysteems. Beeforre tthenn, ooperratiing sysstemms wweree haand-codded in asssembbly andd weere nott poortaablee. CC waas tthe firrst proograammiing lannguaage thaat mmadee poortaabillityy a reaalitty ffor sysstemm-leevell coode.C语语言支持持结构化化编程,也也就是说说C的程程序被编编写成一一些分离离的函数数呼

7、叫(调调用)的的集合,这这些呼叫叫是自上上而下运运行,而而不像一一个单独独的集成成块的代代码使用用GOTTO语句句控制流流程。因因此,CC程序比比起集成成性的FFORTTRANN及COOBOLL的“空心粉粉式代码码”代码要要简单得得多。事事实上,CC仍然具具有GOOTO语语句,不不过它的的功能被被限制了了,仅当当结构化化方案非非常复杂杂时才建建议使用用。C is a llangguagge tthatt suuppoortss sttruccturred proograammiing. Thhat is to sayy thhat C pproggramms aare wriitteen aa

8、s ccolllecttionns oof ddiscconnnectted funnctiion callls thaat rrun topp-doown rattherr thhan a ssinggle monnoliithiic bblocck oof ccodee wiith proograam cconttroll-fllow happpenningg viia GGOTOO sttateemennts. Heencee, CC prrogrramss arre ggeneerallly eassierr too foolloow tthann moonollithhic FORR

9、TRAAN aand COBBOL spaagheettii-coode. Acctuaallyy, CC sttilll haas aa GOOTO staatemmentt, bbut itss fuuncttionnaliity is limmiteed aand it is onlly rrecoommeendeed aas aa laast ressortt iff sttruccturred sollutiionss arre mmuchh moore commpliicatted.正由由于它的的系统编编程根源源,将CC和汇编编语言进进行结合合是相当当容易的的。函数数调用接接口非常

10、常简单,而而且汇编编语言指指令还能能内嵌到到C代码码中,所所以,不不需要连连接独立立的汇编编模块。Trrue to itss syysteem-pproggrammminng rrootts, it is faiirlyy eaasy to intterffacee C witth aasseemblly llangguagges. Thhe ffuncctioon-ccalllingg innterrfacce iis vveryy siimplle, andd asssemmblyy laanguuagee innstrructtionns ccan be embbeddded witth

11、inn C codde, so linnkinng iin ssepaaratte aasseemblly-llangguagge mmoduuless iss noot nneceessaary.优点点:有益益于编写写小而快快的程序序。很容容易与汇汇编语言言结合。具具有很高高的标准准化,因因此其他他平台上上的各版版本非常常相似。Addvanntagges: Goood forr wrritiing smaall fasst pproggramms. Eassy tto iinteerfaace witth aasseemblly llangguagge. Verry sstanndarrdi

12、zzed, soo veersiionss onn ottherr pllatfformms aare simmilaar.缺点点:不容容易支持持面向对对象技术术。语法法有时会会非常难难以理解解,并造造成滥用用。Diisaddvanntagges: Dooes nott eaasilly ssuppportt obbjecct-oorieenteed ttechhniqquess. SSynttax cann bee diiffiicullt aand lennds itsselff too abbusee.移植植性:CC语言的的核心以以及ANNSI函函数调用用都具有有移植性性,但仅仅限于流流

13、程控制制、内存存管理和和简单的的文件处处理。其其他的东东西都跟跟平台有有关。比比如说,为为Winndowws和MMac开开发可移移植的程程序,用用户界面面部分就就需要用用到与系系统相关关的函数数调用。这这一般意意味着你你必须写写两次用用户界面面代码,不不过还好好有一些些库可以以减轻工工作量。Poortaabillityy: WWhille tthe corre oof tthe lannguaage andd thhe AANSII fuuncttionn caallss arre vveryy poortaablee, ttheyy arre llimiitedd too coontrrol

14、-floow, memmoryy maanaggemeent, annd ssimpple fille-hhanddlinng. Eveerytthinng eelsee iss pllatfformm-sppeciificc. MMakiing a pproggramm thhats pporttablle bbetwweenn Wiindoows andd thhe MMac, foor iinsttancce, reqquirres thaat tthe useer-iinteerfaace porrtioons be usiing sysstemm-sppeciificc fuunct

15、tionn caallss. TThiss geenerrallly mmeanns tthatt yoou nneedd too wrritee thhe uuserr-innterrfacce ccodee twwicee. TTherre aare libbrarriess, tthouugh, thhat makke tthe proocesss aa biit eeasiier.用CC语言编编写的游游戏:非非常非常常多。Gaamess Wrrittten in C: Lotts aand lotts.资料料:C语语言的经经典著作作是TThe C PProggrammminng LLa

16、ngguagge,它它经过多多次修改改,已经经扩展到到最初的的三倍大大,但它它仍然是是介绍CC的优秀秀书本。一一本极好好的教程程是TThe Waiite Grooups CC Prrimeer PPluss。Reesouurcees: Thee cllasssic boook aabouut CC iss TThe C PProggrammminng LLangguagge.Its ggonee thhrouugh sevveraal iiterratiionss annd hhas exppandded to aboout thrree timmes itss orrigiinall sii

17、ze, buut iitss sttilll a goood iintrroduuctiion to thee laanguuagee. AAn eexceelleent tuttoriial is Thhe WWaitte GGrouupss C Priimerr Pllus.2、C+C+语言言是具有有面向对对象特性性的C语语言的继继承者。面面向对象象编程,或或称OOOP是结结构化编编程的下下一步。OOO程序序由对象象组成,其其中的对对象是数数据和函函数离散散集合。有有许多可可用的对对象库存存在,这这使得编编程简单单得只需需要将一一些程序序“建筑材材料”堆在一一起(至至少理论论上是这这样)。

18、比比如说,有有很多的的GUII和数据据库的库库实现为为对象的的集合。C+ iis tthe objjectt-orrienntedd suucceessoor tto CC. OObjeect-oriientted, orr OOO, pproggramms aare thee neext steep bbeyoond strructtureed pproggrammminng. OO proograams aree buuiltt ouut oof oobjeectss, wwhicch aare pacckagges of datta aand funnctiionss coolleect

19、eed iintoo diiscrretee unnitss. TTherre aare manny llibrrariies of objjectts aavaiilabble thaat mmakee wrritiing proograams as simmplee ass puulliing toggethher a ccolllecttionn off prrogrram buuilddingg bllockks (att leeastt inn thheorry). Foor eexammplee, ttherre aare manny GGUI andd daatabbasee l

20、iibraariees tthatt arre iimpllemeenteed aas ccolllecttionns oof oobjeectss.C+总是是辩论的的主题,尤尤其是在在游戏开开发论坛坛里。有有几项CC+的的功能,比比如虚拟拟函数,为为函数呼呼叫的决决策制定定增加了了一个额额外层次次,批评评家很快快指出CC+程程序将变变得比相相同功能能的C程程序来得得大和慢慢。C+的拥拥护者则则认为,用用C写出出与虚拟拟函数等等价的代代码同样样会增加加开支。这这将是一一个还在在进行,而而且不可可能很快快得出结结论的争争论。C+ iis tthe subbjecct oof cconttrovv

21、erssy, esppeciiallly iin tthe gamme ddeveeloppmennt ccommmuniity. Thheree arre ffeatturees oof CC+, liike virrtuaal ffuncctioons, thhat addd ann exxtraa laayerr off deecissionn-maakinng tto ffuncctioon ccallls, andd crritiics aree quuickk too poointt ouut tthatt C+ pproggramms ccan be larrgerr annd

22、sslowwer thaan CC coountterppartts. C+ addvoccatees ppoinnt oout, hoowevver, thhat coddingg thhe eequiivallentt off a virrtuaal ffuncctioon iin CC reequiiress thhe ssamee ovverhheadd. IItss ann onn-gooingg deebatte tthatts nott liikelly tto bbe ddeciidedd sooon.我认认为,CC+的的额外开开支只是是使用更更好的语语言的小小付出。同同样的争

23、争论发生生在六十十年代高高级程序序语言如如COBBOL和和FORRTRAAN开始始取代汇汇编成为为语言所所选的时时候。批批评家正正确的指指出使用用高级语语言编写写的程序序天生就就比手写写的汇编编语言来来得慢,而而且必然然如此。而而高级语语言支持持者认为为这么点点小小的的性能损损失是值值得的,因因为COOBOLL和FOORTRRAN程程序更容容易编写写和维护护。Inn myy oppiniion, thhe ooverrheaad oof CC+ is simmplyy thhe ppricce yyou payy foor aa beetteer llangguagge. Thiis ssam

24、ee deebatte wwentt onn inn thhe 660ss whhen higgh-lleveel pproggrammminng llangguagges likke CCOBOOL aand FORRTRAAN sstarrtedd too diispllacee haand-codded asssembbly as thee laanguuagee off chhoicce. Criiticcs ccorrrecttly poiinteed oout thaat pproggramms wwritttenn inn hiigh-levvel lannguaagess we

25、ere inhhereentlly sslowwer thaan hhandd-tuunedd asssemmblyy annd aalwaays wouuld be. Hiigh-levvel lannguaage advvocaatess poointted outt, hhoweeverr, tthatt thhe ssligght perrforrmannce hitt waas wwortth iit bbecaausee COOBOLL annd FFORTTRANN prrogrramss weere mucch eeasiier to wriite andd maainttai

26、nn.优点点:组织织大型程程序时比比C语言言好得多多。很好好的支持持面向对对象机制制。通用用数据结结构,如如链表和和可增长长的阵列列组成的的库减轻轻了由于于处理低低层细节节的负担担。Addvanntagges: Muuch bettterr thhan C ffor orgganiizinng llargge pproggramms. Suppporrts thee obbjecct-oorieenteed pparaadiggm nniceely. Liibraariees oof ccommmon datta sstruuctuuress, llikee liinkeed llistts

27、aand groow-aablee arrrayys, cann reemovve mmuchh off thhe bburdden of havvingg too deeal witth llow-levvel dettaills. 缺点点:非常常大而复复杂。与与C语言言一样存存在语法法滥用问问题。比比C慢。大大多数编编译器没没有把整整个语言言正确的的实现。Diisaddvanntagges: Exxtreemelly llargge aand commpliicatted. Liike C, thee syyntaax llendds iitseelf to abuuse. Caan bb

28、e sslowwer thaan CC. NNot manny ccomppileers impplemmentt thhe eentiire lannguaage corrrecctlyy.移植植性:比比C语言言好多了了,但依依然不是是很乐观观。因为为它具有有与C语语言相同同的缺点点,大多多数可移移植性用用户界面面库都使使用C+对象象实现。Poortaabillityy: BBettter thaan CC, bbut stiill nott grreatt. WWhille iit ssharres thee saame dissadvvanttagee ass C, moost of t

29、hee poortaablee usser-intterffacee liibraariees aare impplemmentted as colllecctioons of C+ obbjeccts.使用用C+编写的的游戏:非常非非常多。大大多数的的商业游游戏是使使用C或或C+编写的的。Gaamess Wrrittten in C+: LLotss annd llotss. AAlmoost alll coommeerciial gammes aree wrrittten in C oor CC+.资料料:最新新版的TThe C+ Prrogrrammmingg Laanguuagee非常

30、常好。作作为教程程,有两两个阵营营,一个个假定你你知道CC,另外外一个假假定你不不知道。到到目前为为止,最最好的CC+教教程是WWhos AAfraaid of C+,如如果你已已经熟知知C,那那么试一一下TTeacch YYourrsellf CC+。Reesouurcees: Thee laatesst eedittionn off Thhe CC+ Proograammiing Lannguaage is exccelllentt. AAs ffor tuttoriialss, ttherre aare twoo caampss, ooness thhat asssumee yoou k

31、knoww C, annd ooness yoou ddont. By farr thhe bbestt grrounnd-uup CC+ tuttoriialss arre WWhos AAfraaid of C+ annd WWhos AAfraaid of Morre CC+. Iff yoou aalreeadyy knnow C, tryy Teeachh Yooursselff C+.3、我该该学习CC+或或是该从从C开始始(Shhoulld II leearnn C+, or shoouldd I staart witth CC )我不不喜欢这这种说法法,但它它是继“我该使使用哪

32、门门语言”之后最最经常被被问及的的问题。很很不幸,不不存在标标准答案案。你可可以自学学C并使使用它来来写程序序,从而而节省一一大堆的的时间,不不过使用用这种方方法有两两个弊端端:I thooughht tthiss boore menntiooninng, as its tthe seccondd moost commmonnly askked queestiion nexxt tto whiich proograammiing lannguaage shoouldd I usee?UUnfoortuunattelyy, tthe ansswerr issntt bllackk annd ww

33、hitte. Youu coouldd saave a llot of timme bby jjustt teeachhingg yooursselff C andd wrritiing appps, butt thheree arre ttwo dissadvvanttagees tto tthiss appprooachh. 你将错过过那些面面向对象象的知识识,因为为它可能能在你的的游戏中中使得数数据建模模更有效效率的东东西。Youre misssinng oout on whaat wwilll liikelly bbe aa muuch morre eeffeectiive wayy

34、off moodellingg thhe ddataa inn yoour gamme. By nott leearnningg OOO prrogrrammmingg offf tthe batt, yyou couuld be enfforccingg baad pproggrammminng hhabiits thaat yyoull havve tto uun-llearrn llateer. Truust me on thiis oone.最大的商商业游戏戏,包括括第一人人称射击击游戏很很多并没没有使用用C+。但是是,这些些程序的的作者即即使使用用老的CC的格式式,他们们通常坚坚持使

35、用用面向对对象编程程技术。如如果你只只想学CC,至少少要自学学OO(面面向对象象)编程程技术。OOO是仿仿真(游游戏)的的完美方方法,如如果你不不学习OOO,你你将不得得不“辛苦”的工作作。Manyy off thhe bbigggestt coommeerciial gammes, inncluudinng mmostt fiirstt-peersoon sshoooterrs, gett byy wiithoout C+. TThe autthorrs oof tthesse pproggramms, howweveer, alwwayss innsisst tthatt thheyre

36、usiing objjectt-orrienntedd prrogrrammmingg teechnniquues eveen tthouugh theeyrre uusinng pplaiin oold C. If youu waant to jusst llearrn CC, aat lleasst tteacch yyourrsellf OOO pproggrammminng ttechhniqquess. OOO iis tthe perrfecct mmethhodoologgy ffor simmulaatioons (reead: gaamess), andd yooulll r

37、reallly be doiing it thhe hhardd waay if youu puush offf leearnningg OOO. 4、汇编编语言(AAsseemblly)显然然,汇编编是第一一个计算算机语言言。汇编编语言实实际上是是你计算算机处理理器实际际运行的的指令的的命令形形式表示示法。这这意味着着你将与与处理器器的底层层打交道道,比如如寄存器器和堆栈栈。如果果你要找找的是类类英语且且有相关关的自我我说明的的语言,这这不是你你想要的的。Byy deefauult, asssemmblyy waas tthe firrst commputter lannguaage. As

38、ssemmblyy laanguuagee iss acctuaallyy a commmannd-bbaseed rreprreseentaatioon oof tthe acttuall innstrructtionns tthatt yoour commputters pproccesssor runns. Thaat mmeanns yyou willl bbe ddeallingg wiith thee loow-lleveel ddetaailss off yoour proocesssorr, llikee reegissterrs aand staackss. IIf yyou

39、re loookinng ffor a llangguagge tthatts Engglissh-llikee annd iis rrelaativvelyy seelf-doccumeentiing, thhis isnnt it!确切切的说,任任何你能能在其他他语言里里做到的的事情,汇汇编都能能做,只只是不那那么简单单 这是是当然,就就像说你你既可以以开车到到某个地地方,也也可以走走路去,只只是难易易之分。话话虽不错错,但是是新技术术让东西西变得更更易于使使用。Byy deefinnitiion, annythhingg yoou ccan do in anyy ottherr laan

40、guuagee, yyou cann doo inn asssemmblyy, oonlyy noot aas eeasiily -oof ccourrse, thhats llikee saayinng tthatt annywhheree yoou ccan go in a ccar, yoou ccan go on fooot, onlly nnot as eassilyy. WWhille tthe staatemmentt miightt bee trrue, thhe llateer ttechhnollogiies madde tthinngs mucch eeasiier to

41、 usee.总的的来说,汇汇编语言言不会在在游戏中中单独应应用。游游戏使用用汇编主主要是使使用它那那些能提提高性能能的零零零碎碎的的部分。比比如说,毁毁灭战士士整体使使用C来来编写,有有几段绘绘图程序序使用汇汇编。这这些程序序每秒钟钟要调用用数千次次,因此此,尽可可能的简简洁将有有助于提提高游戏戏的性能能。而从从C里调调用汇编编写的函函数是相相当简单单的,因因此同时时使用两两种语言言不成问问题。Inn geenerral, asssemmblyy laanguuagee iss noot uusedd onn itts oown forr gaamess. GGamees tthatt uss

42、e aasseemblly llangguagge uuse it in bitts aand pieecess whheree itt caan iimprrovee peerfoormaancee. FFor exaamplle, DOOOM iis wwritttenn enntirrelyy inn C witth aa coouplle oof ddrawwingg rooutiiness haand-codded in asssembbly. Thhey aree thhe rrouttinees tthatt arre ccallled a ffew thoousaand tim

43、mes a ssecoond, soo maakinng tthe rouutinne aas ttighht aas pposssiblle rreallly hellpedd thhe pperfformmancce oof tthe gamme. Its ffairrly eassy tto wwritte aa fuuncttionn inn asssemmblyy thhat is calll-aablee frrom C, so usiing botth llangguagges wassntt a proobleem.特别别注意:语言的的名字叫叫“汇编”。把汇汇编语言言翻译成成真

44、实的的机器码码的工具具叫“汇编程程序”。把这这门语言言叫做“汇编程程序”这种用用词不当当相当普普遍,因因此,请请从这门门语言的的正确称称呼作为为起点出出发。Sppeciial Notte: Thee naame of thee laanguuagee iss aasseemblly. Thhe nnamee off thhe ttooll thhat connverrts asssembbly lannguaage intto ttruee maachiine codde iis ccallled an asssemmbleer. Itts a ccommmon missnommer to c

45、alll tthe lannguaage asssemmbleer, soo sttartt ouut oon tthe rigght fooot bby ccalllingg thhe llangguagge bby iits prooperr naame.优点点:最小小、最快快的语言言。汇编编高手能能编写出出比任何何其他语语言能实实现的快快得多的的程序。你你将是利利用处理理器最新新功能的的第一人人,因为为你能直直接使用用它们。Addvanntagges: Iss, bby ddefiinittionn, tthe smaalleest andd faasteest lannguaage.

46、A tallentted asssembbly proograammeer ccan wriite proograams thaat aare fassterr thhan anyythiing thaat ccan be donne iin ootheer llangguagges. Yooulll bbe tthe firrst perrsonn too bee abble to takke aadvaantaage of thee prroceessoorss laatesst nnew feaaturres, beecauuse youu caan uuse theem ddireectlly.缺点点:难学学、语法法晦涩、坚坚持效率率,造成成大量额额外代码码 不适适于心脏脏虚弱者者。Diisaddvanntagges: Diiffiicullt tto llearrn, cryyptiic ssynttax, tooughh too doo effficcienntlyy, aand it takkes mucch mmoree coode to gett soometthinng ddonee -nott foor tthe faiint of heaart!

展开阅读全文
相关资源
相关搜索

当前位置:首页 > 管理文献 > 管理制度

本站为文档C TO C交易模式,本站只提供存储空间、用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。本站仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知得利文库网,我们立即给予删除!客服QQ:136780468 微信:18945177775 电话:18904686070

工信部备案号:黑ICP备15003705号-8 |  经营许可证:黑B2-20190332号 |   黑公网安备:91230400333293403D

© 2020-2023 www.deliwenku.com 得利文库. All Rights Reserved 黑龙江转换宝科技有限公司 

黑龙江省互联网违法和不良信息举报
举报电话:0468-3380021 邮箱:hgswwxb@163.com