Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/danini-the-panini/gosu_lighting
Simple vector-based lighting for libgosu
https://github.com/danini-the-panini/gosu_lighting
Last synced: about 1 month ago
JSON representation
Simple vector-based lighting for libgosu
- Host: GitHub
- URL: https://github.com/danini-the-panini/gosu_lighting
- Owner: danini-the-panini
- Created: 2015-01-29T06:50:53.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-02-05T22:05:09.000Z (almost 10 years ago)
- Last Synced: 2024-11-18T12:09:40.385Z (about 2 months ago)
- Language: Ruby
- Size: 1.22 MB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
Gosu Lighting
=============Simple vector-based lighting for libgosu.
![alt tag](https://raw.github.com/jellymann/gosu_lighting/master/example.png)
How to use
----------```
$ gem install gosu_lighting
```Include the Circle and Rectangle module into your own circle and rectangle classes. Your circle class _MUST_ have x, y, and radius properties, and your rectangle class _MUST_ have x, y, width, and height properties. Both your circle and rectangle classes must implement a `draw` method that takes a `depth` argument.
To draw circles and rectangles and everything with lighting and shadows, put it in the light source `draw` block and call the circle/rectangle `draw_lit` method with the light source instance, which is passed to the block for convenience.
Here's a trivial example:
```ruby
require 'gosu'
require 'gosu_lighting'class MyCircle < Struct.new(:x, :y, :radius)
include GosuLghting::Circledef draw depth
# your own drawing logic
# use depth to make the object get 'shadowed' by other objects
end
endclass MyRectangle < Struct.new(:x, :y, :width, :height)
include GosuLghting::Rectangledef draw depth
# your own drawing logic
end
endclass MyGame < Gosu::Window
def init
@light_source = GosuLighting::Source.new x, y, radius
@circle = MyCircle.new(...)
@rectangle = MyRectangle.new(...)
enddef draw
@light_source.draw do |ls|
@circle.draw_lit ls
@rectandle.draw_lit ls
end
end
end
```Limitations
-----------1. Only handles circles and axis-aligned rectangles
2. Only really works with one light source