Sunteți pe pagina 1din 3

using using using using using using using using using using

Syste m; Syste m.Col lect ions.Gener ic ; Syste m.Linq; Microsoft .Xna.Fra m e work; Microsoft .Xna.Fra m e work.Audio; Microsoft .Xna.Fra m e work.Content; Microsoft .Xna.Fra m e work.Ga m erServices; Microsoft .Xna.Fra m e work.Gra !ics; Microsoft .Xna.Fra m e work. "n ut; Microsoft .Xna.Fra m e work.Media;

na m es ace G a m e#ro$ect % & & & 'su m m ary ( & & & )!is i s t!e m ain ty e for your ga m e & & & '&su m m ary ( u*l ic class G a m e+ , Microsoft .Xna.Fra me work.G a m e % Gra !ics-evice Manager gra !ics; S r i te.atc! s r i te.atc!; const int /" 0 - 1 /2 /"-)3 4 566; const int /" 0 - 1 /2 37"G3) 4 866; 9ando m rand 4 ne w 9ando m :; ; & & ga m e state G a m eState ga m eState 4 G a m eState.Menu; & & "ncre ment +, o ening screen f ie lds )e<ture=- o eningscreen; 9ectangle dra w9ectangle1 eningscreen; & & "ncre ment =, t!e *oard 0u m *er.oard currentGa m e 0u m *er.oard; & &audio co m onents Audio7ngine audio7ngine; / ave.ank w ave.ank; Sound.ank sound.ank; % u*l ic G a m e+:; gra !ics 4 ne w Gra !ics-evice Manager: t!is; ; Content.9oot-irectory 4 >Content>; & & "ncre ment +, set windo w resolut ion gra !ics.#referred.ack.uffer /idt! 4 /" 0 - 1 /2 /"-) 3; gra !ics.#referred.ack.uffer3eig!t 4 /" 0 - 1 /2 37"G3); & & "ncre ment +, m ake t!e m o use vis i* le "sMouse?is i* le 4 t rue;

& & & 'su m m ary ( & & & Al lows t!e ga m e to erfor m any in i t ia l iAat ion i t needs to *efore start ing to run. & & & )!is i s w !ere i t can query for any required services and load any nonBgra !ic & & & re lated content. Cal l ing *ase. "n i t ia l iAe wil l enu m erate t!roug! any co m onents & & & and in i t ia l iAe t!e m as w el l . & & & '&su m m ary ( rotected overr ide void "n i t ia l iAe:;

% @ *ase. "n i t ia l iAe:; ;

& & & 'su m m ary ( & & & LoadContent wil l *e cal led once er ga m e and is t!e lace to load & & & al l of your content. & & & '&su m m ary ( rotected overr ide void LoadContent:; % & & Create a ne w S r i te.atc!C w !ic! can *e used to dra w te<tures. s r i te.atc! 4 ne w S r i te.atc!:Gra !ics-evice;; & & load audio content audio7ngine 4 ne w Audio7ngine:D > ContentEsounds.<gs>; ; w ave.ank 4 ne w / ave.ank:audio7ngineC D > ContentE/ave .ank.<w*>; ; sound.ank 4 ne w Sound.ank:audio7ngineC D > ContentESound .ank.<s*>; ; & & "ncre ment +, load o ening screen and set o ening screen dra w rectangle o eningscreen 4 Content.Load ' )e<ture=-(:>o eningscreen>; ; dra w9ectangle1 eningscreen 4 ne w 9ectangle:6C 6C gra !ics.#referred.ack.uffer /idt!C gra !ics.#referred.ack.uffer3eig!t; ; & & "ncre ment =, create t!e *oard o*$ect :t!is wil l *e m oved *efore youFre done wit! t!e ro$ect; StartGa m e:; ; @ & & & 'su m m ary ( & & & GnloadContent wil l *e cal led once er ga m e and is t!e lace to unload & & & al l content. & & & '&su m m ary ( rotected overr ide void GnloadContent:; % & & )1 - 1, Gnload any non ContentManager content !ere @ & & & 'su m m ary ( & & & Al lows t!e ga m e to run log ic suc! as u dating t!e w orldC & & & c!ecking for col l is ionsC gat!er ing in utC and laying audio. & & & '&su m m ary ( & & & ' ara m na m e 4>ga m e)i me> ( #rovides a sna s!ot of t iming values.'& ara m ( rotected overr ide void G date:G a m e)i me ga m e)i me; % & & Al lows t!e ga m e to e<it i f :G a m e#ad.GetState:#layer"nde<.1ne;..uttons..ack 4 4 .uttonState.#ressed H H Iey*oard.GetState:; . "sIey-o wn:Ieys.7sca e;; t! is.7<it :; ; & & "ncre ment =, c!ange ga m e state i f ga m e state is G a m eState.Menu and user resses 7nter i f :ga m eState 4 4 G a m eState.Menu J J Iey*oard.GetState:; . "sIey-o wn:Ieys.7nter;; % ga m eState 4 G a m eState.# lay; @ & &i f w eFre actual ly layingC u date m o use state and u date *oard i f :ga m eState 4 4 G a m eState.# lay; % *ool correctGuess 4 currentGa m e 0u m *er.oard.G date:ga m e)i meC M ouse.GetState:;; ; i f :correctGuess;

% sound.ank.# layCue:>ne w Ga m e>; ; StartGa m e:;; @ @ *ase.G date:ga m e)i me;; @ & & & 'su m m ary ( & & & )!is i s cal led w !en t!e ga m e s!ould dra w i tsel f . & & & '&su m m ary ( & & & ' ara m na m e 4>ga m e)i me> ( #rovides a sna s!ot of t iming values.'& ara m ( rotected overr ide void -ra w:G a m e)i me ga m e)i me; % Gra !ics-evice.Clear:Color.Cornf lower.lue;; & & "ncre ments + and =, dra w a ro r iate i te ms !ere s r i te.atc!..egin:; ; i f :ga m eState 4 4 G a m eState.Menu; % s r i te.atc!.-raw:o eningscreenC dra w9ectangle1 eningscreenC Color./!ite; ; @ else i f :ga m eState 4 4 G a m eState.# lay; % currentGa m e 0u m *er.oard.-raw:s r i te.atc!;; @ s r i te.atc!.7nd:; ; *ase.-raw:ga m e)i me;; @ & & & 'su m m ary ( & & & Starts a ga m e & & & '&su m m ary ( void StartGa m e:; % & & rando mly generate ne w nu m *er for ga m e int correct0u m *er 4 rand.0e<t:+C +6;; & & create t!e *oard o*$ect : t! is wil l *e m oved *efore youFre done; currentGa m e 0u m *er.oard 4 ne w 0u m *er.oard:ContentC ne w ?ector=:gra !ics.#referred.ack.uffer /idt! & =C gra !ics.#referred.ack.uffer3eig!t & =;C :int; :gra !ics.#referred.ack.uffer3eig!t K 6.5;C correct0u m *erC sound.ank;; @ @ @

S-ar putea să vă placă și