Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
How do i use the enter key???
#11
Quote:Wow, nice code SD, and you too Whitetiger.
Have to study that a bit. So far I only have a simple menu, but I'll make it more complex.
cool, so far ive only used two menus in one program (same routine of course). The hard part about mine is that when i was programming it the
Code:
LOCATE sh / 2 - INT(ub / 2 + .5) + i, (sw / 2) - (LEN(word$) / 2)
took forever to figure out
the first version of my code only worked with an even amount of items in the menu but i improved it and it's ok now
[Image: sig.php]
Back by popular demand!
I will byte and nibble you bit by bit until nothing remains but crumbs.
Reply
#12
Silent-Death, you have a lot of redundancy. Remember computers are here to do repetitive things for us, if you coping and pasting code over and over, and only changing a small part you are being wastefull, and there is probably a shorter way to code it.
Removing redundancy makes re-using code much eaiser, because algorithms will transfer much eaiser between programs if they are set-up to accept more than one use.

for example, I have just written a sub that scrolls the letters in from one side of the screen and centres them. But it can display any phrase you want, and start on any row. And you can stick it in any program you want now, too. Smile no need to recode the whole thing for another heading on another game.
Code:
'centeres text, and scrolls each letter on from the side
'set-up for SCREEN 13 text width.
SUB scroll2Centre (text$, row%)
   leftMost% = INT(20 - LEN(text$) / 2)
   FOR i = LEN(text$) TO 1 STEP -1
      currentChar$ = MID$(text$, i, 1)    'grabs the char to be moved
      IF currentChar$ <> " " THEN         'skips spaces
         distance% = leftMost% + i - 2
         FOR col% = 1 TO distance%
            LOCATE row%, col%
            PRINT " "; currentChar$;
            pause .01
            IF INKEY$ <> "" THEN          'get-out clause
               LOCATE row%, POS(0) - 1: PRINT " "  'removes scrolling char
               LOCATE row%, leftMost%
               PRINT text$
               EXIT SUB
            END IF
         NEXT col%
      END IF
   NEXT i
END SUB

'Makes the prog. pause
SUB pause (p!)
   tim! = TIMER
   DO: LOOP UNTIL tim! + p! < TIMER
END SUB
I've just modified the pause technique you use, to be universal, and also note that the pause will fail if it ticks over from midnight. (I didn't bother codeing a fail-safe for that, I just can't be arsed atm.. Tongue)

You may want to re-code the snake motion, you could code it so the snake trys to get to a certain point. Instead of the motions being hard-coded. This way it'll look different every time. Smile
url=http://www.spreadfirefox.com/?q=affiliates&id=60131&t=79][Image: safer.gif][/url]
END OF LINE.
Reply
#13
Quote:Silent-Death, you have a lot of redundancy.

Waaah! *remembers 3rd normalised form* Not school, i hate school!!!

oh, and:
Code:
Pause = TIMER
DO                              'Makes it pause while Screen 13 Sets Up
LOOP UNTIL Pause + .5 < TIMER

I dont understand why you have this? Does it really make that much difference if you removed it?
Reply
#14
Some cards take a while to display the picture when they change of mode. That way you are making sure that when you begin drawing, the image will be visible. It can be annoying (and a monitor killer) if the image comes out from scratch on it with anything different than black. Many video cards/monitors combos stop the CRT completely when they "close" a video mode, and then bring it back to life when the new screen mode is set, hence the delay. If you draw stuff at once, the CRT has to begin placing electrons since it is "heating", and that causes some wearout.

My old SIS6206 changed modes instantly, but the fist videocard (onboard) that I had when I bought my 233MMX took ages to change from text mode to SCREEN 13. I remember that it was really annoying to code under that circumstances.
SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
Reply
#15
Quote:
Phydaux Wrote:Silent-Death, you have a lot of redundancy.

Waaah! *remembers 3rd normalised form* Not school, i hate school!!!
Uuuurgh! I thought all that normalised form stuff was to do with data-bases. I spent days tring to get MS Access to do what I wanted. Lotus Approach, was so much eaiser to use. But all that was years ago...

The redundancy I'm talking about it having the same code over-and-over, but with a slight thing changed, e.g. the scrolling heading, SD programmed the movement of each letter individually, and I showed a way to do the exact same thing with less code, and more versatility. Smile
url=http://www.spreadfirefox.com/?q=affiliates&id=60131&t=79][Image: safer.gif][/url]
END OF LINE.
Reply
#16
Quote:Silent-Death, you have a lot of redundancy.

I did it that way because i'm still a beginner (well i consider my-self a beginner). I don't now alot of certain technics to to the code i have a sorter way (but i'm learning Big Grin ).

Quote:oh, and:
Code:
Code:
Pause = TIMER
DO                              'Makes it pause while Screen 13 Sets Up
LOOP UNTIL Pause + .5 < TIMER


I dont understand why you have this? Does it really make that much difference if you removed it?

It's there because i noticed a pause when screen 13 goes up. That just gives it time to do the crap it has to do Big Grin (that was a really dumbed down v. of what Na_th_an said :wink: ).
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)