mdk137
Moldy Popcorn
Posts: 36
|
Post by mdk137 on May 9, 2007 10:24:15 GMT -5
I was working in a Adventure Text. Simple thing I imagined.
The player define which direction he/she would go (north, south, east, west) while randomly monstrous beings appear to kill and treasures for better score. kill, higher score, be killed, gameover.
However, when programming a little to define the direction appeared one strange bug, where the second shown line of screen was "cut to half".
Follows the problematic code below: --- CUT HERE ---- 'teste para um adventure. 'teresina. 07 de maio de 2007. 'atualização em 08 de maio de 2007. bugado.
'para o joystick dim ctrl as integer 'direção a seguir em português dim dir as string 'direção a seguir em inglês dim dir2 as string dir$ = "norte" dir2$ = "north" while 1 cls print " para onde voce vai? "; dir$ print " where you go? "; dir2$ ctrl=joypad(0)
'apertou para cima if ctrl.0 then waitpadup 0 dir$ = "norte" dir2$ = "north" endif 'apertou para esquerda if ctrl.2 then waitpadup 0 dir$ = "oeste" dir2$ = "west" endif 'apertou para baixo if ctrl.1 then waitpadup 0 dir$ = "sul" dir2$ = "south" endif 'apertou para direita if ctrl.3 then waitpadup 0 dir$ = "leste" dir2$ = "east" endif wend --- CUT HERE ---
Somebody knows as to solve this problem?
Sorry my english.
|
|
oompa loompa
I AM THE GOVERNATOR
"Git 'Er Dun!"
Posts: 1,301
|
Post by oompa loompa on May 13, 2007 19:42:22 GMT -5
i dunno, i'll come back to this later
maybe your program is executing cls twice - i haven't tested it, but using it twice is the only way i can see the genesis messing up. i might have fixed this in the latest version too
|
|
|
Post by jlf65 on May 13, 2007 23:48:10 GMT -5
Your code should do this instead at the start of the loop: update=1 while 1 if update then cls print " para onde voce vai? "; dir$ print " where you go? "; dir2$ update=0 endif
ctrl=joypad(0)
'apertou para cima if ctrl.0 then waitpadup 0 dir$ = "norte" dir2$ = "north" update=1 endif 'apertou para esquerda if ctrl.2 then waitpadup 0 dir$ = "oeste" dir2$ = "west" update=1 endif 'apertou para baixo if ctrl.1 then waitpadup 0 dir$ = "sul" dir2$ = "south" update=1 endif 'apertou para direita if ctrl.3 then waitpadup 0 dir$ = "leste" dir2$ = "east" update=1 endif wend You're constantly clearing and printing as fast as the loop can go... which can't be good for the display code used by cls/print.
|
|
mdk137
Moldy Popcorn
Posts: 36
|
Post by mdk137 on May 14, 2007 14:39:03 GMT -5
thanks a lot! I am working in the code with your tip and wait to have something to show briefly
|
|
mdk137
Moldy Popcorn
Posts: 36
|
Post by mdk137 on May 14, 2007 15:55:32 GMT -5
follows the modified code. The code grew to demonstrate more less or as it will be the game. I used the idea of jlf65 to reduce the tax of updates in the screen for acceptable levels. However still I did not reach one number adequate of updates. --- CUT HERE--- 'para o joystick dim ctrl as integer 'direção a seguir dim dir as string 'direção a seguir em inglês dim dir2 as string 'código para gerador encontros com mostros dim encontro as integer 'tipo de monstro encontrado dim monstro as string 'tipo de monstro encontrado em inglês dim monstro2 as string 'contador de tempo para o jogo e para a atualização de tela dim contador as integer dir$ = "norte" dir2$ = "north" monstro$ = "nada..." monstro2$ = "nothing..." contador=0 while 1 contador=contador+1 if contador=1000 then cls ink 1: print " para onde voce vai? "; dir$ print " where you go? "; dir2$ ink 2: print " Encontrou algo?... "; monstro$ print " Found something?... "; monstro2$ ink 0 contador=0 endif ctrl=joypad(0)
'apertou para cima if ctrl.0 then 'waitpadup 0 dir$ = "norte" dir2$ = "north" gosub evento endif 'apertou para esquerda if ctrl.2 then 'waitpadup 0 dir$ = "oeste" dir2$ = "west" gosub evento endif 'apertou para baixo if ctrl.1 then 'waitpadup 0 dir$ = "sul" dir2$ = "south" gosub evento endif 'apertou para direita if ctrl.3 then 'waitpadup 0 dir$ = "leste" dir2$ = "east" gosub evento endif wend
evento: randomize timer encontro=rnd(9) if encontro=0 then monstro$ = "nada..." monstro2$ = "nothing..." endif if encontro=1 then monstro$ = "um tesouro!" monstro2$ = "a treasure!" endif if encontro=2 then monstro$ = "um esqueleto!" monstro2$ = "a skeleton!" endif if encontro=3 then monstro$ = "um guerreiro!" monstro2$ = "a warrior!" endif if encontro=4 then monstro$ = "um mago!" monstro2$ = "a mage!" endif if encontro=5 then monstro$ = "um lobisomen!" monstro2$ = "a werewolf!" endif if encontro=6 then monstro$ = "um vampiro!" monstro2$ = "a vampire!" endif if encontro=7 then monstro$ = "um fantasma!" monstro2$ = "a ghost!" endif if encontro=8 then monstro$ = "um demonio!" monstro2$ = "a fiend!" endif if encontro=9 then monstro$ = "um metal gear!" monstro2$ = "a metal gear!" endif return
--- CUT HERE--- still lack elaborates codes for status (of the player and the monsters), to talk with npcs, inventory, combats among others things.
More work will come to decide this and to complete what it lacks.
|
|
|
Post by jlf65 on May 15, 2007 0:46:58 GMT -5
You're still clearing and printing every 1000 loops. If the code generated is pretty decent, that means you could still be trying to update the screen hundreds of times per second. Look at my code again - it only clears and prints on the first time into the loop, or when something changes.
|
|
mdk137
Moldy Popcorn
Posts: 36
|
Post by mdk137 on May 15, 2007 8:35:27 GMT -5
The proverb is correct. haste is enemy of the perfection. I desired to show something new quickly and I did not give right attention to your code. I revised the code again and I wait to have correctly implemented your tip. Follows the revised code below: --- CUT HERE---- 'para o joystick dim ctrl as integer 'direção a seguir dim dir as string 'direção a seguir em inglês dim dir2 as string 'código para gerador encontros com mostros dim encontro as integer 'tipo de monstro encontrado dim monstro as string 'tipo de monstro encontrado em inglês dim monstro2 as string 'contador de tempo para o jogo e para a atualização de tela dim contador as integer dir$ = "norte" dir2$ = "north" monstro$ = "nada..." monstro2$ = "nothing..." contador=1 while 1 if contador then cls ink 1: print " para onde voce vai? "; dir$ print " where you go? "; dir2$ ink 2: print " Encontrou algo?... "; monstro$ print " Found something?... "; monstro2$ ink 0 contador=0 endif ctrl=joypad(0) 'apertou para cima if ctrl.0 then 'waitpadup 0 dir$ = "norte" dir2$ = "north" contador=1 sleep 10 gosub evento endif 'apertou para esquerda if ctrl.2 then 'waitpadup 0 dir$ = "oeste" dir2$ = "west" contador=1 sleep 10 gosub evento endif 'apertou para baixo if ctrl.1 then 'waitpadup 0 dir$ = "sul" dir2$ = "south" contador=1 sleep 10 gosub evento endif 'apertou para direita if ctrl.3 then 'waitpadup 0 dir$ = "leste" dir2$ = "east" contador=1 sleep 10 gosub evento endif wend evento: randomize timer encontro=rnd(9) if encontro=0 then monstro$ = "nada..." monstro2$ = "nothing..." endif if encontro=1 then monstro$ = "um tesouro!" monstro2$ = "a treasure!" endif if encontro=2 then monstro$ = "um esqueleto!" monstro2$ = "a skeleton!" endif if encontro=3 then monstro$ = "um guerreiro!" monstro2$ = "a warrior!" endif if encontro=4 then monstro$ = "um mago!" monstro2$ = "a mage!" endif if encontro=5 then monstro$ = "um lobisomen!" monstro2$ = "a werewolf!" endif if encontro=6 then monstro$ = "um vampiro!" monstro2$ = "a vampire!" endif if encontro=7 then monstro$ = "um fantasma!" monstro2$ = "a ghost!" endif if encontro=8 then monstro$ = "um demonio!" monstro2$ = "a fiend!" endif if encontro=9 then monstro$ = "um metal gear!" monstro2$ = "a metal gear!" endif return ---CUT HERE---- Again, thanks for the aid.
|
|
|
Post by jlf65 on May 16, 2007 0:28:15 GMT -5
Looks better. One thing you could do to make the code more efficient is to move this to evento:
contador=1 sleep 10
Rather than do it in every if/then, just do it at the start of evento as evento is called for every condition.
|
|
mdk137
Moldy Popcorn
Posts: 36
|
Post by mdk137 on May 16, 2007 11:01:43 GMT -5
Thanks for last comment. I already added this last tip to the code and works perfectly.
Now I am working in the code for the monsters and the status of the player.
You have some suggestion concerning monsters to cut into pieces in a dark Dungeon? My ideias are imprisoned excessively to the bestiary of the D&D.
|
|
|
Post by jlf65 on May 16, 2007 13:34:02 GMT -5
How about lawyers? You could break them into categories, like TSG lawyers, RIAA lawyers, or MS lawyers. ;D
|
|
mdk137
Moldy Popcorn
Posts: 36
|
Post by mdk137 on May 16, 2007 16:21:51 GMT -5
Good suggestions. However I would like that the game did not have bonds with the real world. Lawyers are easy targets. I was thinking about an uncommon bestiary. With beasts really strange to kill: Cyberdemons and/or cacodemons (doom), or lickers and/or tyrants (resident evil series). Something that runs away from the fantastic rpg type. This probably would allow to put bazookas, grenade launchers, flame throwers, among others things still more strange. This everything remember me that I did not think about the plot game. Must be something simple but must exist.
|
|
|
Post by jlf65 on May 16, 2007 17:21:18 GMT -5
My suggestions were obviously a joke, but for early levels or near "normal" places, you could add regular animals. Wolves, bears, feral dogs... that sort of thing.
|
|
|
Post by haroldoop on May 16, 2007 21:58:28 GMT -5
|
|
mdk137
Moldy Popcorn
Posts: 36
|
Post by mdk137 on May 17, 2007 16:23:28 GMT -5
I understood the joke concerning the lawyers. Therefore this profession is an easy target. ;D Your suggestions of monsters for "normal" areas of the game had been also written down. haroldoop thanks for the generators they had given me a mount of absurd ideas. (a servant of " Gh'Pe, The Knower of the Book" debtor to fight in the well of the desperation with monstruous as " Avant-Garde Dune Hamster of the Moon" ?) however, observing the nature to kill or to die that I am implementing, it seems the plot of a film of zombies. on the code in itself, I am making modifications with more caution. suddenly a code with less than 100 lines exceeded the mark of 300!. Add more things to the code was allowing to the sprouting of errors for all the sides. This compelled me to write the algorithm in the paper to not lose me. and everything that I desired was to create one simple adventure text. I wait to have something to show in briefly and with all bugs eliminated.
|
|
|
Post by jlf65 on May 17, 2007 18:19:18 GMT -5
Rather than code the text game directly, you might consider making data tables and just code to go through the tables. Make it like a state machine.
|
|