Skip to content

Commit

Permalink
Moved shared state check
Browse files Browse the repository at this point in the history
Also added a note on it in the docs
  • Loading branch information
britzl committed Mar 19, 2018
1 parent 2bf9986 commit 375c00a
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 7 deletions.
7 changes: 7 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ An alternative approach is to ignore the ```set_view_projection``` message and d
...
end

NOTE: In order for this to work you need to make sure that the `Shared State` setting in the `Script` section of `game.project` is checked (defaults to checked)


### Feeding window size to the camera
It is recommended to send the window width and height from the render script to the camera module. This is required if any of the projectors provided in ```camera.lua``` is used. It also allows custom projectors to get the current window size by calling ```camera.get_window_size()```. Set the window size like this:

Expand All @@ -98,9 +101,13 @@ It is recommended to send the window width and height from the render script to
...
end

NOTE: In order for this to work you need to make sure that the `Shared State` setting in the `Script` section of `game.project` is checked (defaults to checked)


### Example render script
The orthographic/render folder contains a render script that does the above mentioned integration of the Orthographic Camera API. Use it as it is or copy it into your project and make whatever modifications that you need.


## The Orthographic Camera API - functions
The API can be used in two ways:

Expand Down
6 changes: 0 additions & 6 deletions orthographic/camera.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,6 @@

local M = {}

-- Check if 'shared_state' setting is on
-- From https://github.com/rgrams/rendercam/blob/master/rendercam/rendercam.lua#L4-L7
if sys.get_config("script.shared_state") ~= "1" then
error("ERROR - camera - 'shared_state' setting in game.project must be enabled for camera to work.")
end

M.SHAKE_BOTH = hash("both")
M.SHAKE_HORIZONTAL = hash("horizontal")
M.SHAKE_VERTICAL = hash("vertical")
Expand Down
8 changes: 7 additions & 1 deletion orthographic/render/orthographic.render_script
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
local camera = require "orthographic.camera"

-- Check if 'shared_state' setting is on
-- From https://github.com/rgrams/rendercam/blob/master/rendercam/rendercam.lua#L4-L7
if sys.get_config("script.shared_state") ~= "1" then
error("ERROR - camera - 'shared_state' setting in game.project must be enabled for camera to work.")
end


local DISPLAY_WIDTH = tonumber(sys.get_config("display.width"))
local DISPLAY_HEIGHT = tonumber(sys.get_config("display.height"))



function init(self)
self.tile_pred = render.predicate({"tile"})
self.gui_pred = render.predicate({"gui"})
Expand Down

0 comments on commit 375c00a

Please sign in to comment.