summaryrefslogtreecommitdiffhomepage
path: root/README.mdown
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2021-08-09 08:21:26 -0400
committerrealtradam <[email protected]>2021-08-09 08:21:26 -0400
commit026c466d05a7eda8f3f16f07c172acb567251119 (patch)
tree26684648a73e8ff53e6a1179e013fec318286302 /README.mdown
parentf0496c534e9a3b7393f580a7bb44428be8c2a1cf (diff)
downloadruby2d-camera-026c466d05a7eda8f3f16f07c172acb567251119.tar.gz
ruby2d-camera-026c466d05a7eda8f3f16f07c172acb567251119.zip
added coordinate_to_screenspace and coordinate_to_worldspace methods to Camera1.1.0
Diffstat (limited to 'README.mdown')
-rw-r--r--README.mdown5
1 files changed, 5 insertions, 0 deletions
diff --git a/README.mdown b/README.mdown
index 2a2e865..6152d07 100644
--- a/README.mdown
+++ b/README.mdown
@@ -19,6 +19,11 @@ Create your object as if you would create it in Ruby2D except you need to prefix
- `Camera.x` and `Camera.y` Default: 0. This is the position the camera is centered on in the "world"
- `Camera.angle` Default: 0. This is the angle of how much the camera is rotated(in degrees). It ranges from 0-360. Giving values outside of this range will automagically convert them to fit within the 0-360 range.
+### There are also 2 helpful functions:
+
+- `Camera.coordinate_to_worldspace(x,y)` You pass coordinates on the screen(for example where a player clicked in the window) and it will return the coordinates(in a 2d array) what the coordinates are in the world
+- `Camera.coordinate_to_screenspace(x,y)` You pass in a coordinate in the world(for example an enemy in your game) and it will give you the coordinates(in a 2d array) of where on the screen this character appears. Note this function may return values that are outside of the screen if the object is not in view of the camera
+
## How it works:
A single `Camera` module exists which keeps track of objects created with it. When you create an object with the camera it creates a special object that inherits the original object from Ruby2D and then adds additional functions. The Camera module then uses these functions to draw the various objects on the screen each frame, using the parameters you gave it.