vx.Map

From vx
Revision as of 00:53, 18 December 2008 by 24.57.170.150 (Talk)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Contents

[edit] vx.Map

An singleton that handles all map interaction.

[edit] Notes

This is an internal object, of which there is only one instance. Just use the variable vx.map to use this.

[edit] Attributes

vx.Map.width -> number (read)
vx.Map.height -> number (read)

  • The dimensions of the map, in tiles.

vx.Map.start_x -> number (read)
vx.Map.start_y -> number (read)

  • The default tile position to spawn the player, specified by the map.

vx.Map.title -> string (read)

  • The title of the active map.

vx.Map.filename -> string (read/write)

  • The filename of the map currently being used. Changing the filename does the equivalent of the Switch(filename) method

vx.Map.music_filename -> string (read)

  • The filename of the music to be played when this map is used.

vx.Map.layer[layer_index] -> (internal class) vx.Map.Layer

  • Resolves a layer by the specified index.
  • This layer object has the following attributes:
    • layer.layer_index -> number (read)
      • The index in the array of the layer being looked up.
    • layer.lucent -> number (read)
      • Translucency percentage of the layer.
    • layer.parallax_x -> number (read/write)
    • layer.parallax_y -> number (read/write)
      • The layer's parallax scrolling effects. I *think* it's specified as a 16.16 fixed point number! Lua doesn't have bitshift though, so you have to multiply/divide by 65536. I *could* possibly make it so the interaction is a decimal where the number 1 is a "normal" static layer.
    • layer.width -> number (read)
    • layer.height -> number (read)
      • The dimensions of the layer in tiles.

vx.Map.zone[zone_index] -> (internal class) vx.Map.Zone

  • Resolves a zone by the specified index.
  • This zone object has the following attributes:
    • zone.zone_index -> number (read)
      • The index in the array of the zone being looked up.
    • zone.name -> string (read)
      • Returns the name of the zone, as specified by its on-map description.
    • zone.event -> string (read)
      • The name of the global/map function to call if this zone were activated. Useful in custom engine loops where you have to handle zone interaction manually.

vx.Map.tileset -> vx.Image (read)

  • Returns an image of the current map's tileset. Any modifications to this image affect the on-map tileset, allowing for some neat effects!

[edit] Methods

vx.Map:Switch(filename)

  • Attempts to switch maps.
  • IMPORTANT: Unlike with VergeC, LuaVerge scripts do not automatically halt when the map is switched, so it is up to you to break out of any loops and functions before it will actually process the map switch request.

vx.Map:Render([x, [y, [dest]]])

  • Draws the map at the specified coordinates, to the specified image destination. If x or y are not specified, it will use the camera's current position. If dest is not specified, it will draw the render to the screen.

vx.Map:GetTile(x, y, layer) -> number

  • Returns the tile index at the specified (x, y) location on the given layer of the map.

vx.Map:SetTile(x, y, layer, tile)

  • Changes the tile index at the specified (x, y) location on the given layer of the map to the given tile.

vx.Map:GetObs(x, y) -> number

  • Gets the tile index of the obstruction tile at the specified (x, y) tile location. A tile of 0 is typically empty obstructions, but it entirely depends on the map being used. To make sure you're handling obstructions properly, you may want to use GetObsPixel(x, y) instead

vx.Map:GetObsPixel(x, y) -> boolean

  • Gets whether or not the specified on-map (x, y) pixel location contains an obstruction. Note that this returns a boolean, whereas GetObs(x, y) returns a tile number.

vx.Map:SetObs(x, y, tile)

  • Changes the obstruction tile at the specified (x, y) location on the map to the given tile.

vx.Map:GetZone(x, y) -> number

  • Gets the zone index at the specified (x, y) tile location. A zone of 0 means the default map zone, for which no event SHOULD be associated. It is up to you to figure out what the numbering means. The zone[] attributes of the map may be useful for looking up name or scripts associated with a zone.

vx.Map:SetZone(x, y, zone)

  • Changes the zone at the specified (x, y) location on the map to the given zone index.
Personal tools