Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
stuttering screen with inkey
#1
Okay, the title wasn't too explanatory, sorry for that. Basically, my trouble is that with the following code when you press the w,a,s,d buttons to move the charachter it somtimes moves, somtimes it doesn't and when it does it stutters.

Code:
SCREEN 13
  
   FOR x% = 1 TO 6
      FOR y% = 12 TO 24
         COLOR 26
         LOCATE y%, x%
         PRINT CHR$(219)
      NEXT y%
   NEXT x%

   FOR x% = 1 TO 6
      FOR y% = 1 TO 11
         COLOR 42
         LOCATE y%, x%
         PRINT CHR$(177)
      NEXT y%
   NEXT x%

   FOR x% = 7 TO 12
      FOR y% = 9 TO 24
         COLOR 25
         LOCATE y%, x%
         PRINT CHR$(219)
      NEXT y%
   NEXT x%

   FOR x% = 7 TO 12
      FOR y% = 1 TO 8
         COLOR 42
         LOCATE y%, x%
         PRINT CHR$(177)
      NEXT y%
   NEXT x%

   FOR x% = 13 TO 20
      FOR y% = 18 TO 24
         COLOR 23
         LOCATE y%, x%
         PRINT CHR$(219)
      NEXT y%
   NEXT x%

   FOR x% = 13 TO 20
      FOR y% = 1 TO 17
         COLOR 42
         LOCATE y%, x%
         PRINT CHR$(177)
      NEXT y%
   NEXT x%

   FOR x% = 21 TO 26
      FOR y% = 10 TO 24
         COLOR 26
         LOCATE y%, x%
         PRINT CHR$(219)
      NEXT y%
   NEXT x%

   FOR x% = 21 TO 26
      FOR y% = 1 TO 9
         COLOR 42
         LOCATE y%, x%
         PRINT CHR$(177)
      NEXT y%
   NEXT x%
  
   FOR x% = 27 TO 32
      FOR y% = 15 TO 24
         COLOR 25
         LOCATE y%, x%
         PRINT CHR$(219)
      NEXT y%
   NEXT x%

   FOR x% = 27 TO 32
      FOR y% = 1 TO 14
         COLOR 42
         LOCATE y%, x%
         PRINT CHR$(177)
      NEXT y%
   NEXT x%

   FOR x% = 33 TO 36
      FOR y% = 9 TO 24
         COLOR 27
         LOCATE y%, x%
         PRINT CHR$(219)
      NEXT y%
   NEXT x%

   FOR x% = 33 TO 36
      FOR y% = 1 TO 8
         COLOR 42
         LOCATE y%, x%
         PRINT CHR$(177)
      NEXT y%
   NEXT x%

   FOR x% = 37 TO 40
      FOR y% = 18 TO 24
         COLOR 25
         LOCATE y%, x%
         PRINT CHR$(219)
      NEXT y%
   NEXT x%

   FOR x% = 37 TO 40
      FOR y% = 1 TO 17
         COLOR 42
         LOCATE y%, x%
         PRINT CHR$(177)
      NEXT y%
   NEXT x%

   LOCATE 4, 10
   COLOR 12, 15
   PRINT "Game Title Undecided"

   LOCATE 23, 5
   COLOR 12, 15
   PRINT "Press any key to continue..."

   SLEEP
  
   CLS


SCREEN 7
locx = 3
locy = 19

FOR x% = 1 TO 40
      LOCATE 1, x%
      COLOR 8
      PRINT CHR$(219)
      LOCATE 20, x%
      PRINT CHR$(219)
   NEXT x%
  
   FOR y% = 1 TO 20
      LOCATE y%, 1
      PRINT CHR$(219)
      LOCATE y%, 40
      PRINT CHR$(219)
   NEXT y%
  
DO
  
   press$ = INKEY$
  
   LOCATE locy, locx
   COLOR 13
   PRINT CHR$(2)
  
   IF press$ = "w" THEN
      IF locy - 1 <> 1 THEN
      LOCATE locy, locx
      PRINT " "
      locy = locy - 1
      END IF
   ELSEIF press$ = "d" THEN
      IF locx + 1 <> 40 THEN
      LOCATE locy, locx
      PRINT " "
      locx = locx + 1
      END IF
   ELSEIF press$ = "s" THEN
      IF locy + 1 <> 20 THEN
      LOCATE locy, locx
      PRINT " "
      locy = locy + 1
      END IF
   ELSEIF press$ = "a" THEN
      IF locx - 1 <> 1 THEN
      LOCATE locy, locx
      PRINT " "
      locx = locx - 1
      END IF
   END IF
  
      
LOOP UNTIL INKEY$ = CHR$(27)

Thanks in advance for your help.

Jack

EDIT:

Sorry (I don't mean this in a sarcastic way) probably should have mentioned. I was wondering if anyone knew how to fix this?
Reply
#2
Anyone? Please?
Reply
#3
You may want to have a look at MULTIKEY. INKEY$ just isn't suited for games input most of the times; it is primarly meant for keyboard input in static contexts, like menus, or letting the user type some text. For more dynamic contexts where you need to quickly detect the state (pressed or not pressed) of multiple keys at once, INKEY$ won't work. For those cases, MULTIKEY must be used instead.
ngelo Mottola - EC++
Reply
#4
Thanks, I'll look into it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)