Skip to content

Commit

Permalink
Code drop
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewmcwatters committed Feb 6, 2016
1 parent ab4b650 commit 3a2cee3
Show file tree
Hide file tree
Showing 28 changed files with 1,661 additions and 393 deletions.
4 changes: 2 additions & 2 deletions src/engine/client/camera.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ require( "common.vector" )
local contexts = camera and camera.getWorldContexts() or {}
local entity = camera and camera.getParentEntity()
local position = camera and camera.getPosition() or vector()
local minZoom = camera and camera.getMinZoom() or 0.5
local maxZoom = camera and camera.getMaxZoom() or 2
local minZoom = camera and camera.getMinZoom() or 1
local maxZoom = camera and camera.getMaxZoom() or 4
local zoom = camera and camera.getZoom() or 1

local class = class
Expand Down
4 changes: 3 additions & 1 deletion src/engine/client/debugoverlay.lua
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,7 @@ local _G = _G
module( "debugoverlay" )

function rectangle( x, y, width, height, color, duration )
_G.g_DebugOverlay:rectangle( x, y, width, height, color, duration )
if ( _G.g_DebugOverlay ) then
_G.g_DebugOverlay:rectangle( x, y, width, height, color, duration )
end
end
8 changes: 6 additions & 2 deletions src/engine/client/gui/optionsmenu/audiooptionspanel.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,12 @@ end

function audiooptionspanel:updateSound()
local options = self.options
convar.setConvar( "snd_volume", options.masterVolume )
convar.setConvar( "snd_desktop", options.desktopSound and 1 or 0 )
if ( options.masterVolume ) then
convar.setConvar( "snd_volume", options.masterVolume )
end
if ( options.desktopSound ) then
convar.setConvar( "snd_desktop", options.desktopSound and 1 or 0 )
end
end

gui.register( audiooptionspanel, "audiooptionspanel" )
2 changes: 1 addition & 1 deletion src/engine/client/gui/optionsmenu/bindlistitem.lua
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ function bindlistitem:getKey()
return self.key
end

bindlistitem.keyTrap = function( key )
function bindlistitem.keyTrap( key )
local self = gui.bindlistitem.trappedItem
gui.bindlistitem.trappedItem = nil
self:setKey( key )
Expand Down
2 changes: 1 addition & 1 deletion src/engine/client/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -440,7 +440,7 @@ local function onReceivePlayerInitialized( payload )

require( "engine.client.camera" )
_G.camera.setParentEntity( localplayer )
_G.camera.setZoom( 1 )
_G.camera.setZoom( 2 )

if ( not _G._SERVER ) then
localplayer:initialSpawn()
Expand Down
88 changes: 88 additions & 0 deletions src/game/client/gui/hudgamemenu/spellitem.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
--========= Copyright © 2013-2016, Planimeter, All rights reserved. ==========--
--
-- Purpose: Spell Item class
--
--============================================================================--

class "spellitem" ( gui.button )

spellitem.trappedItem = trappedItem

function spellitem:spellitem( parent, name, spellName )
require( "game.shared.spells." .. spellName )

local spell = spell.getSpell( spellName )
local text = spell.name
gui.button.button( self, parent, name, text )
self.width = parent:getWidth()
self.height = 30
self.spell = spell
end

function spellitem:drawBackground()
local property = "button.backgroundColor"
local width = self:getWidth()
local height = self:getHeight()

if ( self:isDisabled() ) then
property = "button.disabled.backgroundColor"
graphics.setColor( self:getScheme( property ) )
graphics.rectangle( "fill", 1, 0, width - 2, height )
return
end

if ( self.mousedown and self.mouseover ) then
property = "button.mousedown.backgroundColor"
graphics.setColor( self:getScheme( property ) )
graphics.rectangle( "fill", 1, 0, width - 2, height )
elseif ( self.mousedown or self.mouseover ) then
property = "button.mouseover.backgroundColor"
graphics.setColor( self:getScheme( property ) )
graphics.rectangle( "fill", 1, 0, width - 2, height )
end
end

function spellitem:drawForeground()
end

function spellitem:drawText()
local property = "button.textColor"

if ( self:isDisabled() ) then
property = "button.disabled.textColor"
end

graphics.setColor( self:getScheme( property ) )

local font = self:getScheme( "font" )
graphics.setFont( font )
local margin = 18
local x = margin
local y = self:getHeight() / 2 - font:getHeight() / 2 - 2
graphics.print( self:getText(), x, y )

local label = "Key or Button"
local key = self:getKey()
x = self:getWidth() - margin - font:getWidth( label ) / 2 - font:getWidth( key ) / 2
graphics.print( key, x, y )
end

function spellitem:getSpell()
return self.spell
end

function spellitem.keyTrap( key )
local self = gui.spellitem.trappedItem
gui.spellitem.trappedItem = nil
self:setKey( key )
os.setCursorVisible( true )
return true
end

function spellitem:onClick()
gui.spellitem.trappedItem = self
os.setCursorVisible( false )
input.setKeyTrap( self.keyTrap )
end

gui.register( spellitem, "spellitem" )
41 changes: 41 additions & 0 deletions src/game/client/gui/hudgamemenu/spells.lua
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,47 @@ function hudgamemenuspells:hudgamemenuspells( parent )
gui.panel.panel( self, parent, "Spells" )
self:setScheme( "Default" )
self:setSize( parent:getSize() )

local panel = gui.scrollablepanel( self, "Spells Scrollable Panel" )
panel:setSize( self:getWidth(), 345 )
panel:setY( 86 + 31 + 18 )
self.innerPanel = panel:getInnerPanel()
end

local function getLastY( self )
local children = self:getChildren()
if ( children ) then
local y = 0
for _, panel in ipairs( children ) do
y = y + panel:getHeight()
end
return y
end
return 0
end

function hudgamemenuspells:addSpell( spell )
local panel = self:getInnerPanel()
local name = spell .. " Spell Item"
local y = getLastY( panel )
local spell = gui.spellitem( panel, name, spell )
spell:setY( y )
self:setInnerHeight( getLastY( panel ) )
end

function hudgamemenuspells:removeSpells()
local panel = self:getInnerPanel()
panel:removeChildren()
self:setInnerHeight( getLastY( panel ) )
end

function hudgamemenuspells:getInnerPanel()
return self.innerPanel
end

function hudgamemenuspells:setInnerHeight( height )
local innerPanel = self:getInnerPanel()
innerPanel:setInnerHeight( height )
end

gui.register( hudgamemenuspells, "hudgamemenuspells" )
2 changes: 1 addition & 1 deletion src/game/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ local _G = _G
module( "game" )

appSecret = ""
tileSize = 32
tileSize = 16
initialRegion = "test_01"

function conf( c )
Expand Down
12 changes: 11 additions & 1 deletion src/game/shared/spells/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,18 @@ class "spell"

spell.spells = spells

spell.name = "Unknown Spell"

function spell.getSpell( name )
return spell.spells[ name ]
end

function spell.invoke()
return
end

function spell.register( class, name )
spell.spells[ name ] = class
getfenv( 2 )[ name ] = nil
end

function spell:spell()
Expand Down
Binary file modified src/images/entities/item_apple/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/images/entities/item_apple/2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/images/entities/prop_chest.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/images/entities/prop_tree/1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/images/entities/prop_worldgate_spawn.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/images/moveindicator.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
return {
image = "images/moveindicator.png",
width = 32,
height = 32,
width = 16,
height = 16,
frametime = 0.04,
animations = {
click = {
Expand Down
Binary file modified src/images/moveindicator.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/images/player.lua
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
return {
image = "images/player.png",
width = 32,
height = 64,
width = 16,
height = 32,
frametime = 0.2,
animations = {
idle = {
Expand Down
Binary file modified src/images/player.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/images/tilesets/architect.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/images/tilesets/developer.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified src/images/tilesets/world.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
4 changes: 2 additions & 2 deletions src/regions/Architect.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset name="Architect" tilewidth="32" tileheight="32">
<image source="../images/tilesets/architect.png" width="64" height="64"/>
<tileset name="Architect" tilewidth="16" tileheight="16">
<image source="../images/tilesets/architect.png" width="32" height="32"/>
</tileset>
4 changes: 2 additions & 2 deletions src/regions/Developer.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset name="Developer" tilewidth="32" tileheight="32">
<image source="../images/tilesets/developer.png" width="64" height="64"/>
<tileset name="Developer" tilewidth="16" tileheight="16">
<image source="../images/tilesets/developer.png" width="32" height="32"/>
</tileset>
4 changes: 2 additions & 2 deletions src/regions/World.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<tileset name="World" tilewidth="32" tileheight="32">
<image source="../images/tilesets/world.png" width="512" height="512"/>
<tileset name="World" tilewidth="16" tileheight="16">
<image source="../images/tilesets/world.png" width="256" height="256"/>
<tile id="8">
<properties>
<property name="walkable" value="false"/>
Expand Down
Loading

0 comments on commit 3a2cee3

Please sign in to comment.