Thanks, is anything in this script on a timer?
Nope. The NPC script (which isn't included) can run on a timer or keydown with minimal difference in code. It'll be included when I release the demo engine.
I'm a little confused by a certain part of the script. It says, LET playerY = gridY * 44 but gridY isn't defined as a variable yet. So how does that work?
That variable needs to be set before entering a card. Here's a few of the variables I set in the New Adventure button in QoM for example:
gridY = 4
gridX = 4
moveY = gridY
moveX = gridX
playerY = 137
playerX = 137
NPCspeed = 50
NPCgridY = 4
NPCgridX = 4
NPCspriteY = 137
NPCspriteX = 137
moveup$ = "moveup "
movedown$ = "movedown "
moveleft$ = "moveleft "
moveright$ = "moveright "
And also, if you could explain what each section of code is suppose to do, that will help a lot.)
I'll do that when I release the demo engine. I doubt I'll be releasing it anytime soon though with all of these projects. Here's a quick rundown:
LET gridlayout$ = "" Â
LET northcard = 0 Â
LET southcard = 0 Â
LET eastcard = 0 Â
LET westcard = 0 Â
LET playerY = gridY * 44 Â
LET playerY = playerY - 39 Â
LET playerX = gridX * 44 Â
LET playerX = playerX - 39 Â
LET moveY = gridY Â
LET moveX = gridX
Â
Sets the computer's bearings so that it knows what cards are North, South, East and West of the current card. Then positions the player sprite according to the GridX and GridY variables.
'----PLAYER CODE-------------------------------------------------------------------- Â ------------ Â
ON KEYDOWN Â
LET newtile$ = "empty" Â
IF keydown$ = "UPARROW" THEN
LET moveY = gridY - 1 Â
END IF
IF keydown$ = "DOWNARROW" THEN
LET moveY = gridY + 1 Â
END IF
IF keydown$ = "LEFTARROW" THEN
LET moveX = gridX - 1 Â
END IF
IF keydown$ = "RIGHTARROW" THEN
LET moveX = gridX + 1 Â
END IF
'----GRID CODE-------------------------------------------------------------------- Â ---------------
Detects which arrow button the player presses, so that the computer knows which way to attempt to move the player in.
LET moveXY = 0 Â
LET moveXY = 7 * moveY Â
LET moveXY = moveXY - 7 Â
LET moveXY = moveXY + moveX Â
LET newtile$ = MID$(gridlayout$, moveXY, 1)
The core of the engine. This is the magic that makes collision happen. Limitless collision classes... massive storage space... oh yeah...
IF newtile$ = "0" THEN
LET newtile$ = "empty" Â
END IF
IF newtile$ = "1" THEN
LET newtile$ = "wall" Â
END IF
IF newtile$ = "2" THEN
LET newtile$ = "portal 1" Â
END IF
Determines which collision class the space the player is trying to move onto is.
IF moveY < 1 THEN Â
 LET gridY = 7 Â
 GOTOCARD northcard Â
END IF Â
IF moveY > 7 THEN Â
 LET gridY = 1 Â
 GOTOCARD southcard Â
END IF Â
IF moveX > 7 THEN Â
 LET gridX = 1 Â
 GOTOCARD eastcard Â
END IF Â
IF moveX < 1 THEN Â
 LET gridX = 7 Â
 GOTOCARD westcard Â
END IF Â
IF newtile$ = "portal 1" THEN Â
 LET gridY = 0 Â
 LET gridX = 0 Â
 GOTOCARD 0 Â
END IF
IF newtile$ = "empty" THEN Â
 IF keydown$ = "UPARROW" THEN
LET playerY = playerY - 44 Â
END IF
 IF keydown$ = "DOWNARROW" THEN
LET playerY = playerY + 44 Â
END IF
 IF keydown$ = "LEFTARROW" THEN
LET playerX = playerX - 44 Â
END IF
 IF keydown$ = "RIGHTARROW" THEN
LET playerX = playerX + 44 Â
END IF
 LET gridY = moveY Â
 LET gridX = moveX Â
END IF Â
IF newtile$ = "wall" THEN Â
 LET moveY = gridY Â
 LET moveX = gridX Â
END IF
References the properties of collision classes.