-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of ssh://LoganBarnett@git.kenai.com/jemini~main…
…line
- Loading branch information
Showing
16 changed files
with
454 additions
and
22 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
Jemini 2009.10.27 | ||
Jemini 2009.11.24 | ||
|
||
== Description | ||
|
||
Jemini is a game library designed to allow creation of reusable features. How many times has someone implemented the aiming on a first person shooter, or a minimap on a real time strategy? Jemini comes packaged with lots of behaviors out of the box, with the ability to easily author more. Jemini uses Phys2D and Slick for physics and graphics, with 3D on the roadmap. | ||
|
||
== Installation | ||
|
||
At a command line, type: | ||
|
||
sudo gem install jemini | ||
|
||
(Leave off the "sudo" if on Windows.) | ||
|
||
== License | ||
|
||
Jemini is released under the BSD license. See the COPYING file for the full license. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#Allows an object to load attributes from a file. | ||
class Configurable < Jemini::Behavior | ||
|
||
#The loaded configuration for the object. | ||
attr_reader :config | ||
|
||
#Loads a configuration with the given name. | ||
def configure_as(key) | ||
string = game_state.manager(:config).get_config(key) | ||
@config = parse(string) | ||
end | ||
|
||
private | ||
|
||
#Parse the config string, returning a hash of attributes. | ||
def parse(string) | ||
attributes = {} | ||
string.split("\n").each do |line| | ||
line.strip! | ||
next if line.empty? | ||
next if line =~ /^#/ | ||
if line =~ /^([^=]+)=(.*)$/ | ||
key = $1.strip.to_sym | ||
value = parse_value($2.strip) | ||
attributes[key] = value | ||
end | ||
end | ||
attributes | ||
end | ||
|
||
#Treats quoted strings as strings, unquoted numbers as numbers. | ||
def parse_value(value) | ||
case value | ||
when /^"(.*)"$/ | ||
escape($1) | ||
when /^([\-\d]+)$/ | ||
$1.to_i | ||
when /^([\-\d\.]+)$/ | ||
$1.to_f | ||
else | ||
escape(value) | ||
end | ||
end | ||
|
||
def escape(string) | ||
string.gsub!(/\\\"/, '"') | ||
string.gsub!(/\\\\/, '\\') | ||
string | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# draws a line on the screen | ||
class DrawableEllipse < Jemini::Behavior | ||
java_import 'org.newdawn.slick.geom.Ellipse' | ||
java_import 'org.newdawn.slick.Color' | ||
depends_on :Spatial | ||
wrap_with_callbacks :draw | ||
|
||
#The Color to draw the ellipse in. | ||
attr_accessor :color | ||
#If true, the shape will be drawn filled in. If false, only the frame will be drawn. | ||
attr_accessor :ellipse_filled | ||
|
||
def load | ||
@color = Color.white | ||
@ellipse_filled = true | ||
@ellipse = Ellipse.new @game_object.position.x, @game_object.position.y, 1.0, 1.0 | ||
@game_object.on_after_position_changes { set_drawing_location } | ||
end | ||
|
||
#The ellipse height. | ||
def height=(value) | ||
@ellipse.radius2 = value / 2.0 | ||
set_drawing_location | ||
end | ||
def height | ||
@ellipse.radius2 * 2.0 | ||
end | ||
|
||
#The ellipse width. | ||
def width=(value) | ||
@ellipse.radius1 = value / 2.0 | ||
set_drawing_location | ||
end | ||
def width | ||
@ellipse.radius1 * 2.0 | ||
end | ||
|
||
#Draw an outline to the given graphics context. | ||
def draw(graphics) | ||
graphics.set_color @color | ||
if @ellipse_filled | ||
graphics.fill @ellipse | ||
else | ||
graphics.draw @ellipse | ||
end | ||
end | ||
|
||
private | ||
def set_drawing_location | ||
@ellipse.x = @game_object.position.x - @ellipse.radius1 | ||
@ellipse.y = @game_object.position.y - @ellipse.radius2 | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
# draws a line on the screen | ||
class DrawableRectangle < Jemini::Behavior | ||
java_import 'org.newdawn.slick.geom.Rectangle' | ||
java_import 'org.newdawn.slick.Color' | ||
depends_on :Spatial | ||
wrap_with_callbacks :draw | ||
|
||
#The Color to draw the shape in. | ||
attr_accessor :color | ||
#If true, the shape will be drawn filled in. If false, only the frame will be drawn. | ||
attr_accessor :rectangle_filled | ||
|
||
def load | ||
@color = Color.white | ||
@rectangle_filled = true | ||
@rectangle = Rectangle.new @game_object.position.x, @game_object.position.y, 1.0, 1.0 | ||
@game_object.on_after_position_changes { set_drawing_location } | ||
end | ||
|
||
#The rectangle height. | ||
def height=(value) | ||
@rectangle.height = value | ||
set_drawing_location | ||
end | ||
def height | ||
@rectangle.height | ||
end | ||
|
||
#The rectangle width. | ||
def width=(value) | ||
@rectangle.width = value | ||
set_drawing_location | ||
end | ||
def width | ||
@rectangle.width | ||
end | ||
|
||
#Draw an outline to the given graphics context. | ||
def draw(graphics) | ||
graphics.set_color @color | ||
if @rectangle_filled | ||
graphics.fill @rectangle | ||
else | ||
graphics.draw @rectangle | ||
end | ||
end | ||
|
||
private | ||
def set_drawing_location | ||
@rectangle.x = @game_object.position.x - (@rectangle.width / 2.0) | ||
@rectangle.y = @game_object.position.y - (@rectangle.height / 2.0) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
class ConfigManager < Jemini::GameObject | ||
|
||
def load | ||
@configs = {} | ||
end | ||
|
||
#Takes a reference to a config loaded via the resource manager, and returns it. | ||
def get_config(reference) | ||
game_state.manager(:resource).get_config(reference) | ||
end | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
shot_power = 75 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.