Topic:   Very bewildering problem with the Scrolling V6...   (Read 28854 times)


0 Members and 1 Guest are viewing this topic.

Silverwind


  • ^ This guy is amazing.

  • ****


  • Posts: 2805

  • For the glory of my maker
Very bewildering problem with the Scrolling V6...
« on: August 16, 2008, 04:09:52 PM »
I'm not sure if this is a glitch in GM or not, but it has brought a temporary halt to development on the Scrolling V6 Nav. Here's the file: http://www.mediafire.com/?sharekey=41bf6bec539742b7d2db6fb9a8902bda

The problem:
After colliding with an obstacle and moving in a non-opposite direction, (as in, left or right if the previous move direction was up) the computer changes the values of gridX and gridY accordingly to accommodate for the player moving onto the new space, but the code for scrolling the background sprite isn't executed. It's altogether baffling.

The keydown code is on card 2, and is the following:
Code: [Select]
ON KEYDOWN
  newtile$ = "empty"
  directionkeypressed = 0
  IF keydown$ = "UPARROW" THEN moveY = gridY - 1
  IF keydown$ = "DOWNARROW" THEN moveY = gridY + 1
  IF keydown$ = "LEFTARROW" THEN moveX = gridX - 1
  IF keydown$ = "RIGHTARROW" THEN moveX = gridX + 1
  IF keydown$ CONTAINS "ARROW" THEN directionkeypressed = 1
'----GET COLLISION CLASS OF NEW LOCATION--------------------------------------------------------
'  roomX = 1
'  roomY = 1
'  IF moveX > 7 THEN roomX = roomX + 1
'  IF moveX > 14 THEN roomX = roomX + 1
'  IF moveY > 7 THEN roomY = roomY + 1
'  IF moveY > 14 THEN roomY = roomY + 1
'  room = 3 * roomY
'  room = room - 3
'  room = room + roomX
'  IF room = 1 THEN gridlayout$ = gridlayout1$
'  IF room = 2 THEN gridlayout$ = gridlayout2$
'  IF room = 3 THEN gridlayout$ = gridlayout3$
'  IF room = 4 THEN gridlayout$ = gridlayout4$
'  IF room = 5 THEN gridlayout$ = gridlayout5$
'  IF room = 6 THEN gridlayout$ = gridlayout6$
'  IF room = 7 THEN gridlayout$ = gridlayout7$
'  IF room = 8 THEN gridlayout$ = gridlayout8$
'  IF room = 9 THEN gridlayout$ = gridlayout9$
  moveXY = 7 * moveY
  moveXY = moveXY - 7
  moveXY = moveXY + moveX
  IF roomY > 1 THEN moveXY = moveXY - 49
  IF roomY > 2 THEN moveXY = moveXY - 49
  IF roomX > 1 THEN moveXY = moveXY - 7
  IF roomX > 2 THEN moveXY = moveXY - 7
  newtile$ = MID$ gridlayout$ moveXY 1

  IF newtile$ = "" THEN newtile$ = "empty"
  IF newtile$ = "0" THEN newtile$ = "empty"
  IF newtile$ = "1" THEN newtile$ = "wall"
  IF newtile$ = "2" THEN newtile$ = "portal 1"
'---/GET COLLISION CLASS OF NEW LOCATION-------------------------------------------------------
'----COLLISION CLASSES--------------------------------------------------------------------------
  IF moveY < 1 THEN
    ALERT You're trying to move north.
'    gridY = 21
'    GOTOCARD northcard
  END IF
  IF moveY > 21 THEN
    ALERT You're trying to move south.
'    gridY = 1
'    GOTOCARD southcard
  END IF
  IF moveX < 1 THEN
    ALERT You're trying to move west.
'    gridX = 21
'    GOTOCARD westcard
  END IF
  IF moveX > 21 THEN
    ALERT You're trying to move east.
'    gridX = 1
'    GOTOCARD eastcard
  END IF
  IF newtile$ = "portal 1" THEN
'    gridY = moveY
'    gridX = 6
'    GOTOCARD portalcard
  END IF

  IF newtile$ = "empty" THEN
    gridX = moveX
    gridY = moveY
'     Position background sprite.
    IF keydown$ = "UPARROW" THEN bgY = bgY + 44
    IF keydown$ = "DOWNARROW" THEN bgY = bgY - 44
    IF keydown$ = "LEFTARROW" THEN bgX = bgX + 44
    IF keydown$ = "RIGHTARROW" THEN bgX = bgX - 44
'     Position NPC1sprite.
    NPC1spriteY = NPC1gridY * 44
    NPC1spriteY = NPC1spriteY - 44
    NPC1spriteY = NPC1spriteY + bgY
    NPC1spriteX = NPC1gridX * 44
    NPC1spriteX = NPC1spriteX - 44
    NPC1spriteX = NPC1spriteX + bgX
'     Position NPC2sprite.
    NPC2spriteY = NPC2gridY * 44
    NPC2spriteY = NPC2spriteY - 44
    NPC2spriteY = NPC2spriteY + bgY
    NPC2spriteX = NPC2gridX * 44
    NPC2spriteX = NPC2spriteX - 44
    NPC2spriteX = NPC2spriteX + bgX
'     Position NPC3sprite.
    NPC3spriteY = NPC3gridY * 44
    NPC3spriteY = NPC3spriteY - 44
    NPC3spriteY = NPC3spriteY + bgY
    NPC3spriteX = NPC3gridX * 44
    NPC3spriteX = NPC3spriteX - 44
    NPC3spriteX = NPC3spriteX + bgX
'     Position NPC4sprite.
    NPC4spriteY = NPC4gridY * 44
    NPC4spriteY = NPC4spriteY - 44
    NPC4spriteY = NPC4spriteY + bgY
    NPC4spriteX = NPC4gridX * 44
    NPC4spriteX = NPC4spriteX - 44
    NPC4spriteX = NPC4spriteX + bgX
  IF newtile$ = "wall" THEN
    moveX = gridX
    moveY = gridY
  END IF
'---/COLLISION CLASSES--------------------------------------------------------------------------
'     Check which NPCs are alive and draw the sprites of the living ones.
  IF NPC1alive = 1 THEN SPRITE -11 NPC1spriteX NPC1spriteY $NPC1sprite$$
  IF NPC2alive = 1 THEN SPRITE -12 NPC2spriteX NPC2spriteY $NPC2sprite$$
  IF NPC3alive = 1 THEN SPRITE -13 NPC3spriteX NPC3spriteY $NPC3sprite$$
  IF NPC4alive = 1 THEN SPRITE -14 NPC4spriteX NPC4spriteY $NPC4sprite$$
  SPRITE 1 bgX bgY
END KEYDOWN
I survived the spammage of 2007