From 4c63c59b12784d12f7715b22b62e028e32967a1f Mon Sep 17 00:00:00 2001 From: dsc Date: Mon, 28 Feb 2011 01:53:57 -0800 Subject: [PATCH] Adds a new tank type, expands first level. --- data/config.yaml | 9 +-- data/types/levels.yaml | 129 +++++++++++++++++++++++++++++++--------- data/types/units.yaml | 28 ++++++++- src/tanks/map/fence.cjs | 69 ---------------------- src/tanks/map/index.cjs | 2 +- src/tanks/map/pathing/map.cjs | 2 +- src/tanks/map/pit.cjs | 69 ++++++++++++++++++++++ src/tanks/ui/grid.cjs | 42 +++++++------- src/tanks/ui/main.cjs | 8 ++- src/tanks/ui/viewport.cjs | 9 ++- www/css/lttl.css | 17 +++-- 11 files changed, 243 insertions(+), 141 deletions(-) delete mode 100644 src/tanks/map/fence.cjs create mode 100644 src/tanks/map/pit.cjs diff --git a/data/config.yaml b/data/config.yaml index e32760c..7080b0a 100644 --- a/data/config.yaml +++ b/data/config.yaml @@ -1,12 +1,12 @@ game: timeDilation : 1.0 - # zoom : 1.0 gameoverDelay : 1000 debug: showFpsGraph : false - enableGameLogging : false - # createGridTable : false - # showGridCoords : false + # enableGameLogging : false + # createGridCanvas : false + createGridTable : false + showGridCoords : false map: refSize : &ref_size 50 rockSizeMin : 12.5 @@ -17,7 +17,6 @@ pathing: overlayPathmap : false traceTrajectories : false ui: - createGridCanvas : true overlayOnPause : true showAttackCooldown : false showCountdown : true diff --git a/data/types/levels.yaml b/data/types/levels.yaml index 1a2b15d..2021d39 100644 --- a/data/types/levels.yaml +++ b/data/types/levels.yaml @@ -13,12 +13,12 @@ types: test: name: Da Test desc: A test level. - levelSize: 2000 500 + levelSize: 1000 500 bounds: - - [-50,-50, 2100,50] + - [-50,-50, 1100,50] - [-50,0, 50,500] - - [2001,0, 50,500] - - [-50,501, 2100,50] + - [1001,0, 50,500] + - [-50,501, 1100,50] walls: - type: wall args: [300,50, 50,200] # [x,y, w,h] @@ -31,20 +31,20 @@ types: - type: wall args: [450,300, 50,200] - - type: fence + - type: pit args: [360,210, 30,30] - type: rock args: [400,200, 25,25] - type: rock args: [425,225, 25,25] - - type: fence + - type: pit args: [460,210, 30,30] - - type: fence + - type: pit args: [10,210, 30,30] - - type: fence + - type: pit args: [110,210, 30,30] - - type: fence + - type: pit args: [210,210, 30,30] - type: rock @@ -57,6 +57,68 @@ types: args: [100,400, 50,50] - type: rock args: [150,300, 50,50] + + - type: rock + args: [560,100, 30,30] + - type: rock + args: [575,130, 20,20] + - type: rock + args: [550,150, 40,40] + - type: rock + args: [560,190, 10,10] + - type: pit + args: [560,210, 30,30] + - type: rock + args: [550,250, 25,25] + - type: rock + args: [550,275, 25,25] + - type: rock + args: [575,290, 10,10] + - type: rock + args: [560,300, 30,30] + - type: rock + args: [575,330, 20,20] + + - type: wall + args: [650,250, 50,50] + - type: pit + args: [500,400, 150,100] + + # moat + - type: pit + args: [725,50, 10,10] + - type: pit + args: [725,60, 25,280] + + # rock hallway + # - type: wall + # args: [750,0, 25,50] + # - type: wall + # args: [875,0, 25,50] + - type: rock + args: [725,0, 50,50] + - type: rock + args: [735,50, 10,10] + - type: rock + args: [745,50, 10,10] + - type: rock + args: [755,50, 10,10] + - type: rock + args: [765,50, 10,10] + - type: rock + args: [750,60, 10,10] + - type: rock + args: [760,60, 30,30] + - type: rock + args: [860,60, 30,30] + - type: rock + args: [760,160, 30,30] + - type: rock + args: [860,160, 30,30] + - type: rock + args: [760,260, 30,30] + - type: rock + args: [860,260, 30,30] units: - type: player @@ -68,12 +130,21 @@ types: - type: green align: 2 loc: [175,25] - # - type: green - # align: 2 - # loc: [425,125] + - type: green + align: 2 + loc: [525,25] + - type: green + align: 2 + loc: [675,425] + - type: orange + align: 2 + loc: [775,125] + - type: orange + align: 2 + loc: [775,325] items: - # - type: rockets - # loc: [325,275] + - type: rockets + loc: [75,275] - type: nitro loc: [325,25] @@ -94,20 +165,20 @@ types: - type: wall args: [100,100, 50,50] - - type: fence + - type: pit args: [360,210, 30,30] - type: rock args: [400,200, 25,25] - type: rock args: [425,225, 25,25] - - type: fence + - type: pit args: [460,210, 30,30] - - type: fence + - type: pit args: [10,210, 30,30] - - type: fence + - type: pit args: [110,210, 30,30] - - type: fence + - type: pit args: [210,210, 30,30] - type: rock @@ -163,20 +234,20 @@ types: - type: wall args: [100,100, 50,50] - - type: fence + - type: pit args: [360,210, 30,30] - type: rock args: [400,200, 25,25] - type: rock args: [425,225, 25,25] - - type: fence + - type: pit args: [460,210, 30,30] - - type: fence + - type: pit args: [10,210, 30,30] - - type: fence + - type: pit args: [110,210, 30,30] - - type: fence + - type: pit args: [210,210, 30,30] - type: rock @@ -229,20 +300,20 @@ types: - type: wall args: [100,100, 50,50] - - type: fence + - type: pit args: [360,210, 30,30] # - type: rock # args: [400,200, 25,25] # - type: rock # args: [425,225, 25,25] - - type: fence + - type: pit args: [460,210, 30,30] - - type: fence + - type: pit args: [10,210, 30,30] - - type: fence + - type: pit args: [110,210, 30,30] - - type: fence + - type: pit args: [210,210, 30,30] - type: rock diff --git a/data/types/units.yaml b/data/types/units.yaml index 15c7596..899fba6 100644 --- a/data/types/units.yaml +++ b/data/types/units.yaml @@ -46,6 +46,7 @@ types: body : '#E73075' turret : '#A72F5B' barrel : '#2E62C9' + blue: name: Blue Tank desc: A friendly blue tank. @@ -66,6 +67,7 @@ types: body : '#4596FF' turret : '#182B53' barrel : '#F25522' + green: name: Green Tank desc: A very green tank. @@ -77,7 +79,7 @@ types: move : 0.75 power : 1 speed : 0.5 - shots : 3 + shots : 5 ai: path : 1.0 dodge : 1.0 @@ -87,6 +89,28 @@ types: body : '#83BB32' turret : '#1C625B' barrel : '#D43B24' - + + orange: + name: Orange Tank + desc: A very orange tank. + tags: [ 'tank' ] + symbol: tanks/thing/tank.Tank + lootTable : rich + stats: + hp : 1 + move : 0.45 + power : 1 + speed : 0.35 + shots : 3 + ai: + path : 1.0 + dodge : 1.0 + shootIncoming : 0.10 + shootEnemy : 0.35 + colors: + body : '#EE8057' + turret : '#C13B00' + barrel : '#244792' + diff --git a/src/tanks/map/fence.cjs b/src/tanks/map/fence.cjs deleted file mode 100644 index d985260..0000000 --- a/src/tanks/map/fence.cjs +++ /dev/null @@ -1,69 +0,0 @@ -var Y = require('Y').Y -, Rect = require('ezl/shape').Rect - -, constants = require('tanks/constants') -, BoundsType = constants.BoundsType -, DensityType = constants.DensityType -, Wall = require('tanks/map/wall').Wall -, - - -Fence = -exports['Fence'] = -Wall.subclass('Fence', { - - isReflective : false, - - shadowFillStyle : 'rgba(0,0,0, 0.10)', - shadowSize : 10, - - fillStyle : 'rgba(0,0,0, 0.25)', - strokeStyle : 'rgba(0,0,0, 0.25)', - lineWidth : 0, - - blocking : BoundsType.BLOCKING, - density : DensityType.SPARSE, - isBoundary : false, - - - - init : function initFence(x,y, w,h){ - Wall.init.call(this, x,y, w,h, this.isBoundary); - }, - - render : function render(parent){ - if (this.isBoundary) - return this; - - if (this.shape) { - parent = parent || this.shape.parent; - this.shape.remove(); - } - - if (!parent) - return this; - - this.shape = - new Rect(this.width, this.height) - .position(this.loc.x, this.loc.y) - .fill(this.fillStyle) - .stroke(this.strokeStyle, this.lineWidth) - .appendTo( parent ); - - var ss = this.shadowSize; - this.shadow = - new Rect(this.width, this.height) - .position(0,0) - .fill(this.shadowFillStyle) - .stroke(this.strokeStyle, this.lineWidth) - .erase(ss,ss, -ss,-ss) - .appendTo( this.shape ); - - return this; - }, - - - toString : Wall.fn.toString - -}); - diff --git a/src/tanks/map/index.cjs b/src/tanks/map/index.cjs index eaf4b68..b6580d4 100644 --- a/src/tanks/map/index.cjs +++ b/src/tanks/map/index.cjs @@ -6,5 +6,5 @@ require('Y').Y 'Level' : require('tanks/map/level').Level, 'Wall' : require('tanks/map/wall').Wall, 'Rock' : require('tanks/map/rock').Rock, - 'Fence' : require('tanks/map/fence').Fence + 'Pit' : require('tanks/map/pit').Pit }); diff --git a/src/tanks/map/pathing/map.cjs b/src/tanks/map/pathing/map.cjs index 8b6b7d2..f36f041 100644 --- a/src/tanks/map/pathing/map.cjs +++ b/src/tanks/map/pathing/map.cjs @@ -28,7 +28,7 @@ QuadTree.subclass('Map', { allWalls : null, // All walls in this map innerWalls : null, // Non-boundary walls - denseWalls : null, // Non-boundary non-Fences + denseWalls : null, // Non-boundary non-Pits diff --git a/src/tanks/map/pit.cjs b/src/tanks/map/pit.cjs new file mode 100644 index 0000000..c562065 --- /dev/null +++ b/src/tanks/map/pit.cjs @@ -0,0 +1,69 @@ +var Y = require('Y').Y +, Rect = require('ezl/shape').Rect + +, constants = require('tanks/constants') +, BoundsType = constants.BoundsType +, DensityType = constants.DensityType +, Wall = require('tanks/map/wall').Wall +, + + +Pit = +exports['Pit'] = +Wall.subclass('Pit', { + + isReflective : false, + + shadowFillStyle : 'rgba(0,0,0, 0.10)', + shadowSize : 10, + + fillStyle : 'rgba(0,0,0, 0.25)', + strokeStyle : 'rgba(0,0,0, 0.25)', + lineWidth : 0, + + blocking : BoundsType.BLOCKING, + density : DensityType.SPARSE, + isBoundary : false, + + + + init : function initPit(x,y, w,h){ + Wall.init.call(this, x,y, w,h, this.isBoundary); + }, + + render : function render(parent){ + if (this.isBoundary) + return this; + + if (this.shape) { + parent = parent || this.shape.parent; + this.shape.remove(); + } + + if (!parent) + return this; + + this.shape = + new Rect(this.width, this.height) + .position(this.loc.x, this.loc.y) + .fill(this.fillStyle) + .stroke(this.strokeStyle, this.lineWidth) + .appendTo( parent ); + + var ss = this.shadowSize; + this.shadow = + new Rect(this.width, this.height) + .position(0,0) + .fill(this.shadowFillStyle) + .stroke(this.strokeStyle, this.lineWidth) + .erase(ss,ss, -ss,-ss) + .appendTo( this.shape ); + + return this; + }, + + + toString : Wall.fn.toString + +}); + diff --git a/src/tanks/ui/grid.cjs b/src/tanks/ui/grid.cjs index cc82a2c..141aa4a 100644 --- a/src/tanks/ui/grid.cjs +++ b/src/tanks/ui/grid.cjs @@ -37,26 +37,26 @@ Rect.subclass('Grid', { , h = this.canvasHeight ; - // if ( this.createGridTable ) { - // var tbody = $(''); - // Y(0, rows).forEach(function(y){ - // var row = $('').appendTo(tbody); - // Y(0, cols).forEach(function(x){ - // $(''+x+','+y+'') - // .width(side).height(side) - // .appendTo(row); - // }, this); - // }, this); - // - // this.table = - // $('') - // .width(this.layerWidth) - // .height(this.layerHeight) - // .append(tbody) - // .prependTo( this.layer ); - // - // } else - // this.table = null; + if ( this.createGridTable ) { + var tbody = $(''); + Y(0, rows).forEach(function(y){ + var row = $('').appendTo(tbody); + Y(0, cols).forEach(function(x){ + $('') + .width(side).height(side) + .appendTo(row); + }, this); + }, this); + + this.table = + $('
'+(x*side)+','+(y*side)+'
') + .width(this.layerWidth) + .height(this.layerHeight) + .append(tbody) + .prependTo( this.layer ); + + } else + this.table = null; if ( this.createGridCanvas ) { ctx.lineWidth = this.lineWidth; @@ -78,5 +78,5 @@ Rect.subclass('Grid', { }); -config.updateOnChange(['ui.createGridTable', 'ui.createGridCanvas'], Grid.fn); +config.updateOnChange(['debug.createGridTable', 'debug.createGridCanvas'], Grid.fn); diff --git a/src/tanks/ui/main.cjs b/src/tanks/ui/main.cjs index 5ca519a..8c9d2e6 100644 --- a/src/tanks/ui/main.cjs +++ b/src/tanks/ui/main.cjs @@ -35,15 +35,17 @@ function main(){ overlay = $('#overlay'); updateOverlay( config.get('ui.overlayOnPause') ); - config.on('set:ui.overlayOnPause', function(evt){ updateOverlay(evt.newval); }); - config.on('set:ui.debug.showFpsGraph', function(evt){ updateUI('#info', evt.newval); }); + config.on('set:ui.overlayOnPause', function(evt){ updateOverlay(evt.newval); }); + config.on('set:debug.showFpsGraph', function(evt){ updateUI('#info', evt.newval); }); + config.on('set:debug.showGridCoords', function(evt){ $('body')[(evt.newval ? 'add' : 'remove' )+'Class']('showGridCoords'); }); - // Player.on('create', function(evt){ P = evt.data.instance; }); + config.set('debug.showGridCoords', config.get('debug.showGridCoords')); /// Debug /// if (qkv.debug || config.get('debug.showFpsGraph')) updateUI('#info', SHOW); + // Show debug menus $(document).bind('keydown', 'ctrl+d', function(evt){ updateUI('.debug', TOGGLE); }); $(document).bind('keydown', 'ctrl+i', function(evt){ updateUI('#info', TOGGLE); }); diff --git a/src/tanks/ui/viewport.cjs b/src/tanks/ui/viewport.cjs index c9b14ea..a09ee1e 100644 --- a/src/tanks/ui/viewport.cjs +++ b/src/tanks/ui/viewport.cjs @@ -6,7 +6,7 @@ var Y = require('Y').Y , min = Y(Math.min).limit(2) , max = Y(Math.max).limit(2) -, PAD_X = 1024, PAD_Y = 690 +, PAD_X = 1024, PAD_Y = 690 // viewport padding is max iPad resolution (heh) , Viewport = @@ -15,12 +15,15 @@ HtmlLayer.subclass('Viewport', { _layerId : 'viewport', spacer : null, // inner layer to induce scrolling so we can arbitrarily center the elements - maxBleedX : 10, // Maximum amount of empty space to show to the left/right of content. (Tip: set to Infinity to disable) - maxBleedY : 10, // Maximum amount of empty space to show to the top/bottom of content. (Tip: set to Infinity to disable) + maxViewWidth : 600, // Max portal sizes + maxViewHeight : 520, + maxBleedX : 10, // Maximum amount of empty space to show (Tip: set to Infinity to disable) + maxBleedY : 10, init : function initViewport(props, attrs, html){ HtmlLayer.init.call(this, props, attrs, html); + this.css({ 'max-width':this.maxViewWidth, 'max-height':this.maxViewHeight }); this.spacer = $('
').appendTo(this.layer); }, diff --git a/www/css/lttl.css b/www/css/lttl.css index d6496cd..693085f 100644 --- a/www/css/lttl.css +++ b/www/css/lttl.css @@ -15,7 +15,7 @@ td { text-align:center; vertical-align:middle; } .bigblue { position:fixed; width:100%; top:50%; margin-top:-200px; z-index:1001; } .bigblue .box { width:400px; margin:0 auto; padding:1em; color:#000; background-color:#2992C5; - box-shadow:7.5px 7.5px 15px #000; -moz-box-shadow:7.5px 7.5px 15px #000; -webkit-box-shadow:7.5px 7.5px 15px #000; } + box-shadow:5px 5px 6px 2px rgba(0,0,0,0.4); -moz-box-shadow:5px 5px 6px 2px rgba(0,0,0,0.4); -webkit-box-shadow:5px 5px 6px 2px rgba(0,0,0,0.4); } .bigblue h1 { text-align:center; font-size:2em; letter-spacing:2px; } .bigblue h2 { font-size:1.1em; letter-spacing:2px; } .bigblue .start { margin:1.5em 0 0.5em; text-align:center; border:0; } @@ -49,8 +49,10 @@ td { text-align:center; vertical-align:middle; } /*** Game and Viewport ***/ #game { position:relative; width:100%; height:100%; margin:0; padding:0; } -#viewport { position:relative; width:100%; height:100%; max-width:1024px; max-height:690px; - overflow:hidden; cursor:crosshair; margin:0 auto; background-color:#3F3F3F; } +#viewport { width:100%; height:100%; /* max-width:1024px; max-height:690px; */ /* <- Set by Viewport class */ + position:relative; margin:10px auto; overflow:hidden; cursor:crosshair; + background-color:#3F3F3F; border:15px solid #222; + box-shadow:inset 0 0 5px 1px rgba(0,0,0,0.4); -moz-box-shadow:inset 0 0 5px 1px rgba(0,0,0,0.4); -webkit-box-shadow:inset 0 0 5px 1px rgba(0,0,0,0.4); } #viewport > .layer { margin:690px 1024px; } #viewport > .spacer { position:absolute; z-index:-1; width:1024px; height:690px; /* width:100%; height:100%; */ } #viewport .layer.grid { outline:1px solid rgba(255,255,255, 0.1); } @@ -99,12 +101,13 @@ td { text-align:center; vertical-align:middle; } #config input[type=checkbox] { top:0.33em; } -table.grid { position:absolute; top:0; left:0; z-index:10; } +#viewport .layer.grid { z-index:1000; } +table.grid { position:absolute; top:0; left:0; } table.grid, -table.grid td { /* outline:1px solid rgba(255,255,255,0.1); */ - color:transparent; font: 18pt monospace; +table.grid td { outline:1px solid rgba(255,255,255,0.05); + color:transparent; font: 10px/50px Menlo, monospace; text-align:center; margin:0; padding:0; white-space:nowrap; overflow:hidden; } -.showGridCoords table.grid td:hover { color:rgba(255,255,255,0.1); } +.showGridCoords table.grid td:hover { color:rgba(255,255,255,0.5); } /* #debug { position:relative; top:1em; right:1em; z-index:5000; } -- 1.7.0.4