Close
Faqja 2 prej 2 FillimFillim 12
Duke shfaqur rezultatin 11 deri 20 prej 20
  1. #11
    Programues Softueresh Maska e edspace
    Anėtarėsuar
    04-04-2002
    Vendndodhja
    Filadelfia, SHBA
    Postime
    2,565
    Ke bere goxha pune deri tani jo vetem ne dizajn por edhe ne kod.

    Hollesite e dizajnit po ti le ty ti ndertosh sipas qejfit. Ka plot lojra e filma qe mund ti marresh si shembuj por edhe imagjinaten e paske te mire.

    Ne lidhje me sendet qe gjenden neper dhoma e ke filluar mire me klasen Item.
    isTake() ndryshoje ne canTake().

    Mendimi im eshte qe ne cdo dhome te kesh nje numer te caktuar sendesh. Disa sende mund ti marrresh pa kushte, disa mund ti marresh vetem nqs ben dicka tjeter (psh vret rojen qe ti marresh celsin), dhe disa sende te tjera nuk mund ti marresh por duhet ti perdoresh (qeni, ushtari, mbreti) qe te vesh ne nje dhome tjeter.

    Gjithashtu disa hyrje mund te lejohen pa kushte ndersa disa te tjera jane me kushte si psh:
    - per dhomen e princeshes duhet celesi
    - per te marre celsin duhet te vrasesh mbretin/rojen

    Pra duhet te lidhim sendet dhe daljet/hyrjet me dhomen.

    Deri tani ti ke krijuar nje liste te daljeve por nuk kemi vene kushte per to.
    Mendimi im eshte metoda setExit() te kete emrin e dhomes por edhe nje boolean per kushtin.

    Kodi:
     public void setExit(Room soused, boolean kusht) {
            exits.add(soused);
            kushtet.add(soused); //vendosim kusht
     }
    
    //shikojme nqs ka pengesa/kushte apo jo
     public boolean kakusht(Room soused) {
            return kushtet.contains(soused);
     }
    Pra, pervec listes (set) se dhomave, do krijojme edhe nje liste te dhomave qe kane kushte. Kur personi do doje te shkoje ne nje dhome te caktuar, do shikojme nqs ajo dhome egziston dhe nqs ka kusht apo jo. Nqs nuk ka kusht do ta lejojme lojtarin te kaloje. Nqs ka kusht, do ti themi qe ajo dhome ka pengesa dhe ai pastaj duhet te plotesoje kushtet.

    Ja kodi i komandes go ne klasen game().
    Kodi:
     private void goRoom(Command command) {
            if (!command.hasSecondWord()){
                // if the second word is missing, then...
                System.out.println("Go where?");
                return;
            }
    
            String direction = command.getSecondWord();
    
            // try to go into the next room
            Room nextRoom = currentRoom.nextRoom(direction);
    
            if (nextRoom == null) {
                System.out.println("I can't go this way!");
            }
            else if(currentRoom.kakusht(nexRoom)){
            	System.out.println("Kjo dhome ka pengesa.");
            }
            else {
                currentRoom = nextRoom;
                System.out.println(currentRoom.longDescription());
            }
        }

    Deri tani kemi nje liste te objekteve ne dhome, kemi dhe nje liste te dyerve qe kane kushte. Na duhet nje menyre qe objektet te nderveprojne me njeri tjetrin dhe te mund te ndryshojne dhomen, duke shtuar nje objekt te ri (psh celesin), duke ndryshuar nje objekt tjeter ne dhome, ose duke hapur dyert.

    psh: Kur qenin e genjejme me mishin, ai thjesht do largohet dhe ne do kemi plotesuar kushtet per te futur ne dhome. kushtet.remove(dhoma)
    Kur perdorim shpaten kunder nje ushtari, ai mund te shtoje nje objekt te ri ne dhome, celesin. Lojtari pastaj duhet te marre celesin dhe te hape deren.

    Lojtarit i kemi dhene te drejten per te marre dicka nga dhoma por duhet ti japim edhe mundesine te perdore nje nga sendet qe ka ne torbe si ne shembujt me lart.

    Kete mund ta bejme me komanden:
    perdor emri_i_sendit
    anglisht: use item_name

    Kur te shtypet kjo komande ne do shikojme ne radhe te pare, nqs e ka kete send apo jo. Nqs se e ka, do therasim funksionin perdor() ne klasen game.

    Kodi:
    private void perdor(Item send){
    if( player.zoteron(send) ){
             
    	if( currentRoom.getName() == "obori"){
    		if( send.getName() == "mish" ){
    			currentRoom.removeItem("qeni"); //heqim qenin
                                                    player.hiqngacanta("mish"); 
    			currentRoom.hiqKushtin("stalla"); //lejojme hyrjen ne stalle
    			System.out.println("Qeni po ha mishin");
    
    		}
    		if( send.getName() == "shpata" ){
    			currentRoom.removeItem("roja"); //vrasim rojen
    			currentRoom.saveItem("celesi"); //ai leshon celesin
    			System.out.println("Vrave rojen, i ra dicka nga xhepi");
    		}
    	}
    	else if( currentRoom.getName() == "stalla"){	
    	// vazhdo ketu me sendet qe ndryshojne dicka
    	
    	}
    	else if( currentRoom.getName() == "dhoma e princeshes"){	
    	// vazhdo ketu me sendet qe ndryshojne dicka	
    	}
    }
    }
    Funksionin removeItem ti me duket e ke quajtur selectItem.
    Funksioni hiqKushtin eshte i ngjashem me removeItem. Do shikosh listen e sendeve (itemlist) dhe do gjesh sendin ka te njejtim emeri si argumenti i funksionit dhe do ta heqesh nga set ose map.

    Funksioni perdor() do jete i gjate sepse do kete kodin per te gjitha dhomat. Sa here qe personi shtyp komanden perdor send ti do ti dergosh sendin ketij funksioni dhe funksioni duke u bazuar mbi currentRoom do shikoje se cfare efektesh ka ai send. Lojtari mund te duhet te perdore disa sende para se te hapet dera e nje dhome tjeter. Mos harro qe ti heqesh sendet nga canta pasi perdoren. Disa sende si celesi ose mishi mund te perdoren vetem njehere dhe do ti heqesh nga canta, ndersa sende te tjera si shpata mund te jene gjithnje ne cante.


    Ketu ke dhe klasen e lojtarit.
    Kodi:
    import java.util.Set;
    import java.util.HashSet;
    import java.util.Iterator;
    
    class Player {
    	
        private String _name;
        private int _piket; 
        private Set _bag; 
        
        public Player(String name) {
            _name = name;
            _piket = 0;
            _bag = new HashSet();
        }
        
        //shto shumen
        public void shto_piket(int shuma){
        	_piket += shuma;
        }
        
        //kthe piket
        public int merr_piket(){
        	return _piket;
        }
        
        public void hiqngacanta(String name){
    	    Iterator iter = _bag.iterator();
    	    while (iter.hasNext()) {
    			Item smth = (Item)iter.next();
    			if (smth.getName().equals(name)) {
    			    _bag.remove(smth);  // heq objektin e zgjedhur nga koleksioni
    			    break;
    			}
          	}
          	
        }
        
        public void hidhnecante(Item smth) {
         	_bag.add(smth);
    	}
    }
    Te thashe qe nuk jam njohur mire me sintaksen e Java dhe do kete ndonje gabim se nuk kisha kohe ta testoja.
    Ndryshuar pėr herė tė fundit nga edspace : 07-10-2004 mė 15:53
    Edi

  2. #12
    ...gjenķ... Maska e mad
    Anėtarėsuar
    18-03-2004
    Vendndodhja
    Prage [EU]
    Postime
    1,321
    Edi, te lumshin dockat!
    rrofsh per pjeset e futura!

    e keqja ime eshte se JBlue, i cili eshte me lehte per te hapur lojen, te pakten deri ne kete gjendje, mund ta perdor vetem ne lab e shkolles. do postoj shume shpejt te gjithe klasat, me shprese qe te na mbaje koha!
    Mos u be merak, se gabime nuk ke bere. vetem se do ndryshoje emertimin e variablave, se ne Java nuk para perdoret simboli "_", te pakten ashtu si na e kerkojne keta neve, sipas konventes!

    Edhe nje here shume faleminderit, dhe se shpejti atehere!
    R E S P E K T E
    {^_^}
    ::|maDes!gn © 2009|::

  3. #13
    Programues Softueresh Maska e edspace
    Anėtarėsuar
    04-04-2002
    Vendndodhja
    Filadelfia, SHBA
    Postime
    2,565
    Une perdor JCreator. Kane edhe nje version LITE falas dhe per keto pak dite qe e kam perdorur me duket i shkelqyer; shume i lehte per tu perdorur. Eshte si Visual Studio per Java. Po te duhet, merre ketu http://www.jcreator.com/download.htm

    Per nenvizen _ e variablave jam mesuar qe i perdor ne klasat e C++ per te treguar qe ato variabla jane private. Java e lejon perdorimin e tyre por sot lexova se nuk rekomandohen dhe nuk japin arsye pse. Nejse, ceshtje preferencash.
    Edi

  4. #14
    ...gjenķ... Maska e mad
    Anėtarėsuar
    18-03-2004
    Vendndodhja
    Prage [EU]
    Postime
    1,321

    Exclamation

    pershendetje te gjithe forumistave!@
    edhe Edit, gjithashtu!

    une po attach .zip, me kerkesen e lojes. dmth me shpjegimin zyrtar te lojes.

    nqs eshte e mundur, ne baze te sourcecode-it, qe do te attach ne postimin tjeter, te futen kodet qe kam postuar une, dhe ti gjithashtu, aty ku duhen, se me eshte bere nje lemsh, dhe nuk me kompilohet ne nje pike. kodi qe do te postoj, eshte i kompilueshem dhe i perdorshem, vetem se ska perfundim, dmth kushtet, sendet, objektet, personazhet per te cilet kemi folur me lart. tekstet e tutorialeve thone qe eshte me mire ta kesh programin te ndare ne *.class te vecanta dhe ti gruposh ne nje arkiv, po mua me duket pak si e hallakatshme.
    me mire kur i ke aty ne nje faqe, edhe kompilimi dhe kontrollimi dhe korigjimi behen me kollaj! nejse, se llafet e shumta jane fukarallek. shpresoj te degjoj....dmth, te lexoj shpejt nga ju! mos pertoni te pyesni!

    {^_^}
    Skedarėt e Bashkėngjitur Skedarėt e Bashkėngjitur
    ::|maDes!gn © 2009|::

  5. #15
    Programues Softueresh Maska e edspace
    Anėtarėsuar
    04-04-2002
    Vendndodhja
    Filadelfia, SHBA
    Postime
    2,565
    Madi,

    I bashkova te gjitha pjeset e kodit qe shkruajtem ne forum dhe shtova disa pjese te tjera qe i diskutuam me lart por nuk ishin programuar.

    Tani jo vetem qe mund te levizesh neper dhoma, por mund te marresh edhe objekte te ndryshme nga nje dhome ne tjetren, dhe ti perdoresh ato kur e shikon te nevojshme. Per te marre nje objekt perdor komanden take objekt ndersa per ta perdorur perdor komanden use objekt. use e kam programuar vetem per dhomen ku ka pengesa (qeni dhe roja) dhe nuk mund te shkosh me tej pa hequr pengesat. Ne rastin e qenit duhet ti japesh mishin (use Meat) ndersa rojes duhet ti presesh koken (use Sword), e ti marresh celsin. Mund ta shtosh vete kodin per perdorimin e objekteve ne dhomat e tjera nqs e shikon te nevojshme dhe do te veshtiresosh lojen.

    Te gjitha funksionet kryesore jane mbaruar, po ashtu edhe llogjika elementare. Bej ndonje pastrim te vogel ne kod dhe shto pjese te tjera per ta bere lojen me interesante dhe me te veshtire.

    Hidh nje kopje te kodit mundesisht ne Shqip edhe Anglisht kur ta mbarosh.
    Te pakten hidh nje kopje me disa komente ne Shqip qe te mund ta kuptojne te gjithe.

    Kodin e perpilova me Java 1.5.0 ne JCreator.
    Skedarėt e Bashkėngjitur Skedarėt e Bashkėngjitur
    Edi

  6. #16
    ...gjenķ... Maska e mad
    Anėtarėsuar
    18-03-2004
    Vendndodhja
    Prage [EU]
    Postime
    1,321
    Edi, te lumshin duart vella, si gjithmone!

    Une prap kam ca pyetje:

    a) E ke luajtur lojen ti vete? dmth, a e provove ta luash?

    dhe

    b) ka disa metoda dhe deklarime psh. ne klasen Player, qe nuk perdoren ne asnje moment te lojes. si psh int piket; ose public int merrPiket ?

    provoj ta kompiloj kodin, edhe pa keta nuk ka gabime sintaksore! dmth, JVM nuk gjen gabime ne kod.

    nejse, jam duke shtuar komentet ne anglisht, te cilat do ti kthej edhe ne shqip dhe do ti postoj ketu te dyja versionet!

    rrofsh

    {^_^}
    ::|maDes!gn © 2009|::

  7. #17
    Programues Softueresh Maska e edspace
    Anėtarėsuar
    04-04-2002
    Vendndodhja
    Filadelfia, SHBA
    Postime
    2,565
    Loja perpilohet dhe luhet pa problem. Nga ato sa thame me lart, vetem piket nuk jane programuar por funksionet i ke gati ti perdoresh. Vendos ti se si do shperblesh lojtarin dhe shto dy-tre rreshta kod me shume.

    Me poshte ke nje log te lojes.
    Shkoj ne stalle dhe marr kalin
    Shkoj ne kuzhine te marr mishin
    Shkoj ne Sallon dhe i jap qenit mishin qe te futem ne rrugen e shkurter.
    Shkoj tek princesha dhe e hipi ne kale (mbaron loja)

    Do jap ca komanda te gabuara per te testuar qe loja punon sic duhet.

    --------------------------------------------------------------------------------------------

    Welcome to Koon!
    Koon is a new, incredibly boring adventure game.
    Type 'help' if you need help.

    You are in the middle of the bridge. Cross it over and go toward the castle!.
    Exits: courtyard
    > go courtyard
    You are in the yard of the castle.
    Exits: bridge mainhall stable
    You see:
    > go stable
    You are in stable. The horseman might have something interesting for you!.
    Exits: courtyard
    You see: Horse Sword
    > take Horse
    You now have the Horse
    > take Sword
    You now have the Sword
    > take Sword
    There is no item with that name.
    > take Horse
    There is no item with that name.
    > take Dog
    There is no item with that name.
    > Take dog
    I don't know what you mean...
    > test test test
    I don't know what you mean...
    > help
    You are on a wandering, in the wild Fanghorn Forest.
    You are looking for a castle, The Dark Warlord's Castle.
    Your mission is to get to the highest room, in the highest
    tower, so u can save the Princess of Noland

    You find your way out of the Forest, look for a bridge
    Your command words are:
    go quit use take help
    You are in stable. The horseman might have something interesting for you!.
    Exits: courtyard

    > go courtyard
    You are in the yard of the castle.
    Exits: bridge mainhall stable
    You see:
    > go mainhall
    You are in the entrance of the castle, which takes you inside!.
    Exits: stair1 courtyard kitchen
    You see:
    > go kitchen
    You are in the kitchen, where the servants used to work (better check in there!)
    .
    Exits: mainhall
    You see: Towel Meat
    > take Towel
    You now have the Towel
    > take Towel
    There is no item with that name.
    > take meat
    There is no item with that name.
    > take Meat
    You now have the Meat
    > go mainhall
    You are in the entrance of the castle, which takes you inside!.
    Exits: stair1 courtyard kitchen
    You see:
    > go stair2
    I can't go this way!
    > go home
    I can't go this way!
    > go stair1
    You are in the stairway that takes you to the 2nd floor!.
    Exits: stair2 lounge mainhall
    You see:
    > go lounge
    You are in the place where the treasuries of the Dark Warlord are kept(look in!)
    .
    Exits: stair1 shortcut
    You see: Hellhound
    > use Towel
    You would be a nice meal for a hungry hellhound
    > use Sword
    You would be a nice meal for a hungry hellhound
    > use Meat
    Nice distraction! This is your chance.
    > go shortcut
    You are in for the hidden and shorter way to win the game!.
    Exits: cell lounge
    You see:
    > go cell
    You are in the place where the princess is locked!.
    Exits: tower
    You see: Princess
    Congratulations champion. Take her away.
    > use Sword
    Put that down. You're scaring her.
    > use Meat
    You don't have the Meat
    > use Horse
    ...and they lived happily thereafter.
    > quit
    Thank you for playing. See you

    Press any key to continue...

    -----------------------------------------------------------------------------

    Me poshte ke menyren tjeter per te fituar lojen, duke vrare rojen.
    Shkoj ne stalle te marr shpaten dhe kalin
    Shkoj ne kullen e rojes
    Vras rojen dhe i marr celesin per birucen e Princeshes.
    E hipi princeshen ne kal dhe mbaron loja.


    -------------------------------------------------------------------------------


    Welcome to Koon!
    Koon is a new, incredibly boring adventure game.
    Type 'help' if you need help.

    You are in the middle of the bridge. Cross it over and go toward the castle!.
    Exits: courtyard
    > go courtyard
    You are in the yard of the castle.
    Exits: bridge mainhall stable
    You see:
    > go stable
    You are in stable. The horseman might have something interesting for you!.
    Exits: courtyard
    You see: Horse Sword
    > take Horse
    You now have the Horse
    > take Sword
    You now have the Sword
    > go courtyard
    You are in the yard of the castle.
    Exits: bridge mainhall stable
    You see:
    > go mainhall
    You are in the entrance of the castle, which takes you inside!.
    Exits: stair1 courtyard kitchen
    You see:
    > go stair1
    You are in the stairway that takes you to the 2nd floor!.
    Exits: stair2 lounge mainhall
    You see:
    > go stair2
    You are in the stairway that takes you to the highest floor of the castle!.
    Exits: stair1 tower
    You see:
    > go tower
    You are in highest level of the castle!.
    Exits: stair2 cell
    You see: Guard
    > go cell
    Kjo dhome ka pengesa.
    You see: Guard
    > go cell
    Kjo dhome ka pengesa.
    You see: Guard
    > use sword
    You don't have the sword
    > use Sword
    The guard is dead. He has something in his pocket.
    > take Key
    You now have the Key
    > use Key
    You unlocked the door. You might want to clean yourself up!
    > go stair2
    You are in the stairway that takes you to the highest floor of the castle!.
    Exits: stair1 tower
    You see:
    > go stair1
    You are in the stairway that takes you to the 2nd floor!.
    Exits: stair2 lounge mainhall
    You see:
    > go mainhall
    You are in the entrance of the castle, which takes you inside!.
    Exits: stair1 courtyard kitchen
    You see:
    > go kitchen
    You are in the kitchen, where the servants used to work (better check in there!)
    .
    Exits: mainhall
    You see: Towel Meat
    > take Towel
    You now have the Towel
    > go mainhall
    You are in the entrance of the castle, which takes you inside!.
    Exits: stair1 courtyard kitchen
    You see:
    > go stair1
    You are in the stairway that takes you to the 2nd floor!.
    Exits: stair2 lounge mainhall
    You see:
    > go stair2
    You are in the stairway that takes you to the highest floor of the castle!.
    Exits: stair1 tower
    You see:
    > go tower
    You are in highest level of the castle!.
    Exits: stair2 cell
    You see:
    > use Towel
    Good enough. Don't make her wait any longer.
    > go cell
    You are in the place where the princess is locked!.
    Exits: tower
    You see: Princess
    Congratulations champion. Take her away.
    > take Princess
    You cannot take this object.
    > use Sword
    Put that down. You're scaring her.
    > use Horse
    ...and they lived happily thereafter.
    > quit
    Thank you for playing. See you soon. Good bye.

    Press any key to continue...
    Edi

  8. #18
    ...gjenķ... Maska e mad
    Anėtarėsuar
    18-03-2004
    Vendndodhja
    Prage [EU]
    Postime
    1,321
    edi, te lutem, si e hape lojen, se meka ik petlla. deri tani e kam provu me te gjitha programet e mundshme, por prap spo e hap dot. nuk me mblidhen .class me njeri-tjetrin.

    {^_^}
    ::|maDes!gn © 2009|::

  9. #19
    Programues Softueresh Maska e edspace
    Anėtarėsuar
    04-04-2002
    Vendndodhja
    Filadelfia, SHBA
    Postime
    2,565
    Perdora JCreator Lite.
    Mund ta marresh falas ne adresen qe kam postuar me lart.
    Gjate instalimit tregoi se ku ke instaluar Java SDK.

    Hap JCreator,
    File > Open dhe hap te gjithe skedaren qe kam bashkengjitur.
    Hap faqen Zork1.java
    Nga menuja zgjidh Build > Compile File
    Pastaj Build > Execute File
    Edi

  10. #20
    ...gjenķ... Maska e mad
    Anėtarėsuar
    18-03-2004
    Vendndodhja
    Prage [EU]
    Postime
    1,321
    EDI, nuk kam fjale per te thene sa ndihme me ke dhene, dhe jo vetem mua, por te gjithe atyre qe kane filluar te marrin kete rruge! Shume shume rrofsh!

    se shpejti do te postoj nje tjeter program, i cili perdor funksionet grafike te Java-s!

    {^_^}
    ::|maDes!gn © 2009|::

Faqja 2 prej 2 FillimFillim 12

Regullat e Postimit

  • Ju nuk mund tė hapni tema tė reja.
  • Ju nuk mund tė postoni nė tema.
  • Ju nuk mund tė bashkėngjitni skedarė.
  • Ju nuk mund tė ndryshoni postimet tuaja.
  •