Guide: Remaking the default custom map.

Duodecimus
Over the last couple of months I but together a game (found here) using the Map and drawing grid, and I figured it out.
I figured out weird exits, I figured out teleporting, I figured out how to stop it doing anything automatically at all.

So lets start.

first, any room you're going to be fancy with needs to have this:

Before entering the room:
this.grid_render = False


This will stop it from automatically drawing the room, drawing the player, centering the map, and auto-generating the exits.
So we'll need to replace those functions



First, drawing the room, the exits and the player
After entering a room:

//game.pov is the name for where the player is on the map. This is the top left corner of the room.
//this is how the room sees itself.
//Grid_GetGridCoordinateForPlayer() returns an integer for the x, y or z. You don't NEED to do this line, but it may be difficult to keep track otherwise.

player_x = Grid_GetGridCoordinateForPlayer(game.pov, this, "x")
player_y = Grid_GetGridCoordinateForPlayer(game.pov, this, "y")
player_z = Grid_GetGridCoordinateForPlayer(game.pov, this, "z")
//Grid_AddNewShapePoint(x ,y) will mark a point on the grid for Grid_DrawShape
//Grid_Drawshape(shapeid, linecolor, fillcolor, transparency) will draw a line from the first shapepoint to the second, second to third, etc
//and from last to first, then it will be filled and made transparent. There is no max on shapepoints. You can use both hex codes and certain
// names as colors. Reusing shapeid will cause the old shape to vanish. I couldn't find a way to just remove shapes.
//+1 is one towards the bottom or the right of the screen. -1 would be left or top. The code below creates the same box as the automatic mapper.
Grid_AddNewShapePoint (player_x+1, player_y)
Grid_AddNewShapePoint (player_x+1, player_y+1)
Grid_AddNewShapePoint (player_x, player_y+1)
Grid_AddNewShapePoint (player_x, player_y)
Grid_DrawShape ("00131", "Black", "#ffffff", 1)
//Grid_DrawLine(x1, y1, x2, y2, color, thickness) Code below draws an exit to the north, with length 1.
Grid_DrawLine (player_x+.5, player_y, player_x+.5, player_y-1, "#000000", 3)
//JS.Grid_DrawPlayer(x, y, z, radius, border, borderWidth, fill)
//I'm not exactly sure what occurs in this function. It draws a circle with an outline of border and the color of fill, and centers the map for you. It is not required, and you can remove it if you want. I keep it around because the map centering is much smoother than the other option: Grid_SetCentre (x, y)
JS.Grid_DrawPlayer (player_x+.5, player_y+.5, player_z, 5, "black", 2, "yellow")



Next, Making a weird exit:
Pick an exit, it doesn't matter what type it originally was, it can lead anywhere.
check "Run a script (instead of moving the player automatically)"

// getObject(objectname) returns the object named.
plyr = GetObject ("player")
currentRoom = plyr.parent
// If you are using an exit for this script you can also use newRoom = this.to
newRoom = getObject("Destination room name")
//where is the destination room? north is -y, east is +x, south is +y, and west is -x
//If you like, you can derive these from the exit direction and this.grid_length to mimic the auto mapper.
offset_x = 1
offset_y = -2
offset_z = 0
//this set() is to make the default mapper know that it needs to draw this new room you're going to. If you rewrote the drawing code don't worry about it.
set (newRoom, "grid_render", true)
//this boils down to 'get the current room and offset it' x+1 and y-2 is one right and two up.
newx = Grid_GetGridCoordinateForPlayer(plyr, currentRoom, "x")+offset_y
newy = Grid_GetGridCoordinateForPlayer(plyr, currentRoom, "y")+offset_x
newz = Grid_GetGridCoordinateForPlayer(plyr, currentRoom, "z")+offset_z
//Tell the internal map logic what the coordinates of the new room are.
Grid_SetGridCoordinateForPlayer (plyr, newRoom, "x", newx)
Grid_SetGridCoordinateForPlayer (plyr, newRoom, "y", newy)
Grid_SetGridCoordinateForPlayer (plyr, newRoom, "z", newz)
//move the player to the destination.
MoveObject (plyr, newRoom)
//center the grid. optional

//I don't know what Grid_CalculateMapCoordinates does, but you have to call it last.
Grid_CalculateMapCoordinates (newRoom, plyr)


Weird exit code also doubles as teleporting code, you just need to know where things are.

I covered the basics here, but questions are welcome.
Never wrote a coding guide, so advice on that is also appreciated.

HegemonKhan
nice grid~coordinate~map~graphics guide, hehe :D

I covered this basic stuff of graphing in my Python and Java school classes just recently (last thing before our finals), and we used the same concepts:

(0,0) ....................(ROW,0)
__________________
|.........................|
|.........................|
|.........................|
|.........................|
|________________|
(0,COL).............(ROW,COL)

make points (X,Y), use them to draw lines, and the lines can draw angular shapes

circle is done by finding its center (X,Y), and the radius via: radius = (height - 2*offset) / 2

This topic is now closed. Topics are closed after 60 days of inactivity.

Support

Forums