From df11c5da2c6e91a2c079308d62110995352d76f5 Mon Sep 17 00:00:00 2001 From: Patrick Davison Date: Tue, 9 Apr 2013 01:08:02 -0700 Subject: MapEditor improvements --- pages/mapeditor.php | 64 +++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 55 insertions(+), 9 deletions(-) (limited to 'pages') diff --git a/pages/mapeditor.php b/pages/mapeditor.php index 0d6cf94..3134d51 100644 --- a/pages/mapeditor.php +++ b/pages/mapeditor.php @@ -23,6 +23,17 @@ if ($_REQUEST['mapByMap']) { exit; } +if ($_REQUEST['genMap']) { +//function GenerateMap($rows, $cols, $rockchance, $numBlocks = -1, $cp = -1, $tp = -1, $mapName = '') { + $map = GenerateMap($_REQUEST['width'], $_REQUEST['height'], $_REQUEST['rockChance'], $_REQUEST['wallCount'], $_REQUEST['checkpoints'] % 6, $_REQUEST['teleports'] % 6); + //$map = GenerateMap($_REQUEST['height'], $_REQUEST['width'], $_REQUEST['rockChance'], 0, 0, 0); + //$map = insertPoint($map, $_REQUEST['points'], 'o'); + $code = GenerateMapCode($map); + $map = new map($code); + echo json_encode($map); + exit; +} + htmlHeader(array('stats', 'mapeditor'), 'Map Editor', 'Map Editor', @@ -113,16 +124,20 @@ function minusWalls() { reloadMap(); } function plusWidth() { - changeDimensions(testMap.width - 0 + 1, testMap.height) + changeDimensions(testMap.width - 0 + 1, testMap.height); } function minusWidth() { - changeDimensions(testMap.width - 1, testMap.height) + changeDimensions(testMap.width - 1, testMap.height); } function plusHeight() { - changeDimensions(testMap.width, testMap.height - 0 + 1) + changeDimensions(testMap.width, testMap.height - 0 + 1); } function minusHeight() { - changeDimensions(testMap.width, testMap.height - 1) + changeDimensions(testMap.width, testMap.height - 1); +} +function updateName() { + testMap.name = $('#mapName').val(); + mapHasChanged = true; } function changeDimensions(width, height) { @@ -151,12 +166,13 @@ function loadPlayableMap() { if (isLoadingMap == true) return; isLoadingMap = true; - var URLString = 'mapeditor?mapByMap='+JSON.stringify(testMap); + //var URLString = 'mapeditor?mapByMap='+JSON.stringify(testMap); + var URLString = 'mapeditor'; $.ajax({ - type: "GET", + type: "POST", url: URLString, cache: true, - data: '', + data: 'mapByMap='+JSON.stringify(testMap), fail: function() { alert("error"); }, complete: function(data) { playableMap = decryptJSON(data.responseText); @@ -179,6 +195,20 @@ function loadMap(by) { } else if (by == 'code') { mapCode = $('#mapCode').val(); URLString = 'mapeditor?mapByCode='+mapCode; + } else if (by == 'gen') { + mapCode = $('#mapCode').val(); + URLString = 'mapeditor?genMap=true'+mapCode; + var height = $('#genMapHeight').val(); + var width = $('#genMapWidth').val(); + var rockChance = $('#genMapRockChance').val(); + var checkpoints = $('#genMapCheckpoints').val(); + var teleports = $('#genMapTeleports').val(); + URLString += '&height='+height; + URLString += '&width='+width; + URLString += '&wallCount='+testMap.walls; + URLString += '&rockChance='+rockChance; + URLString += '&checkpoints='+checkpoints; + URLString += '&teleports='+teleports; } $.ajax({ type: "GET", @@ -233,6 +263,17 @@ function constructTiles(width, height, baseMap) {
Load map by code: +
+ +
+ Generate a random map: +
Height: +
Width: +
Rockchance 1 in: +
Checkpoints: (Max 5) +
Teleports: (Max 5) + +
@@ -241,10 +282,15 @@ function constructTiles(width, height, baseMap) {
-
+
Settings: +
+ Map Name: +
+ +
Height: @@ -262,7 +308,7 @@ function constructTiles(width, height, baseMap) {