From: <cl...@us...> - 2007-07-11 00:06:26
|
Revision: 46 http://fortress.svn.sourceforge.net/fortress/?rev=46&view=rev Author: clrg Date: 2007-07-10 17:06:28 -0700 (Tue, 10 Jul 2007) Log Message: ----------- Rewrite the prototype to use isometric layout instead of a regular grid Modified Paths: -------------- trunk/client/src/main.t trunk/client/src/net/sourceforge/fortress/preloadimages.t Added Paths: ----------- trunk/client/src/net/sourceforge/fortress/game.t trunk/client/src/net/sourceforge/fortress/image/iso96/ trunk/client/src/net/sourceforge/fortress/image/iso96/grid.png trunk/client/src/net/sourceforge/fortress/image/iso96/highlight.png trunk/client/src/net/sourceforge/fortress/isogrid.t trunk/client/src/net/sourceforge/fortress/twoquarter.t Removed Paths: ------------- trunk/client/src/net/sourceforge/fortress/app.t trunk/client/src/net/sourceforge/fortress/image/mud/ trunk/client/src/net/sourceforge/fortress/map.t trunk/client/src/net/sourceforge/fortress/maptile.t Modified: trunk/client/src/main.t =================================================================== --- trunk/client/src/main.t 2007-07-10 22:37:09 UTC (rev 45) +++ trunk/client/src/main.t 2007-07-11 00:06:28 UTC (rev 46) @@ -1,5 +1,5 @@ <!-- Copyright 2007 licensed under GPL v3 --> <vexi xmlns:ui="vexi://ui" xmlns="net.sourceforge.fortress"> - <app /> + <game /> </vexi> Deleted: trunk/client/src/net/sourceforge/fortress/app.t =================================================================== --- trunk/client/src/net/sourceforge/fortress/app.t 2007-07-10 22:37:09 UTC (rev 45) +++ trunk/client/src/net/sourceforge/fortress/app.t 2007-07-11 00:06:28 UTC (rev 46) @@ -1,28 +0,0 @@ -<!-- Copyright 2007 licensed under GPL v3 --> - -<vexi xmlns:ui="vexi://ui" xmlns="net.sourceforge.fortress" xmlns:widget="vexi.widget"> - <widget:surface /> - <preloadimages /> - <ui:box titlebar="Fortress Prototype"> - <ui:box orient="vertical" shrink="true"> - <minimap /> - <ui:box fill="#888888" height="1" /> - <ui:box height="5" /> - <ui:box id="tiletype" align="center" textcolor="white" /> - <ui:box height="5" /> - <ui:box id="position" align="center" textcolor="white" /> - </ui:box> - <ui:box fill="#888888" width="1" hshrink="true" /> - <map id="map" /> - - vexi.ui.frame = thisbox; - - $map.active ++= function(v) - { - $position.text = "( "+$map.activeTile.posx+", "+$map.activeTile.posy+" )"; - $tiletype.text = $map.activeTile.type; - cascade = v; - } - - </ui:box> -</vexi> \ No newline at end of file Copied: trunk/client/src/net/sourceforge/fortress/game.t (from rev 42, trunk/client/src/net/sourceforge/fortress/app.t) =================================================================== --- trunk/client/src/net/sourceforge/fortress/game.t (rev 0) +++ trunk/client/src/net/sourceforge/fortress/game.t 2007-07-11 00:06:28 UTC (rev 46) @@ -0,0 +1,12 @@ +<!-- Copyright 2007 licensed under GPL v3 --> + +<vexi xmlns:ui="vexi://ui" xmlns="net.sourceforge.fortress" xmlns:widget="vexi.widget"> + <widget:surface /> + <preloadimages /> + <ui:box titlebar="Fortress Prototype"> + <isogrid id="map" /> + + vexi.ui.frame = thisbox; + + </ui:box> +</vexi> \ No newline at end of file Added: trunk/client/src/net/sourceforge/fortress/image/iso96/grid.png =================================================================== (Binary files differ) Property changes on: trunk/client/src/net/sourceforge/fortress/image/iso96/grid.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/client/src/net/sourceforge/fortress/image/iso96/highlight.png =================================================================== (Binary files differ) Property changes on: trunk/client/src/net/sourceforge/fortress/image/iso96/highlight.png ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Added: trunk/client/src/net/sourceforge/fortress/isogrid.t =================================================================== (Binary files differ) Property changes on: trunk/client/src/net/sourceforge/fortress/isogrid.t ___________________________________________________________________ Name: svn:mime-type + application/octet-stream Deleted: trunk/client/src/net/sourceforge/fortress/map.t =================================================================== --- trunk/client/src/net/sourceforge/fortress/map.t 2007-07-10 22:37:09 UTC (rev 45) +++ trunk/client/src/net/sourceforge/fortress/map.t 2007-07-11 00:06:28 UTC (rev 46) @@ -1,199 +0,0 @@ -<!-- Copyright 2007 licensed under GPL v3 --> - -<vexi xmlns:ui="vexi://ui" xmlns="net.sourceforge.fortress"> - <ui:box layout="absolute"> - <ui:box id="map" shrink="true" /> - <ui:box id="cur" fill="#88ffffff" display="false" /> - - var drag1 = false; - var drag2 = false; - - //////// sample road creation ///////////////////////////////// - - var createMudTile = function(tile) - { - if (tile.type == "mud") return; - var posx = tile.posx; - var posy = tile.posy; - var comp = ""; - if (posy > 0 and $map[posx][posy-1].type == "mud") - { - var nt = $map[posx][posy-1]; - nt.comp = nt.comp.substring(0, 2) + "m" + nt.comp.substring(3); - nt.sync(); - comp = comp + "m"; - } - else comp = comp + "_"; - if ($map.numchildren > posx+1 and $map[posx+1][posy].type == "mud") - { - var nt = $map[posx+1][posy]; - nt.comp = nt.comp.substring(0, 3) + "m"; - nt.sync(); - comp = comp + "m"; - } - else comp = comp + "_"; - if ($map[posx].numchildren > posy+1 and $map[posx][posy+1].type != "grass") - { - var nt = $map[posx][posy+1]; - nt.comp = "m" + nt.comp.substring(1); - nt.sync(); - comp = comp + "m"; - } - else comp = comp + "_"; - if (posx > 0 and $map[posx-1][posy].type != "grass") - { - var nt = $map[posx-1][posy]; - nt.comp = nt.comp.substring(0, 1) + "m" + nt.comp.substring(2); - nt.sync(); - comp = comp + "m"; - } - else comp = comp + "_"; - tile.seed = ""; - tile.type = "mud"; - tile.comp = comp; - tile.sync(); - surface.setMapTile(tile); - } - - var sr1Func = function(v) - { - drag1 = false; - surface.Focused --= sr1Func; - surface._Release1 --= sr1Func; - } - - thisbox.Press1 ++= function(v) - { - if (!activeTile or drag2) return; - createMudTile(activeTile); - drag1 = true; - surface.Focused ++= sr1Func; - surface._Release1 ++= sr1Func; - } - - //////// minimap interaction ////////////////////////////////// - - var mapDim = function(v) - { - cascade = v; - surface.setMapDim($map.width, $map.height); - } - - $map.width ++= mapDim; - $map.height ++= mapDim; - - var mapBox = function(v) - { - cascade = v; - surface.setMapBox(width, height); - } - - thisbox.width ++= mapBox; - thisbox.height ++= mapBox; - - //////// map movement ///////////////////////////////////////// - - var mx; - var my; - var ox; - var oy; - var vx; - var vy; - - var dragMove = function(v) - { - var m = thisbox.mouse; - var nx = ox + m.x - mx; - var ny = oy + m.y - my; - nx = 0 > nx ? (nx > vx ? nx : vx) : 0; - ny = 0 > ny ? (ny > vy ? ny : vy) : 0; - $map.x = nx; - $map.y = ny; - surface.setMapPos(nx, ny); - cascade = v; - } - - var dragStop = function(v) - { - surface.delMoveTrap(dragMove); - surface._Release2 --= dragStop; - drag2 = false; - cascade = v; - active = true; - } - - var dragStart = function(v) - { - if (drag1) return; - drag2 = true; - $cur.display = false; - var m = thisbox.mouse; - mx = m.x; - my = m.y; - ox = $map.x; - oy = $map.y; - vx = width - $map.width; - vy = height - $map.height; - surface.addMoveTrap(dragMove); - surface._Release2 ++= dragStop; - cascade = v; - } - - thisbox.Press2 ++= dragStart; - - //////// tile tracking //////////////////////////////////////// - - thisbox.activeTile = null; - - thisbox.active ++= function(v) - { - var d = thisbox.distanceto(activeTile); - $cur.display = true; - $cur.width = activeTile.width; - $cur.height = activeTile.height; - $cur.x = d.x; - $cur.y = d.y; - } - - var enterFunc = function(v) - { - cascade = v; - activeTile = trapee; - if (drag1) createMudTile(trapee); - if (!drag2) active = true; - } - - thisbox.Leave ++= function(v) { $cur.display = false; } - - for (var i=0; 100>i; i++) - { - $map[i] = vexi.box; - $map[i].orient = "vertical"; - for (var j=0; 100>j; j++) - { - var t = .maptile(vexi.box); - t.Enter ++= enterFunc; - t.posx = i; - t.posy = j; - $map[i][j] = t; - } - } - - surface ++= function(v) - { - cascade = v; - surface.setMapContents($map); - - surface.moveMapTo = function(x, y) - { - var d = $map.distanceto($map[x][y]); - var dx = width/2 - d.x; - var dy = height/2 - d.y; - $map.x = 0 > dx ? (dx > width - $map.width ? dx : width - $map.width) : 0; - $map.y = 0 > dy ? (dy > height - $map.height ? dy : height - $map.height) : 0; - surface.setMapPos($map.x, $map.y); - } - } - - </ui:box> -</vexi> \ No newline at end of file Deleted: trunk/client/src/net/sourceforge/fortress/maptile.t =================================================================== --- trunk/client/src/net/sourceforge/fortress/maptile.t 2007-07-10 22:37:09 UTC (rev 45) +++ trunk/client/src/net/sourceforge/fortress/maptile.t 2007-07-11 00:06:28 UTC (rev 46) @@ -1,14 +0,0 @@ -<!-- Copyright 2007 licensed under GPL v3 --> - -<vexi xmlns:ui="vexi://ui" xmlns="net.sourceforge.fortress"> - <ui:box shrink="true" width="20" height="20"> - - thisbox.sync = function() { fill = .image[type][type+comp+seed]; } - thisbox.type = "grass"; - thisbox.comp = ""; - thisbox.seed = vexi.math.floor(vexi.math.random()*10); - - sync(); - - </ui:box> -</vexi> \ No newline at end of file Modified: trunk/client/src/net/sourceforge/fortress/preloadimages.t =================================================================== (Binary files differ) Copied: trunk/client/src/net/sourceforge/fortress/twoquarter.t (from rev 42, trunk/client/src/net/sourceforge/fortress/maptile.t) =================================================================== --- trunk/client/src/net/sourceforge/fortress/twoquarter.t (rev 0) +++ trunk/client/src/net/sourceforge/fortress/twoquarter.t 2007-07-11 00:06:28 UTC (rev 46) @@ -0,0 +1,99 @@ +<!-- Copyright 2007 licensed under GPL v3 --> + +<vexi xmlns:ui="vexi://ui" xmlns:meta="vexi://meta" xmlns="net.sourceforge.fortress"> + <meta:doc> + <author>Charles Goodwin</author> + <about>An portion of an isometric tile on the map</about> + <usage> + A tile representing two quarters of an isometric tile on + the map (hence the name). The two quarters are either side + of a diagonal axis of the template box. + + There are two types of tile - top and bottom. This means + whether the tile to the right is a top piece or on the + bottom of an isometric tile. + </usage> + </meta:doc> + + <ui:box layout="absolute" shrink="true" width="48" height="24"> + + // top-left vs bottom-left + thisbox.top = true; + // used to give the graphics a non-repeating feel + thisbox.seed = vexi.math.floor(vexi.math.random()*10); + + thisbox.addPiece = function(type, left) + { + var z = static.zindex[type]; + if (z == null) throw "tried to add nonregistered type '"+type+"' from "+posx+", "+posy; + var i = 0; + while (numchildren > i) + { + if (thisbox[i].type == type and thisbox[i].left == left) + throw "tried to add a duplicate tile piece of type '"+type+"' from "+posx+", "+posy; + if (thisbox[i].z > z) break; + i++; + } + + var b = vexi.box; + b.fill = .image[static.tileset][type]; + b.left = left; + b.shrink = true; + b.type = type; + b.x = left ? 0 : -48; + b.y = top ? 0 : -24; + //vexi.log.info(posx+", "+posy+" -- "+top+", "+left); + b.z = z; + thisbox[i] = b; + } + + thisbox.delPiece = function(type, left) + { + for (var i=0; numchildren>i; i++) + { + if (thisbox[i].type == type and thisbox[i].left == left) + { + thisbox[i] = null; + return; + } + } + throw "tried to clear a non-existent piece of type '"+type+"' from "+posx+", "+posy; + } + + thisbox.posx ++= static.posFunc; + thisbox.posy ++= static.posFunc; + + </ui:box> + + static.posFunc = function(v) + { + cascade = v; + trapee.top = 0 == (trapee.posx + trapee.posy) % 2; + } + + static.tileset = "iso96"; + + static.varies = { }; + static.zindex = { }; + static.ztiles = [ ]; + static.z = 0; + + static.register = function(name, v) + { + if (zindex[name]) throw "duplicate entrie in zindex table"; + if (!v) v = 1; + varies[name] = v; + zindex[name] = static.z; + ztiles[static.z] = name; + static.z++; + } + + static.init = function() + { + register("highlight"); + register("grid"); + } + + { init(); } + +</vexi> \ No newline at end of file This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |