summaryrefslogtreecommitdiffhomepage
path: root/README.md
diff options
context:
space:
mode:
Diffstat (limited to 'README.md')
-rw-r--r--README.md33
1 files changed, 19 insertions, 14 deletions
diff --git a/README.md b/README.md
index 2069ab1..f6984c2 100644
--- a/README.md
+++ b/README.md
@@ -1,27 +1,32 @@
# Ruby2D Camera Demo
-`ruby run.rb` to run the demo
+`ruby run.rb` to run the demo.
----
-
-Controls:
+## Controls:
WASD to move character
-IJKL to move camera
-Q/E to rotate camera
-R to reset the rotation
+Q/E to rotate camera
+Hold R to reset the rotation
+Space to enter doors
+
+## How it works:
+
+A single `Camera` module exists which keeps track of objects that you add to it. When you add an object to the camera it creates a wrapper for the object and 'monkey patches' it onto the object to work with the camera.
----
+Feel free to use any part of this code in your own projects, no credit required(but is appreciated [^; )
-I wanted to make a proof of concept to see how feasible it is to implement a camera system in Ruby2D. Turns out it is very feasible :D
+## How to use the camera in your own code:
-How it works:
+Copy the `lib/camera/` directory into your ruby project and then in your code simply ```require_relative 'camera/camera'``` at the top. In your `Update do` loop you must add ```Camera.redraw``` at the bottom(this is so that the camera applies any changes you tell it to do). Your camera is now ready to use!
-A single `Camera` module exists which keeps track of objects that you add to it. When you add an object to the camera (currently only triangles) it creates a wrapper for the object and modifys it to work with the camera.
+To add an object to the camera simply do ```Camera << @your_object``` and the camera will do its magic on your object. Only the various shape/image/text/line/sprite/etc. from Ruby2D are supported.
+Whenever an object is wrapped by the camera it gets `x` and `y` methods if it does not already have them which you can use to move the object around in the camera. The text object also gets a `center` method which you can set to true if you wish the origin of text to be its center. Otherwise the origin of all objects is the top left corner. Other then these methods mentioned, object behave as expected within the context of the camera.
-If you want to use this little demo in your own projects feel free to do so! All you need is the camera.rb file and then just `require` or `require_relative` it into your project.
-See the code as an example for how it is used.
+When unloading an object, make sure to also remove it from the Camera or else it will attempt to update it when it is Nil. To do this use the following: `Camera.remove(@your_object)`
-Credit is appreciated but not required :)
+To manipulate the camera there are 4 variables you can use:
+- `Camera.zoom` Default: 1. This is a multiplier for how much you want the camera to be zoomed in(e.g 2 is 2x zoom, 0.5 is 0.5x zoom)
+- `Camera.x` and `Camera.y` Default: 0. This are the position of the camera in the "world"
+- `Camera.angle` Default: 0. This is the angle of how much the camera is rotated(in degrees). It ranges from 0-359. Giving values outside of this range will automagically convert them to fit within the 0-359 range.