Here's a half finished conversion. I think the sprite and keydown commands are the only things left to convert. I'm still kinda hazy on those.
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
SPRITE 15 playerX playerY $playersprite$$
'----PLAYER CODE-------------------------------------------------------------------- ------------
ON KEYDOWN
LET newtile$ = "empty"
IF keydown$ = "UPARROW" THEN LET moveY = gridY - 1
IF keydown$ = "DOWNARROW" THEN LET moveY = gridY + 1
IF keydown$ = "LEFTARROW" THEN LET moveX = gridX - 1
IF keydown$ = "RIGHTARROW" THEN LET moveX = gridX + 1
'----GRID CODE-------------------------------------------------------------------- ---------------
LET moveXY = 0
LET moveXY = 7 * moveY
LET moveXY = moveXY - 7
LET moveXY = moveXY + moveX
LET newtile$ = MID$ gridlayout$ moveXY 1
IF newtile$ = "0" THEN LET newtile$ = "empty"
IF newtile$ = "1" THEN LET newtile$ = "wall"
IF newtile$ = "2" THEN LET newtile$ = "portal 1"
'---/GRID CODE-------------------------------------------------------------------- ---------------
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
IF keydown$ = "DOWNARROW" THEN LET playerY = playerY + 44
IF keydown$ = "LEFTARROW" THEN LET playerX = playerX - 44
IF keydown$ = "RIGHTARROW" THEN LET playerX = playerX + 44
LET gridY = moveY
LET gridX = moveX
END IF
IF newtile$ = "wall" THEN
LET moveY = gridY
LET moveX = gridX
END IF
SPRITE 15 playerX playerY
END KEYDOWN
'---/PLAYER CODE-------------------------------------------------------------------- ------------
Thanks, is anything in this script on a timer?
-Gandolf
P.S. Here is the code a little more converted. Also 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? (And also, if you could explain what each section of code is suppose to do, that will help a lot.) :)
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
CREATESPRITE 15, "player"
MOVESPRITE 15, playerx, playery
'----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-------------------------------------------------------------------- ---------------
LET moveXY = 0
LET moveXY = 7 * moveY
LET moveXY = moveXY - 7
LET moveXY = moveXY + moveX
LET newtile$ = MID$(gridlayout$, moveXY, 1)
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
'---/GRID CODE-------------------------------------------------------------------- ---------------
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
MOVESPRITE 15, playerx, playery
END KEYDOWN
'---/PLAYER CODE-------------------------------------------------------------------- ------------
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.
Instead of pushing the sprite 44 pixels push it 30? Then redraw your map to support 30x30 tiles?
Yeah, it's fairly straightforward. You'd have to change the core as well:
LET moveXY = 0
LET moveXY = 7 * moveY
LET moveXY = moveXY - 7
LET moveXY = moveXY + moveX
LET newtile$ = MID$(gridlayout$, moveXY, 1)
Would become:
LET moveXY = 0
LET moveXY = 9 * moveY
LET moveXY = moveXY - 9
LET moveXY = moveXY + moveX
LET newtile$ = MID$(gridlayout$, moveXY, 1)
y = 9 * ManV
y = y - 9
y = y + ManH
x$ = MID$ gridlayout$ y 1
ON KEYDOWN
IF keydown$ = "RIGHTARROW" THEN
IF x$ <> "a" THEN
do move
END IF
END IF
END IF
Um... yeah, I suppose... but why not just make a collision class? That's what V6 is all about:
IF newtile$ = "left side wall" THEN
LET newtile$ = "empty"
IF keydown$ = "RIGHT ARROW" THEN LET newtile$ = "wall"
END IF