Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old May 2nd, 2005, 12:39 PM   #1
phoenix987
Newbie
 
Join Date: Apr 2005
Location: New Jersey
Posts: 8
Rep Power: 0 phoenix987 is on a distinguished road
Question Help with a QBASIC program

I've been working on a Mario Bros. clone in QBASIC 1.1. My problem is that the spiny turtle sprite will not work right. Whenever it wraps around to the other side of the screen, a wierd colored print of the sprite will be left at the last place the sprite was placed before it wrapped around. It also does this when the sprite "exits" the screen through the pipe (it's supposed to just disappear before the pipe, but it leaves a print as before). Also, it leaves a steak of pixels behind it whenever the sprite moves horizontally. I sort of fixed it with a LINE command, but the GET and PUT method I use should work; it works with the Mario sprite. The latter part isn't necessary to look into, but it would be nice to see what's wrong with the code if you see it.

Sorry for the length of the code. I have a test sub that contains all the code regarding the spiny sprite. The CALL statements are in between the hyphen lines.

Furthermore, the code is from the computer I use at school for my programming class, so that's why I seem to be talking to someone else, sort of, in the code.

The code is too long for one post....

' for anyone who opens this....
' this program is no where near complete, but you can read my version history
' and correspond with me through the REM below.

REM

'my version history is in a SUB


'if you want to see this program in action, just hit F5, then use the
'following keys: A=left, D=right, W=jump straight up, Q=jump left, E=jump
'                ESC=quit                                            right
'-----------------------------------------------------------------------------
'also, remember, DON'T STEAL MY TRIFORCE AND MASTER SWORD LOGO!!!!!!!!!












DECLARE SUB test (spinyx!, spinyy!, counter!, spinyexit!, oldspinyx!, oldspinyy!)
DECLARE SUB level1 (spinyx!, spinyy!, counter!, spinyexit, oldspinyx!, oldspinyy!)
DECLARE SUB drawenemies ()
DECLARE SUB topedge (x!, y!, direction$, oldx!, oldy!, hit)
DECLARE SUB repairpipes (x!)
DECLARE SUB gameloop (x!, y!, oldx!, oldy!, direction$, jump!, up!, press$)
DECLARE SUB dropdown (x!, y!, oldx!, oldy!, direction$)
DECLARE SUB jumpsub (x!, y!, oldx!, oldy!, jump!, up!, direction$)
DECLARE SUB decidesprite (direction$, x!, y!)
DECLARE SUB keyboard (x!, y!, direction$, jump!, up!, press$)
DECLARE SUB wraparound (x!)
DECLARE SUB drawmario ()
DECLARE SUB drawbackground ()
DECLARE SUB preliminarystuff (x!, y!, spinyx, spinyy, direction$)
DECLARE SUB logo ()

'CALL logo

CLS
SCREEN 13

DIM SHARED santaleft(120)
DIM SHARED santaright(120)
DIM SHARED santaleftsh(120)
DIM SHARED santarightsh(120)
DIM SHARED spiny(100)
DIM SHARED spinysh(100)
DIM SHARED background(110)
DIM SHARED spinybackground(100)

'-----------------------------------------------------------------------------
CALL drawenemies
CALL drawbackground
CALL preliminarystuff(x, y, spinyx, spinyy, direction$)
CALL test(spinyx!, spinyy!, counter!, spinyexit, oldspinyx!, oldspinyy!)
'-----------------------------------------------------------------------------

END

CALL drawenemies
CALL drawmario
CALL drawbackground
CALL preliminarystuff(x, y, spinyx, spinyy, direction$)
CALL test(spinyx!, spinyy!, counter!, spinyexit, oldspinyx!, oldspinyy!)
CALL gameloop(x, y, oldx, oldy, direction$, jump, up, press$)



'spiny sprite
DATA 00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00
DATA 00,15,00,00,15,00,00,15,00,00
DATA 00,00,15,00,15,00,15,00,00,00
DATA 15,00,15,15,15,15,15,00,15,00
DATA 00,15,04,04,04,04,04,15,00,89
DATA 15,04,04,04,04,04,04,04,15,00
DATA 00,15,15,15,15,15,15,15,00,00
DATA 00,00,89,00,00,00,89,00,00,00

'spiny sprite shadow
DATA 00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00
DATA 00,00,00,00,00,00,00,00,00,00
DATA 15,00,00,00,15,00,00,00,15,00
DATA 00,15,00,00,15,00,00,15,00,00
DATA 00,00,15,15,15,15,15,00,00,00
DATA 00,15,04,04,04,04,04,15,00,89
DATA 15,04,04,04,04,04,04,04,15,00
DATA 00,15,15,15,15,15,15,15,00,00
DATA 00,00,89,00,00,00,89,00,00,00

'mario left sprite
DATA 00,00,00,00,04,04,04,04,00,00
DATA 00,00,00,04,04,04,04,04,00,00
DATA 00,00,00,00,08,89,89,06,00,00
DATA 00,00,00,89,89,89,89,06,00,00
DATA 00,00,00,00,89,89,89,06,00,00
DATA 00,00,00,00,01,01,01,00,00,00
DATA 00,00,00,01,01,04,01,01,00,00
DATA 00,00,00,01,01,04,01,01,00,00
DATA 00,00,00,01,01,89,01,01,00,00
DATA 00,00,00,00,01,01,01,00,00,00
DATA 00,00,00,00,00,08,00,00,00,00
DATA 00,00,00,00,08,08,00,00,00,00

'mario left shadow
DATA 00,00,00,00,04,04,04,04,00,00
DATA 00,00,00,04,04,04,04,04,00,00
DATA 00,00,00,00,08,89,89,06,00,00
DATA 00,00,00,89,89,89,89,06,00,00
DATA 00,00,00,00,89,89,89,06,00,00
DATA 00,00,00,00,01,01,01,00,00,00
DATA 00,00,00,01,01,04,01,01,00,00
DATA 00,00,00,01,01,04,01,01,00,00
DATA 00,00,00,01,01,89,01,01,00,00
DATA 00,00,00,00,01,01,01,00,00,00
DATA 00,00,00,00,00,08,00,00,00,00
DATA 00,00,00,00,08,08,00,00,00,00

'mario right sprite
DATA 00,00,04,04,04,04,00,00,00,00
DATA 00,00,04,04,04,04,04,00,00,00
DATA 00,00,06,89,89,08,00,00,00,00
DATA 00,00,06,89,89,89,89,00,00,00
DATA 00,00,06,89,89,89,00,00,00,00
DATA 00,00,00,01,01,01,00,00,00,00
DATA 00,00,01,01,04,01,01,00,00,00
DATA 00,00,01,01,04,01,01,00,00,00
DATA 00,00,01,01,89,01,01,00,00,00
DATA 00,00,00,01,01,01,00,00,00,00
DATA 00,00,00,00,08,00,00,00,00,00
DATA 00,00,00,00,08,08,00,00,00,00

'mario right shadow
DATA 00,00,04,04,04,04,00,00,00,00
DATA 00,00,04,04,04,04,04,00,00,00
DATA 00,00,06,89,89,08,00,00,00,00
DATA 00,00,06,89,89,89,89,00,00,00
DATA 00,00,06,89,89,89,00,00,00,00
DATA 00,00,00,01,01,01,00,00,00,00
DATA 00,00,01,01,04,01,01,00,00,00
DATA 00,00,01,01,04,01,01,00,00,00
DATA 00,00,01,01,89,01,01,00,00,00
DATA 00,00,00,01,01,01,00,00,00,00
DATA 00,00,00,00,08,00,00,00,00,00
DATA 00,00,00,00,08,08,00,00,00,00






END

SUB decidesprite (direction$, x, y)

IF direction$ = "l" THEN                  'decides which sprite to use
   PUT (x, y), santaleftsh, AND
   PUT (x, y), santaleft, OR
ELSEIF direction$ = "r" THEN
   PUT (x, y), santarightsh, AND
   PUT (x, y), santaright, OR
END IF

END SUB

SUB drawbackground

CLS

' platforms
LINE (75, 98)-(245, 102), 7, BF     'center platform
LINE (0, 196)-(320, 200), 7, BF     'bottom platform
LINE (0, 148)-(100, 152), 7, BF: LINE (220, 148)-(320, 152), 7, BF 'bottom
LINE (0, 48)-(100, 52), 7, BF: LINE (220, 48)-(320, 52), 7, BF     'top

'pipes
LINE (0, 163)-(40, 185), 2, BF    'bottom left
LINE (40, 160)-(50, 188), 2, BF
LINE (40, 160)-(50, 188), 0, B
LINE (280, 163)-(320, 185), 2, BF 'bottom right
LINE (270, 160)-(280, 188), 2, BF
LINE (270, 160)-(280, 188), 0, B
LINE (0, 18)-(40, 37), 2, BF      'top left
LINE (40, 15)-(50, 40), 2, BF
LINE (40, 15)-(50, 40), 0, B
LINE (280, 18)-(320, 37), 2, BF   'top right
LINE (270, 15)-(280, 40), 2, BF
LINE (270, 15)-(280, 40), 0, B

END SUB

SUB drawenemies
   FOR y = 1 TO 10
      FOR x = 1 TO 10
         READ clr
         IF clr = 0 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 0, BF
         IF clr = 4 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 4, BF
         IF clr = 15 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 15, BF
         IF clr = 89 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 89, BF
      NEXT
   NEXT
   GET (0, 0)-(10, 9), spiny
   FOR y = 1 TO 10
      FOR x = 1 TO 10
         READ clr
         IF clr = 0 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 255, BF
         IF clr = 4 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 4, BF
         IF clr = 15 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 15, BF
         IF clr = 89 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 89, BF
      NEXT
   NEXT
   GET (0, 0)-(10, 9), spinysh
   CLS
END SUB

SUB drawmario
   FOR y = 1 TO 12
      FOR x = 1 TO 10
         READ clr
         IF clr = 0 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 0, BF
         IF clr = 1 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 1, BF
         IF clr = 4 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 4, BF
         IF clr = 6 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 6, BF
         IF clr = 8 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 8, BF
         IF clr = 15 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 15, BF
         IF clr = 89 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 89, BF
      NEXT
   NEXT
   GET (0, 0)-(10, 11), santaleft
   LINE (0, 0)-(320, 200), 255, BF
   FOR y = 1 TO 12
      FOR x = 1 TO 10
         READ clr
         IF clr = 0 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 255, BF
         IF clr = 1 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 1, BF
         IF clr = 4 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 4, BF
         IF clr = 6 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 6, BF
         IF clr = 8 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 8, BF
         IF clr = 15 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 15, BF
         IF clr = 89 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 89, BF
      NEXT
   NEXT

   GET (0, 0)-(10, 11), santaleftsh

   FOR y = 1 TO 12
      FOR x = 1 TO 10
         READ clr
         IF clr = 0 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 0, BF
         IF clr = 1 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 1, BF
         IF clr = 4 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 4, BF
         IF clr = 6 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 6, BF
         IF clr = 8 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 8, BF
         IF clr = 15 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 15, BF
         IF clr = 89 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 89, BF
      NEXT
   NEXT

   GET (0, 0)-(10, 11), santaright
   LINE (0, 0)-(320, 200), 255, BF
   FOR y = 1 TO 12
      FOR x = 1 TO 10
         READ clr
         IF clr = 0 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 255, BF
         IF clr = 1 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 1, BF
         IF clr = 4 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 4, BF
         IF clr = 6 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 6, BF
         IF clr = 8 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 8, BF
         IF clr = 15 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 15, BF
         IF clr = 89 THEN LINE (x * 1, y * 1)-(x * 1 - 1, y * 1 - 1), 89, BF
      NEXT
   NEXT

   GET (0, 0)-(10, 11), santarightsh

END SUB

SUB dropdown (x, y, oldx, oldy, direction$)
IF (x > 100 AND x < 210) AND (y < 138 AND y > 102) THEN  'drop down from
   DO UNTIL y = 184                                      'bottom platforms
      CALL decidesprite(direction$, x!, y!)
      oldx = x
      oldy = y
      y = y + 1
      WAIT &H3DA, 8
      PUT (oldx, oldy), background, PSET
      GET (x, y)-(x + 10, y + 11), background
   LOOP
END IF

IF (y > 52 AND y < 88) AND ((x <= 65 AND x > 0) OR (x >= 245 AND x < 320)) THEN
   DO UNTIL y = 136                             'drop down from center
      CALL decidesprite(direction$, x!, y!)     'platform
      oldx = x
      oldy = y
      y = y + 1
      WAIT &H3DA, 8
      PUT (oldx, oldy), background, PSET
      GET (x, y)-(x + 10, y + 11), background
   LOOP

END IF

IF (x > 100 AND x < 210) AND (y < 51 AND y > 0) THEN  'drop down from top
   DO UNTIL y = 86                                       'platforms
      CALL decidesprite(direction$, x!, y!)
      oldx = x
      oldy = y
      y = y + 1
      WAIT &H3DA, 8
      PUT (oldx, oldy), background, PSET
      GET (x, y)-(x + 10, y + 11), background
   LOOP
END IF

END SUB

SUB gameloop (x, y, oldx, oldy, direction$, jump, up, press$)
DO UNTIL press$ = CHR$(27)
press$ = INKEY$
CALL decidesprite(direction$, x, y)
CALL level1(spinyx, spinyy, counter, spinyexit, oldspinyx, oldspinyy)
oldx = x
oldy = y
CALL keyboard(x, y, direction$, jump, up, press$)
CALL jumpsub(x, y, oldx, oldy, jump, up, direction$)
CALL wraparound(x)
WAIT &H3DA, 8
PUT (oldx, oldy), background, PSET
GET (x, y)-(x + 10, y + 11), background
CALL dropdown(x, y, oldx, oldy, direction$)
CALL repairpipes(x)
LOOP
END SUB
phoenix987 is offline   Reply With Quote
Old May 2nd, 2005, 12:40 PM   #2
phoenix987
Newbie
 
Join Date: Apr 2005
Location: New Jersey
Posts: 8
Rep Power: 0 phoenix987 is on a distinguished road
SUB jumpsub (x, y, oldx, oldy, jump, up, direction$)
IF jump <> 0 THEN
'   PLAY "O3L8C"
   IF up = 1 THEN
      FOR i = 1 TO 60
         CALL decidesprite(direction$, x, y)
         oldx = x
         oldy = y
         y = y - 1
         CALL wraparound(x)
         WAIT &H3DA, 8
         PUT (oldx, oldy), background, PSET
         GET (x, y)-(x + 10, y + 11), background
         CALL topedge(x, y, direction$, oldx, oldy, hit)
         IF hit = 1 THEN
            up = 0
            GOTO 1
         END IF
         IF (y = 103) AND (x > 67 AND x < 244) THEN
            IF (x > 67 AND x < 100) OR (x > 210 AND x < 244) THEN
               DO UNTIL y = 136
                  CALL decidesprite(direction$, x, y)
                  oldx = x                            'hit bottom of center
                  oldy = y                            'platform when jumping
                  y = y + 1                           'straight up
                  WAIT &H3DA, 8
                  PUT (oldx, oldy), background, PSET
                  GET (x, y)-(x + 10, y + 11), background
               LOOP
               GOTO 1
            ELSEIF x >= 100 AND x <= 210 THEN
               DO UNTIL y = 184
                  CALL decidesprite(direction$, x, y)
                  oldx = x
                  oldy = y
                  y = y + 1
                  WAIT &H3DA, 8
                  PUT (oldx, oldy), background, PSET
                  GET (x, y)-(x + 10, y + 11), background
               LOOP
               GOTO 1
            END IF
         END IF
         IF (y = 153) AND ((x > 0 AND x < 98) OR (x > 212 AND x < 309)) THEN
            DO UNTIL y = 184
               CALL decidesprite(direction$, x, y)   'hit head on bottom of
               oldx = x                              'bottom platforms when
               oldy = y                              'jumping straight up
               y = y + 1
               WAIT &H3DA, 8
               PUT (oldx, oldy), background, PSET
               GET (x, y)-(x + 10, y + 11), background
            LOOP
            GOTO 1
         END IF
      NEXT
      FOR i = 1 TO 60
         CALL decidesprite(direction$, x, y)
         oldx = x
         oldy = y
         y = y + 1
         CALL wraparound(x)
         WAIT &H3DA, 8
         PUT (oldx, oldy), background, PSET
         GET (x, y)-(x + 10, y + 11), background
      NEXT
      up = 0
      GOTO 1
   END IF
   IF direction$ = "r" THEN
      FOR i = 1 TO 60
         PUT (x, y), santarightsh, AND
         PUT (x, y), santaright, OR
         oldx = x
         oldy = y
         x = x + 1
         y = y - 1
         CALL wraparound(x)
         WAIT &H3DA, 8
         PUT (oldx, oldy), background, PSET
         GET (x, y)-(x + 10, y + 11), background
         CALL topedge(x, y, direction$, oldx, oldy, hit)
         IF hit = 1 THEN
            GOTO 1
         END IF
         IF (y > 85 AND y < 102) AND (x = 65) THEN    'hit body on left side
            DO UNTIL y = 136                          'of center platform
               PUT (x, y), santarightsh, AND
               PUT (x, y), santaright, OR
               oldx = x
               oldy = y
               y = y + 1
               WAIT &H3DA, 8
               PUT (oldx, oldy), background, PSET
               GET (x, y)-(x + 10, y + 11), background
            LOOP
            GOTO 1
         END IF
         IF y > 35 AND y < 52 AND x = 210 THEN       'hit body on side of
            DO UNTIL y = 86                          'top right platform
               PUT (x, y), santarightsh, AND
               PUT (x, y), santaright, OR
               oldx = x
               oldy = y
               y = y + 1
               WAIT &H3DA, 8
               PUT (oldx, oldy), background, PSET
               GET (x, y)-(x + 10, y + 11), background
            LOOP
            GOTO 1
         END IF
         IF (y > 134 AND y < 152) AND (x = 210) THEN  'hit body on side of
            DO UNTIL y = 184                          'bottom right platform
               PUT (x, y), santarightsh, AND
               PUT (x, y), santaright, OR
               oldx = x
               oldy = y
               y = y + 1
               WAIT &H3DA, 8
               PUT (oldx, oldy), background, PSET
               GET (x, y)-(x + 10, y + 11), background
            LOOP
            GOTO 1
         END IF
         IF (y = 53) AND ((x > 0 AND x < 98) OR (x > 212 AND x < 309)) THEN
            IF (x > 65 AND x < 98) OR (x > 212 AND x < 245) THEN
               DO UNTIL y = 86
                  PUT (x, y), santarightsh, AND          'hit head on bottom
                  PUT (x, y), santaright, OR             'of top platforms
                  oldx = x                               'when jumping right
                  oldy = y
                  y = y + 1
                  WAIT &H3DA, 8
                  PUT (oldx, oldy), background, PSET
                  GET (x, y)-(x + 10, y + 11), background
               LOOP
               GOTO 1
            ELSEIF (x > 0 AND x <= 65) OR (x >= 245 AND x < 320) THEN
               DO UNTIL y = 136
                  PUT (x, y), santarightsh, AND
                  PUT (x, y), santaright, OR
                  oldx = x
                  oldy = y
                  y = y + 1
                  WAIT &H3DA, 8
                  PUT (oldx, oldy), background, PSET
                  GET (x, y)-(x + 10, y + 11), background
               LOOP
               GOTO 1
            END IF
         END IF
         IF (y = 103) AND (x > 67 AND x < 244) THEN
            IF (x > 67 AND x < 100) OR (x > 210 AND x < 244) THEN
               DO UNTIL y = 136
                  PUT (x, y), santarightsh, AND         'hit head on bottom
                  PUT (x, y), santaright, OR            'of center platform
                  oldx = x                              'when jumping right
                  oldy = y
                  y = y + 1
                  WAIT &H3DA, 8
                  PUT (oldx, oldy), background, PSET
                  GET (x, y)-(x + 10, y + 11), background
               LOOP
               GOTO 1
            ELSEIF x >= 100 AND x <= 210 THEN
               DO UNTIL y = 184
                  PUT (x, y), santarightsh, AND
                  PUT (x, y), santaright, OR
                  oldx = x
                  oldy = y
                  y = y + 1
                  WAIT &H3DA, 8
                  PUT (oldx, oldy), background, PSET
                  GET (x, y)-(x + 10, y + 11), background
               LOOP
               GOTO 1
            END IF
         END IF
         IF (y = 153) AND ((x > 0 AND x < 98) OR (x > 212 AND x < 309)) THEN
            DO UNTIL y = 184
               PUT (x, y), santarightsh, AND        'hit head on bottom of
               PUT (x, y), santaright, OR           'bottom platforms when
               oldx = x                             'jumping right
               oldy = y
               y = y + 1
               WAIT &H3DA, 8
               PUT (oldx, oldy), background, PSET
               GET (x, y)-(x + 10, y + 11), background
            LOOP
            GOTO 1
         END IF
      NEXT
      FOR i = 1 TO 60
         PUT (x, y), santarightsh, AND
         PUT (x, y), santaright, OR
         oldx = x
         oldy = y
         x = x + 1
         y = y + 1
         CALL wraparound(x)
         WAIT &H3DA, 8
         PUT (oldx, oldy), background, PSET
         GET (x, y)-(x + 10, y + 11), background
         IF x > 220 AND x < 320 AND y < 36 AND y > 0 THEN    'jump onto
            DO UNTIL y = 36                                  'top right
               PUT (x, y), santarightsh, AND                 'platform
               PUT (x, y), santaright, OR
               oldx = x
               oldy = y
               x = x + 1
               y = y + 1
               CALL wraparound(x)
               WAIT &H3DA, 8
               PUT (oldx, oldy), background, PSET
               GET (x, y)-(x + 10, y + 11), background
            LOOP
            GOTO 1
         END IF
         IF x > 220 AND x < 320 AND y < 136 AND y > 103 THEN  'jump onto
            DO UNTIL y = 136                                  'bottom right
               PUT (x, y), santarightsh, AND                  'platform
               PUT (x, y), santaright, OR
               oldx = x
               oldy = y
               x = x + 1
               y = y + 1
               CALL wraparound(x)
               WAIT &H3DA, 8
               PUT (oldx, oldy), background, PSET
               GET (x, y)-(x + 10, y + 11), background
            LOOP
            GOTO 1
         END IF
         IF (x > 65 AND x < 245) AND (y > 52 AND y < 86) THEN 'jump onto
            DO UNTIL y = 86                                   'center platform
               PUT (x, y), santarightsh, AND                  'by jumping
               PUT (x, y), santaright, OR                     'right
               oldx = x
               oldy = y
               x = x + 1
               y = y + 1
               CALL wraparound(x)
               WAIT &H3DA, 8
               PUT (oldx, oldy), background, PSET
               GET (x, y)-(x + 10, y + 11), background
            LOOP
            GOTO 1
         END IF
      NEXT
   ELSEIF direction$ = "l" THEN
      FOR i = 1 TO 60
         PUT (x, y), santaleftsh, AND
         PUT (x, y), santaleft, OR
         oldx = x
         oldy = y
         x = x - 1
         y = y - 1
         CALL wraparound(x)
         WAIT &H3DA, 8
         PUT (oldx, oldy), background, PSET
         GET (x, y)-(x + 10, y + 11), background
         CALL topedge(x, y, direction$, oldx, oldy, hit)
         IF hit = 1 THEN
            GOTO 1
         END IF
         IF (y > 85 AND y < 102) AND (x = 245) THEN   'hit body on right side
            DO UNTIL y = 136                          'of center platform
               PUT (x, y), santaleftsh, AND
               PUT (x, y), santaleft, OR
               oldx = x
               oldy = y
               y = y + 1
               WAIT &H3DA, 8
               PUT (oldx, oldy), background, PSET
               GET (x, y)-(x + 10, y + 11), background
            LOOP
            GOTO 1
         END IF
         IF y > 35 AND y < 52 AND x = 100 THEN       'hit body on side of
            DO UNTIL y = 86                          'top left platform
               PUT (x, y), santaleftsh, AND
               PUT (x, y), santaleft, OR
               oldx = x
               oldy = y
               y = y + 1
               WAIT &H3DA, 8
               PUT (oldx, oldy), background, PSET
               GET (x, y)-(x + 10, y + 11), background
            LOOP
            GOTO 1
         END IF
         IF (y > 134 AND y < 152) AND (x = 100) THEN   'hit body on bottom
            DO UNTIL y = 184                           'left platform side
               PUT (x, y), santaleftsh, AND
               PUT (x, y), santaleft, OR
               oldx = x
               oldy = y
               y = y + 1
               WAIT &H3DA, 8
               PUT (oldx, oldy), background, PSET
               GET (x, y)-(x + 10, y + 11), background
            LOOP
            GOTO 1
         END IF
         IF (y = 103) AND (x > 67 AND x < 244) THEN
            IF (x > 67 AND x < 100) OR (x > 210 AND x < 244) THEN
               DO UNTIL y = 136
                  PUT (x, y), santaleftsh, AND          'hit head on bottom
                  PUT (x, y), santaleft, OR             'of center platform
                  oldx = x                              'when jumping left
                  oldy = y
                  y = y + 1
                  WAIT &H3DA, 8
                  PUT (oldx, oldy), background, PSET
                  GET (x, y)-(x + 10, y + 11), background
               LOOP
               GOTO 1
            ELSEIF x >= 100 AND x <= 210 THEN
               DO UNTIL y = 184
                  PUT (x, y), santaleftsh, AND
                  PUT (x, y), santaleft, OR
                  oldx = x
                  oldy = y
                  y = y + 1
                  WAIT &H3DA, 8
                  PUT (oldx, oldy), background, PSET
                  GET (x, y)-(x + 10, y + 11), background
               LOOP
               GOTO 1
            END IF
         END IF
         IF (y = 153) AND ((x > 0 AND x < 98) OR (x > 212 AND x < 309)) THEN
            DO UNTIL y = 184
               PUT (x, y), santaleftsh, AND              'hit head on bottom
               PUT (x, y), santaleft, OR                 'of bottom platforms
               oldx = x                                  'when jumping left
               oldy = y
               y = y + 1
               WAIT &H3DA, 8
               PUT (oldx, oldy), background, PSET
               GET (x, y)-(x + 10, y + 11), background
            LOOP
            GOTO 1
         END IF
         IF (y = 53) AND ((x > 0 AND x < 98) OR (x > 212 AND x < 309)) THEN
            IF (x > 65 AND x < 98) OR (x > 212 AND x < 245) THEN
               DO UNTIL y = 86
                  PUT (x, y), santaleftsh, AND          'hit head on bottom
                  PUT (x, y), santaleft, OR             'of top platforms
                  oldx = x                              'when jumping left
                  oldy = y
                  y = y + 1
                  WAIT &H3DA, 8
                  PUT (oldx, oldy), background, PSET
                  GET (x, y)-(x + 10, y + 11), background
               LOOP
               GOTO 1
            ELSEIF (x > 0 AND x <= 65) OR (x >= 245 AND x < 320) THEN
               DO UNTIL y = 136
                  PUT (x, y), santaleftsh, AND
                  PUT (x, y), santaleft, OR
                  oldx = x
                  oldy = y
                  y = y + 1
                  WAIT &H3DA, 8
                  PUT (oldx, oldy), background, PSET
                  GET (x, y)-(x + 10, y + 11), background
               LOOP
               GOTO 1
            END IF
         END IF
      NEXT
      FOR i = 1 TO 60
         PUT (x, y), santaleftsh, AND
         PUT (x, y), santaleft, OR
         oldx = x
         oldy = y
         x = x - 1
         y = y + 1
         CALL wraparound(x)
         WAIT &H3DA, 8
         PUT (oldx, oldy), background, PSET
         GET (x, y)-(x + 10, y + 11), background
         IF x > 0 AND x < 100 AND y < 36 AND y > 0 THEN       'jump onto
            DO UNTIL y = 36                                   'top left
               PUT (x, y), santaleftsh, AND                   'platform
               PUT (x, y), santaleft, OR
               oldx = x
               oldy = y
               x = x - 1
               y = y + 1
               CALL wraparound(x)
               WAIT &H3DA, 8
               PUT (oldx, oldy), background, PSET
               GET (x, y)-(x + 10, y + 11), background
            LOOP
            GOTO 1
         END IF
         IF x > 0 AND x < 100 AND y < 136 AND y > 103 THEN     'jump onto
            DO UNTIL y = 136                                   'bottom left
               PUT (x, y), santaleftsh, AND                    'platform
               PUT (x, y), santaleft, OR
               oldx = x
               oldy = y
               x = x - 1
               y = y + 1
               CALL wraparound(x)
               WAIT &H3DA, 8
               PUT (oldx, oldy), background, PSET
               GET (x, y)-(x + 10, y + 11), background
            LOOP
            GOTO 1
         END IF
         IF (x > 65 AND x < 245) AND (y > 52 AND y < 86) THEN 'jump onto
            DO UNTIL y = 86                                   'center platform
               PUT (x, y), santaleftsh, AND                   'by jumping
               PUT (x, y), santaleft, OR                      'left
               oldx = x
               oldy = y
               x = x - 1
               y = y + 1
               CALL wraparound(x)
               WAIT &H3DA, 8
               PUT (oldx, oldy), background, PSET
               GET (x, y)-(x + 10, y + 11), background
            LOOP
            GOTO 1
         END IF
      NEXT
   END IF
1
   jump = 0
END IF

END SUB

SUB keyboard (x, y, direction$, jump, up, press$)

IF press$ = "d" THEN                          'key presses
   x = x + 5
   direction$ = "r"
ELSEIF press$ = "a" THEN
   x = x - 5
   direction$ = "l"
ELSEIF press$ = "e" THEN
   jump = 1
   direction$ = "r"
ELSEIF press$ = "q" THEN
   jump = 1
   direction$ = "l"
ELSEIF press$ = "w" THEN
   jump = 1
   up = 1
END IF

END SUB

SUB level1 (spinyx, spinyy, counter, spinyexit, oldspinyx, oldspinyy)
   IF counter < 250 THEN
      counter = counter + 1
      spinyx = 52: spinyy = 23
      GOTO 3
   END IF
   IF spinyexit = 0 THEN
      PUT (spinyx, spinyy), spinysh, AND
      PUT (spinyx, spinyy), spiny, OR
      oldspinyx = spinyx
      oldspinyy = spinyy
      IF spinyy < 38 THEN
         spinyy = spinyy + 1
      ELSEIF spinyy = 38 THEN
         spinyx = spinyx + 1
      END IF
      IF spinyy >= 38 AND spinyy < 88 AND spinyx = 101 THEN
         spinyy = spinyy + 1
      ELSEIF spinyy = 88 THEN
         spinyx = spinyx + 1
      END IF
      IF spinyy < 138 AND spinyy >= 88 AND spinyx = 246 THEN
         spinyy = spinyy + 1
      ELSEIF spinyy = 138 THEN
         spinyx = spinyx + 1
      END IF
      IF spinyx = 310 THEN
         spinyx = 1
      END IF
      IF spinyy >= 138 AND spinyy < 186 AND spinyx = 101 THEN
         spinyy = spinyy + 1
      ELSEIF spinyy = 186 THEN
         spinyx = spinyx + 1
      END IF
      IF spinyx = 260 AND spinyy <= 186 AND spinyy > 150 THEN
         spinyy = spinyy + 1
      ELSEIF spinyx = 260 AND spinyy = 150 THEN
         spinyexit = 1
      END IF
      WAIT &H3DA, 8
      PUT (oldspinyx, oldspinyy), spinybackground
      LINE (oldspinyx, oldspinyy)-(oldspinyx, oldspinyy + 9), 0
      GET (spinyx, spinyy)-(spinyx + 10, spinyy + 9), spinybackground
   END IF
   IF spinyexit = 1 THEN
      PUT (spinyx, spinyy), spinybackground
   END IF
3
END SUB

SUB logo
CLS
SCREEN 13
yellow = 236
metal = 22
darkmetal = 20
purple = 179
darkpurple = 199
delay = 50000
FOR i = 1 TO 3
   IF i = 2 THEN
      yellow = 116
      metal = 24
      darkmetal = 22
      purple = 202
      darkpurple = 178
   ELSEIF i = 3 THEN
      yellow = 44
      metal = 26
      darkmetal = 24
      purple = 107
      darkpurple = 104
   END IF
   LINE (160, 65)-(230, 155), yellow
   LINE (160, 65)-(90, 155), yellow
   LINE (230, 155)-(90, 155), yellow
   LINE (125, 110)-(195, 110), yellow
   LINE (125, 110)-(160, 155), yellow
   LINE (195, 110)-(160, 155), yellow
   PSET (159, 66), yellow
   PAINT (160, 75), yellow
   PAINT (125, 115), yellow
   PAINT (195, 115), yellow
   LINE (153, 111)-(167, 175), metal, BF
   LINE (152, 175)-(160, 200), metal
   LINE (167, 175)-(160, 200), metal
   PSET (152, 175), 0
   PAINT (160, 176), metal
   LINE (160, 111)-(160, 200), darkmetal
   LINE (153, 73)-(153, 60), metal
   LINE (167, 73)-(167, 60), metal
   LINE (167, 60)-(153, 60), metal
   LINE (153, 73)-(160, 64), metal
   LINE (167, 73)-(160, 64), metal
   PAINT (160, 61), metal
   LINE (160, 64)-(160, 60), darkmetal
   LINE (147, 59)-(173, 59), purple
   LINE (147, 59)-(138, 51), purple
   LINE (173, 59)-(182, 51), purple
   LINE (138, 51)-(132, 55), purple
   LINE (182, 51)-(188, 55), purple
   LINE (132, 55)-(129, 60), purple
   LINE (188, 55)-(191, 60), purple
   LINE (129, 60)-(115, 60), purple
   LINE (191, 60)-(205, 60), purple
   LINE (115, 60)-(118, 55), purple
   LINE (205, 60)-(202, 55), purple
   LINE (118, 55)-(122, 51), purple
   LINE (202, 55)-(198, 51), purple
   LINE (122, 51)-(128, 47), purple
   LINE (198, 51)-(192, 47), purple
   LINE (128, 47)-(133, 44), purple
   LINE (192, 47)-(187, 44), purple
   LINE (133, 44)-(138, 42), purple
   LINE (187, 44)-(182, 42), purple
   LINE (138, 42)-(140, 41), purple
   LINE (182, 42)-(180, 41), purple
   LINE (140, 41)-(155, 52), purple
   LINE (180, 41)-(165, 52), purple
   LINE (155, 52)-(155, 20), purple
   LINE (165, 52)-(165, 20), purple
   LINE (155, 20)-(150, 10), purple
   LINE (165, 20)-(170, 10), purple
   LINE (150, 10)-(160, 0), purple
   LINE (170, 10)-(160, 0), purple
   PAINT (160, 10), purple
   LINE (155, 47)-(165, 45), darkpurple, BF
   LINE (155, 42)-(165, 40), darkpurple, BF
   LINE (155, 37)-(165, 35), darkpurple, BF
   LINE (155, 32)-(165, 30), darkpurple, BF
   LINE (155, 27)-(165, 25), darkpurple, BF
   LINE (155, 22)-(165, 20), darkpurple, BF
   LINE (155, 44)-(155, 43), 0: LINE (165, 44)-(165, 43), 0
   LINE (155, 39)-(155, 38), 0: LINE (165, 39)-(165, 38), 0
   LINE (155, 34)-(155, 33), 0: LINE (165, 34)-(165, 33), 0
   LINE (155, 29)-(155, 28), 0: LINE (165, 29)-(165, 28), 0
   LINE (155, 24)-(155, 23), 0: LINE (165, 24)-(165, 23), 0
   FOR j = 1 TO delay
   NEXT
NEXT
COLOR 20
FOR i = 1 TO 3
   IF i = 2 THEN
      COLOR 25
   ELSEIF i = 3 THEN
      COLOR 30
   END IF
   LOCATE 22, 12: PRINT "Chris's"
   LOCATE 22, 23: PRINT "Programs"
   FOR j = 1 TO delay
   NEXT
NEXT
SLEEP 1
FOR i = 1 TO 4
   IF i = 2 THEN
      COLOR 25
      yellow = 116
      metal = 24
      darkmetal = 22
      purple = 202
      darkpurple = 178
   ELSEIF i = 3 THEN
      COLOR 20
      yellow = 236
      metal = 22
      darkmetal = 20
      purple = 179
      darkpurple = 199
   ELSEIF i = 4 THEN
      COLOR 0
      yellow = 0
      metal = 0
      darkmetal = 0
      purple = 0
      darkpurple = 0
   END IF
   LINE (160, 65)-(230, 155), yellow
   LINE (160, 65)-(90, 155), yellow
   LINE (230, 155)-(90, 155), yellow
   LINE (125, 110)-(195, 110), yellow
   LINE (125, 110)-(160, 155), yellow
   LINE (195, 110)-(160, 155), yellow
   PSET (159, 66), yellow
   PAINT (160, 75), yellow
   PAINT (125, 115), yellow
   PAINT (195, 115), yellow
   LINE (153, 111)-(167, 175), metal, BF
   LINE (152, 175)-(160, 200), metal
   LINE (167, 175)-(160, 200), metal
   PSET (152, 175), 0
   PAINT (160, 176), metal
   LINE (160, 111)-(160, 200), darkmetal
   LINE (153, 73)-(153, 60), metal
   LINE (167, 73)-(167, 60), metal
   LINE (167, 60)-(153, 60), metal
   LINE (153, 73)-(160, 64), metal
   LINE (167, 73)-(160, 64), metal
   PAINT (160, 61), metal
   LINE (160, 64)-(160, 60), darkmetal
   LINE (147, 59)-(173, 59), purple
   LINE (147, 59)-(138, 51), purple
   LINE (173, 59)-(182, 51), purple
   LINE (138, 51)-(132, 55), purple
   LINE (182, 51)-(188, 55), purple
   LINE (132, 55)-(129, 60), purple
   LINE (188, 55)-(191, 60), purple
   LINE (129, 60)-(115, 60), purple
   LINE (191, 60)-(205, 60), purple
   LINE (115, 60)-(118, 55), purple
   LINE (205, 60)-(202, 55), purple
   LINE (118, 55)-(122, 51), purple
   LINE (202, 55)-(198, 51), purple
   LINE (122, 51)-(128, 47), purple
   LINE (198, 51)-(192, 47), purple
   LINE (128, 47)-(133, 44), purple
   LINE (192, 47)-(187, 44), purple
   LINE (133, 44)-(138, 42), purple
   LINE (187, 44)-(182, 42), purple
   LINE (138, 42)-(140, 41), purple
   LINE (182, 42)-(180, 41), purple
   LINE (140, 41)-(155, 52), purple
   LINE (180, 41)-(165, 52), purple
   LINE (155, 52)-(155, 20), purple
   LINE (165, 52)-(165, 20), purple
   LINE (155, 20)-(150, 10), purple
   LINE (165, 20)-(170, 10), purple
   LINE (150, 10)-(160, 0), purple
   LINE (170, 10)-(160, 0), purple
   PAINT (160, 10), purple
   LINE (155, 47)-(165, 45), darkpurple, BF
   LINE (155, 42)-(165, 40), darkpurple, BF
   LINE (155, 37)-(165, 35), darkpurple, BF
   LINE (155, 32)-(165, 30), darkpurple, BF
   LINE (155, 27)-(165, 25), darkpurple, BF
   LINE (155, 22)-(165, 20), darkpurple, BF
   LINE (155, 44)-(155, 43), 0: LINE (165, 44)-(165, 43), 0
   LINE (155, 39)-(155, 38), 0: LINE (165, 39)-(165, 38), 0
   LINE (155, 34)-(155, 33), 0: LINE (165, 34)-(165, 33), 0
   LINE (155, 29)-(155, 28), 0: LINE (165, 29)-(165, 28), 0
   LINE (155, 24)-(155, 23), 0: LINE (165, 24)-(165, 23), 0
   LOCATE 22, 12: PRINT "Chris's"
   LOCATE 22, 23: PRINT "Programs"
   FOR j = 1 TO delay
   NEXT
NEXT

END SUB

SUB preliminarystuff (x, y, spinyx, spinyy, direction$)

x = 160: y = 184
spinyx = 52: spinyy = 23

GET (x, y)-(x + 10, y + 11), background
GET (spinyx, spinyy)-(spinyx + 10, spinyy + 9), spinybackground

direction$ = "l"

END SUB

SUB repairpipes (x)
IF x > 50 AND x < 260 THEN
LINE (0, 163)-(40, 185), 2, BF    'bottom left
LINE (40, 160)-(50, 188), 2, BF
LINE (40, 160)-(50, 188), 0, B
LINE (280, 163)-(320, 185), 2, BF 'bottom right
LINE (270, 160)-(280, 188), 2, BF
LINE (270, 160)-(280, 188), 0, B
LINE (0, 18)-(40, 37), 2, BF      'top left
LINE (40, 15)-(50, 40), 2, BF
LINE (40, 15)-(50, 40), 0, B
LINE (280, 18)-(320, 37), 2, BF   'top right
LINE (270, 15)-(280, 40), 2, BF
LINE (270, 15)-(280, 40), 0, B
END IF
END SUB

SUB test (spinyx!, spinyy!, counter!, spinyexit, oldspinyx!, oldspinyy!)
DO UNTIL press$ = CHR$(27)
   press$ = INKEY$
   CALL level1(spinyx, spinyy, counter, spinyexit, oldspinyx, oldspinyy)
LOOP
END SUB

SUB topedge (x, y, direction$, oldx, oldy, hit)
   IF y = 1 THEN
      DO UNTIL y = 36
         CALL decidesprite(direction$, x, y)
         oldx = x
         oldy = y
         y = y + 1
         WAIT &H3DA, 8
         PUT (oldx, oldy), background, PSET
         GET (x, y)-(x + 10, y + 11), background
      LOOP
      hit = 1
   END IF
END SUB

SUB versionhistory
'V.1 - Platforms are drawn, using a santa sprite i made awhile ago for mario
'      for now. has a wrap around feature, and it also has a jump engine,
'      which is insanely long. Santa can jump onto the left, bottom platform
'      have yet to draw the pipes. santa also hits his head on all of the
'      bottom platforms (just the bottom part). Plan on extending the
'      platforms to look more like Mario Bros.
'V.2 - Platforms are redrawn, and the bottom platform engine is finished
'      Going to design the Mario sprite for this version just in case I need
'      more pixels than the engine currently allows. The arrays have been
'      significantly reduced from 1000 each to 120 for the sprite, then 110
'      for the background (found by multiplying the number of pixels in
'      length and width, for those of you who don't know how I did that)
'V.25- the platform engines are finished. pipes are drawn. just need a mario
'      sprite
'V.3 - Finally have a Mario sprite!!!! Looks really ugly, but it works. Won't
'      be working for a while because I got an idea for another program, a
'      flight simulator like that old game Galaxian, but a little better
'      gameplay
'V.31 - Realized that Mario would go off the top of the screen, so I added a
'       sub for that. Also changed the keys so that people can jump a certain
'       way faster (q=left, w=straight up, e=right)
'V.35 - Have Spiny sprite, and a path for it to follow, but the GET and PUT
'       commands aren't doing what I want for some reason. When the sprite
'       moves left, a streak of red pixels is left behind (fixed with a LINE
'       command, but I'd feel better if Get and Put worked by itself) Also,
'       when the sprite moves to the other side of the screen or it leaves
'       through a pipe, it leaves a messed up print of itself. Going to email
'       this guy I learned QBASIC from and see if he can fix it, as I can't
END SUB

SUB wraparound (x)
 
  IF x < 2 THEN
     x = 308
  ELSEIF x > 309 THEN
     x = 3
  END IF

END SUB
phoenix987 is offline   Reply With Quote
Old May 2nd, 2005, 12:43 PM   #3
phoenix987
Newbie
 
Join Date: Apr 2005
Location: New Jersey
Posts: 8
Rep Power: 0 phoenix987 is on a distinguished road
Just one last note: I won't be able to be on until about 1:00 PM Eastern time tomorrow because this is the only class I have access to a computer.
phoenix987 is offline   Reply With Quote
Old May 5th, 2005, 12:26 PM   #4
phoenix987
Newbie
 
Join Date: Apr 2005
Location: New Jersey
Posts: 8
Rep Power: 0 phoenix987 is on a distinguished road
Is anyone familiar with QBASIC? Or should I try this thread on the VB board?

Also, I'm a n00b, and I can't figure out how to edit posts. Anyone who could point that out to me, please do. I thought there was a button next to the Quote and Quick Reply buttons in the bottom righthand corner of a post, but it's not there anymore...
phoenix987 is offline   Reply With Quote
Old May 5th, 2005, 12:27 PM   #5
phoenix987
Newbie
 
Join Date: Apr 2005
Location: New Jersey
Posts: 8
Rep Power: 0 phoenix987 is on a distinguished road
I was right, there was an edit button there!!! But why isn't it on my other posts? >
phoenix987 is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 6:50 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC