Skip to content

Commit

Permalink
Updated Grid to build 1063
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmcwatters committed Aug 20, 2015
1 parent 35d4cb1 commit 8ecf202
Show file tree
Hide file tree
Showing 6 changed files with 315 additions and 1,258 deletions.
51 changes: 49 additions & 2 deletions src/engine/shared/entities/trigger_transition.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,46 @@ function trigger_transition:trigger_transition()
self:networkNumber( "height", 0 )
end

function trigger_transition:findRegionSpace()
local pos = self:getPosition()
local width = self:getNetworkVar( "width" )
local length = self:getNetworkVar( "height" )

-- Find region space north
local x = pos.x
local y = pos.y - game.tileSize - 1
local r = region.getAtPosition( vector( x, y ) )
if ( not r ) then
return x, y, "north"
end

-- Find region space east
x = pos.x + width
y = pos.y - length
r = region.getAtPosition( vector( x, y ) )
if ( not r and length > width ) then
return x, y, "east"
end

-- Find region space south
x = pos.x
y = pos.y
r = region.getAtPosition( vector( x, y ) )
if ( not r ) then
return x, y, "south"
end

-- Find region space west
x = pos.x
y = pos.y
r = region.getAtPosition( vector( x, y ) )
if ( not r and length > width ) then
return x, y, "west"
end

return pos.x, pos.y
end

function trigger_transition:getPlayersInOrNearRegion( region )
local t = {}
for _, player in ipairs( player.getAll() ) do
Expand Down Expand Up @@ -53,8 +93,15 @@ function trigger_transition:loadRegion()
return
end

local pos = self:getPosition()
region.load( name, pos.x, pos.y )
local x, y, direction = self:findRegionSpace()
if ( direction == "north" ) then
-- Find region length
local regionData = require( "regions." .. name )
local length = regionData.height * game.tileSize
y = y - length + 1
end

region.load( name, x, y )
end

function trigger_transition:removeRegion()
Expand Down
4 changes: 3 additions & 1 deletion src/engine/shared/region/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,11 @@ function region.reload( library )

local name = string.gsub( library, "regions.", "" )
local r = region.getByName( name )
local x = r:getX()
local y = r:getY()
r:cleanUp()
region.unload( name )
region.load( name )
region.load( name, x, y )
end

hook.set( "shared", region.reload, "onReloadScript", "reloadRegion" )
Expand Down
36 changes: 26 additions & 10 deletions src/engine/shared/region/layer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,32 @@ end

if ( _CLIENT ) then
function regionlayer:createSpriteBatch()
local image = self:getTileset():getImage():getDrawable()
local count = self:getWidth() * self:getHeight()
self.spritebatch = graphics.newSpriteBatch( image, count )
local tileset = self:getTileset()
if ( not tileset ) then
return
end

local image = tileset:getImage()
local count = self:getWidth() * self:getHeight()
self.spritebatch = graphics.newSpriteBatch( image:getDrawable(), count )
end

function regionlayer:draw()
if ( self:getType() == "tilelayer" ) then
graphics.push()
graphics.translate( self:getX(), self:getY() )
graphics.setOpacity( self:getOpacity() )
graphics.setColor( color.white )
graphics.draw( self:getSpriteBatch() )
graphics.pop()
if ( self:getType() ~= "tilelayer" ) then
return
end

local spritebatch = self:getSpriteBatch()
if ( not spritebatch ) then
return
end

graphics.push()
graphics.translate( self:getX(), self:getY() )
graphics.setOpacity( self:getOpacity() )
graphics.setColor( color.white )
graphics.draw( spritebatch )
graphics.pop()
end
end

Expand Down Expand Up @@ -94,6 +106,10 @@ if ( _CLIENT ) then
self:createSpriteBatch()

local spritebatch = self:getSpriteBatch()
if ( not spritebatch ) then
return
end

spritebatch:bind()

local tileset = self:getTileset()
Expand Down
3 changes: 2 additions & 1 deletion src/game/client/gui/hudmoveindicator.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,11 @@
class "hudmoveindicator" ( gui.panel )

function hudmoveindicator:hudmoveindicator( parent )
local name = "HUD Move Indicator"
local name = "HUD Move Indicator"
gui.panel.panel( self, parent, name )
self.width = graphics.getViewportWidth()
self.height = graphics.getViewportHeight()
self:setUseFullscreenFramebuffer( true )

self.options = gui.optionsitemgroup( self, name .. " Options Item Group" )
self.options:setWidth( 216 )
Expand Down
Loading

0 comments on commit 8ecf202

Please sign in to comment.