gemini 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/bin/gemini +18 -0
- data/build_configuration.rb +24 -0
- data/lib/ibxm.jar +0 -0
- data/lib/jinput.jar +0 -0
- data/lib/jogg-0.0.7.jar +0 -0
- data/lib/jorbis-0.0.15.jar +0 -0
- data/lib/jruby-complete.jar +0 -0
- data/lib/lwjgl.jar +0 -0
- data/lib/lwjgl_util_applet.jar +0 -0
- data/lib/native_files/OpenAL32.dll +0 -0
- data/lib/native_files/jinput-dx8.dll +0 -0
- data/lib/native_files/jinput-raw.dll +0 -0
- data/lib/native_files/libjinput-linux.so +0 -0
- data/lib/native_files/libjinput-linux64.so +0 -0
- data/lib/native_files/libjinput-osx.jnilib +0 -0
- data/lib/native_files/liblwjgl.jnilib +0 -0
- data/lib/native_files/liblwjgl.so +0 -0
- data/lib/native_files/liblwjgl64.so +0 -0
- data/lib/native_files/libopenal.so +0 -0
- data/lib/native_files/lwjgl.dll +0 -0
- data/lib/native_files/openal.dylib +0 -0
- data/lib/natives-linux.jar +0 -0
- data/lib/natives-mac.jar +0 -0
- data/lib/natives-win32.jar +0 -0
- data/lib/phys2d.jar +0 -0
- data/lib/slick.jar +0 -0
- data/package/jar/gemini.jar +0 -0
- data/src/base_state.rb +112 -0
- data/src/behavior.rb +230 -0
- data/src/behavior_event.rb +23 -0
- data/src/behaviors.txt +5 -0
- data/src/behaviors/animated_sprite.rb +51 -0
- data/src/behaviors/audible.rb +11 -0
- data/src/behaviors/axis_stateful.rb +33 -0
- data/src/behaviors/big_sprite.rb +56 -0
- data/src/behaviors/bounding_box_collidable.rb +25 -0
- data/src/behaviors/camera_anchored_drawable.rb +20 -0
- data/src/behaviors/cardinal_movable.rb +114 -0
- data/src/behaviors/clickable.rb +18 -0
- data/src/behaviors/countable.rb +31 -0
- data/src/behaviors/debug_physical.rb +31 -0
- data/src/behaviors/debug_tangible.rb +30 -0
- data/src/behaviors/drawable.rb +6 -0
- data/src/behaviors/drawable_shape.rb +43 -0
- data/src/behaviors/fading_image_trail_emittable.rb +28 -0
- data/src/behaviors/game_object_emittable.rb +12 -0
- data/src/behaviors/gravity_source.rb +21 -0
- data/src/behaviors/inertial.rb +11 -0
- data/src/behaviors/movable2d.rb +9 -0
- data/src/behaviors/multi_animated_sprite.rb +22 -0
- data/src/behaviors/physical.rb +348 -0
- data/src/behaviors/physical_cardinal_movable.rb +110 -0
- data/src/behaviors/physical_sprite.rb +29 -0
- data/src/behaviors/platformer_controllable.rb +144 -0
- data/src/behaviors/pointer.rb +28 -0
- data/src/behaviors/pressable.rb +13 -0
- data/src/behaviors/receives_events.rb +21 -0
- data/src/behaviors/regional.rb +71 -0
- data/src/behaviors/rotates_to_point.rb +18 -0
- data/src/behaviors/spatial.rb +41 -0
- data/src/behaviors/spline_stretchable_sprite.rb +45 -0
- data/src/behaviors/sprite.rb +99 -0
- data/src/behaviors/stateful.rb +31 -0
- data/src/behaviors/taggable.rb +27 -0
- data/src/behaviors/tangible.rb +51 -0
- data/src/behaviors/timeable.rb +79 -0
- data/src/behaviors/top_down_vehicle.rb +41 -0
- data/src/behaviors/triangle_trail_emittable.rb +41 -0
- data/src/behaviors/updates.rb +10 -0
- data/src/behaviors/updates_at_consistant_rate.rb +27 -0
- data/src/behaviors/vectored_movement.rb +47 -0
- data/src/behaviors/world_collidable.rb +8 -0
- data/src/color.rb +70 -0
- data/src/game_object.rb +174 -0
- data/src/game_objects/background.rb +9 -0
- data/src/game_objects/fading_image.rb +23 -0
- data/src/game_objects/icon_strip_counter_display.rb +58 -0
- data/src/game_objects/static_sprite.rb +18 -0
- data/src/game_objects/tangible_object.rb +4 -0
- data/src/game_objects/text.rb +59 -0
- data/src/game_objects/triangle_trail.rb +85 -0
- data/src/gemini.rb +110 -0
- data/src/gemini_version.rb +3 -0
- data/src/inflector.rb +68 -0
- data/src/input_helpers/joystick_dead_zone_filter.rb +9 -0
- data/src/listenable_mixin.rb +15 -0
- data/src/managers/basic_game_object_manager.rb +81 -0
- data/src/managers/basic_physics_manager.rb +97 -0
- data/src/managers/basic_render_manager.rb +48 -0
- data/src/managers/basic_tangible_manager.rb +33 -0
- data/src/managers/basic_update_manager.rb +27 -0
- data/src/managers/diagnostic/diagnostic_input_manager.rb +0 -0
- data/src/managers/input_manager.rb +229 -0
- data/src/managers/input_support/input_mapping.rb +126 -0
- data/src/managers/input_support/input_message.rb +5 -0
- data/src/managers/input_support/slick_input_listener.rb +19 -0
- data/src/managers/input_support/slick_input_message.rb +11 -0
- data/src/managers/input_support/slick_input_translator.rb +15 -0
- data/src/managers/message_queue.rb +54 -0
- data/src/managers/scrolling_render_manager.rb +44 -0
- data/src/managers/sound_manager.rb +60 -0
- data/src/managers/tag_manager.rb +43 -0
- data/src/math.rb +13 -0
- data/src/music.rb +14 -0
- data/src/org/rubyforge/rawr/Main.java +67 -0
- data/src/platform.rb +28 -0
- data/src/proc_enhancement.rb +5 -0
- data/src/project_generator.rb +122 -0
- data/src/skeleton.txt +10 -0
- data/src/spline.rb +13 -0
- data/src/states/input_diagnostic_state.rb +53 -0
- data/src/vector.rb +99 -0
- data/test/test_state.rb +3 -0
- metadata +181 -0
@@ -0,0 +1,19 @@
|
|
1
|
+
module Gemini
|
2
|
+
class SlickInputListener
|
3
|
+
include InputListener
|
4
|
+
|
5
|
+
def initialize(state)
|
6
|
+
@state = state
|
7
|
+
end
|
8
|
+
|
9
|
+
def isAcceptingInput
|
10
|
+
#@state == BaseState.active_state
|
11
|
+
true
|
12
|
+
end
|
13
|
+
|
14
|
+
def method_missing(method, *args)
|
15
|
+
return if (method == :inputEnded) || @state != BaseState.active_state
|
16
|
+
@state.manager(:message_queue).post_message SlickInputMessage.new(method, args)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Gemini
|
2
|
+
class SlickInputTranslator
|
3
|
+
SLICK_INPUT_TYPE_TRANSLATION = {
|
4
|
+
:keyPressed => [:key, :pressed], # which key?
|
5
|
+
:keyReleased => [:key, :released],
|
6
|
+
:mouseMoved => [:mouse, :moved],
|
7
|
+
:mousePressed => [:mouse, :pressed], # which button?
|
8
|
+
:mouseReleased => [:mouse, :released],
|
9
|
+
:mouseClicked => [:mouse, :clicked],
|
10
|
+
:mouseWheelMoved => [:mouse, :wheel_moved],
|
11
|
+
:controllerLeftPressed => [:controller, :pressed]
|
12
|
+
|
13
|
+
}
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
require 'thread'
|
2
|
+
module Gemini
|
3
|
+
|
4
|
+
# Message object that is posted to the MessageQueue.
|
5
|
+
class Message
|
6
|
+
attr_accessor :name, :value, :delta
|
7
|
+
def initialize(name, value, delta=nil)
|
8
|
+
@name = name
|
9
|
+
@value = value
|
10
|
+
@delta = delta
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
class MessageQueue < Gemini::GameObject
|
15
|
+
def load
|
16
|
+
@listeners = Hash.new {|h,k| h[k] = []}
|
17
|
+
@messages = Queue.new
|
18
|
+
end
|
19
|
+
|
20
|
+
def process_messages(delta)
|
21
|
+
until @messages.empty?
|
22
|
+
message = @messages.shift
|
23
|
+
message.delta = delta
|
24
|
+
|
25
|
+
@listeners[message.name].each do |listener|
|
26
|
+
begin
|
27
|
+
listener[1].call(message)
|
28
|
+
rescue Exception => e
|
29
|
+
# Replace this with a logger
|
30
|
+
$stderr << "Error in callback #{listener[1]} for key: #{listener[0]}\n#{e.class} - #{e.message}\n#{e.backtrace.join("\n")}"
|
31
|
+
java.lang.System.exit(1)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
def post_message(message)
|
38
|
+
@messages << message
|
39
|
+
end
|
40
|
+
|
41
|
+
# Listeners are registered on a certain type of message. This type is arbitrary
|
42
|
+
# and can be any symbol. The second parameter is a key that is used to identify
|
43
|
+
# the callback when it is removed. The third parameter is the callback object
|
44
|
+
# which must be a proc. Alternatively, the second parameter may be omitted and a
|
45
|
+
# block passed in its place.
|
46
|
+
def add_listener(type, key, callback=nil, &block)
|
47
|
+
@listeners[type.to_sym] << [key, callback || block]
|
48
|
+
end
|
49
|
+
|
50
|
+
def remove_listener(type, key)
|
51
|
+
@listeners[type.to_sym].delete_if {|listener| listener.first == key}
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,44 @@
|
|
1
|
+
require 'managers/basic_render_manager'
|
2
|
+
|
3
|
+
class ScrollingRenderManager < BasicRenderManager
|
4
|
+
attr_accessor :camera_position, :tracking_game_object
|
5
|
+
alias_method :set_camera_position, :camera_position=
|
6
|
+
alias_method :set_tracking_game_object, :tracking_game_object=
|
7
|
+
|
8
|
+
def load(camera_position_or_tracking_game_object=nil)
|
9
|
+
unless camera_position_or_tracking_game_object.nil?
|
10
|
+
if camera_position_or_tracking_game_object.kind_of? Vector
|
11
|
+
@camera_position = camera_position_or_tracking_game_object
|
12
|
+
else
|
13
|
+
@tracking_game_object = camera_position_or_tracking_game_object
|
14
|
+
end
|
15
|
+
end
|
16
|
+
@gl = Java::org::newdawn::slick::opengl::renderer::Renderer.get
|
17
|
+
super()
|
18
|
+
end
|
19
|
+
|
20
|
+
def renderer
|
21
|
+
@gl
|
22
|
+
end
|
23
|
+
|
24
|
+
def render(graphics)
|
25
|
+
translation = camera_position
|
26
|
+
@gl.gl_translatef(translation.x, translation.y, 0.0)
|
27
|
+
super
|
28
|
+
@gl.gl_translatef(-translation.x, -translation.y, 0.0)
|
29
|
+
end
|
30
|
+
|
31
|
+
def camera_position
|
32
|
+
@camera_position || calculate_object_position
|
33
|
+
end
|
34
|
+
|
35
|
+
def calculate_object_position
|
36
|
+
#TODO: This should go once declared method overriding is possible.
|
37
|
+
if @tracking_game_object.kind_of? TangibleSprite
|
38
|
+
body_position = @tracking_game_object.body_position
|
39
|
+
Vector.new(-(body_position.x - (@game_state.screen_width / 2)), -(body_position.y - (@game_state.screen_height / 2)))
|
40
|
+
else
|
41
|
+
Vector.new(-(body_position.x - (@game_state.screen_width / 2)), -(body_position.y - (@game_state.screen_height / 2)))
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
@@ -0,0 +1,60 @@
|
|
1
|
+
class SoundManager < Gemini::GameObject
|
2
|
+
#TODO: Raise errors if sounds/music loaded/used when not on the proper thread?
|
3
|
+
#TODO: We can't play oggs as sounds in Windows/Linux. We get an Open AL error: 40963
|
4
|
+
#Wrapper for org.newdawn.slick.Sound.
|
5
|
+
class Sound < Java::org::newdawn::slick::Sound; end
|
6
|
+
|
7
|
+
def load
|
8
|
+
@sounds = {}
|
9
|
+
end
|
10
|
+
|
11
|
+
def unload
|
12
|
+
@music.stop if @music
|
13
|
+
stop_all
|
14
|
+
end
|
15
|
+
|
16
|
+
def add_sound(reference, path)
|
17
|
+
@sounds[reference] = load_sound path
|
18
|
+
end
|
19
|
+
|
20
|
+
def play_sound(reference, volume = 1.0, pitch = 1.0)
|
21
|
+
@sounds[reference].play(pitch, volume)
|
22
|
+
end
|
23
|
+
|
24
|
+
def stop_all
|
25
|
+
@sounds.each_value {|s| s.stop if s.playing}
|
26
|
+
end
|
27
|
+
|
28
|
+
def loop_song(music_file_name, options={})
|
29
|
+
@music.stop if @music
|
30
|
+
begin
|
31
|
+
@music = Java::org::newdawn::slick::Music.new("data/#{music_file_name}", true)
|
32
|
+
@music.loop
|
33
|
+
rescue java.lang.RuntimeException
|
34
|
+
@music = Java::org::newdawn::slick::Music.new("../data/#{music_file_name}", true)
|
35
|
+
@music.loop
|
36
|
+
end
|
37
|
+
# volume MUST be set after loop is called
|
38
|
+
@music.volume = options[:volume] if options.has_key? :volume
|
39
|
+
end
|
40
|
+
|
41
|
+
def play_song(music_file_name)
|
42
|
+
@music.stop if @music
|
43
|
+
begin
|
44
|
+
@music = Java::org::newdawn::slick::Music.new("data/#{music_file_name}", true)
|
45
|
+
@music.play
|
46
|
+
rescue java.lang.RuntimeException
|
47
|
+
@music = Java::org::newdawn::slick::Music.new("../data/#{music_file_name}", true)
|
48
|
+
@music.play
|
49
|
+
end
|
50
|
+
end
|
51
|
+
private
|
52
|
+
|
53
|
+
def load_sound(sound_file_name)
|
54
|
+
begin
|
55
|
+
Sound.new("data/#{sound_file_name}")
|
56
|
+
rescue #java.lang.RuntimeException
|
57
|
+
Sound.new("../data/#{sound_file_name}")
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
class TagManager < Gemini::GameObject
|
2
|
+
def load
|
3
|
+
require 'behaviors/taggable'
|
4
|
+
@tagged_objects = Hash.new { |h,k| h[k] = [] }
|
5
|
+
listen_for(:after_add_game_object, @game_state.manager(:game_object)) do |game_object|
|
6
|
+
if game_object.kind_of? Taggable
|
7
|
+
game_object.tags.each do |tag|
|
8
|
+
@tagged_objects[tag] << game_object
|
9
|
+
end
|
10
|
+
listen_for(:tag_added, game_object) do |tag|
|
11
|
+
@tagged_objects[tag] << game_object
|
12
|
+
end
|
13
|
+
listen_for(:tag_removed, game_object) do |tag|
|
14
|
+
@tagged_objects[tag].delete game_object
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
listen_for(:after_remove_game_object, @game_state.manager(:game_object)) do |game_object|
|
20
|
+
if game_object.kind_of? Taggable
|
21
|
+
game_object.tags.each do |tag|
|
22
|
+
@tagged_objects[tag].delete game_object
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def find_by_all_tags(*tags)
|
29
|
+
tags[1..-1].inject(@tagged_objects[tags[0]]) do |results, tag|
|
30
|
+
results & @tagged_objects[tag]
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def find_by_any_tags(*tags)
|
35
|
+
tags.inject([]) do |results, tag|
|
36
|
+
results.concat @tagged_objects[tag]
|
37
|
+
end.uniq
|
38
|
+
end
|
39
|
+
|
40
|
+
def find_by_tag(tag)
|
41
|
+
@tagged_objects[tag]
|
42
|
+
end
|
43
|
+
end
|
data/src/math.rb
ADDED
data/src/music.rb
ADDED
@@ -0,0 +1,14 @@
|
|
1
|
+
# wraps the Music class on Slick to a module that can be included anywhere
|
2
|
+
module Music
|
3
|
+
# TODO: Support URLs
|
4
|
+
@@music = nil
|
5
|
+
|
6
|
+
def loop_song(music_file_name)
|
7
|
+
@@music.stop if @@music
|
8
|
+
@@music = Java::org::newdawn::slick::Music.new(music_file_name)
|
9
|
+
@@music.loop
|
10
|
+
# do we want to store the music for later?
|
11
|
+
|
12
|
+
end
|
13
|
+
|
14
|
+
end
|
@@ -0,0 +1,67 @@
|
|
1
|
+
package org.rubyforge.rawr;
|
2
|
+
|
3
|
+
import java.io.BufferedReader;
|
4
|
+
import java.io.InputStreamReader;
|
5
|
+
import java.io.InputStream;
|
6
|
+
import java.io.IOException;
|
7
|
+
import java.net.URL;
|
8
|
+
|
9
|
+
|
10
|
+
import java.util.ArrayList;
|
11
|
+
import org.jruby.Ruby;
|
12
|
+
import org.jruby.RubyInstanceConfig;
|
13
|
+
import org.jruby.javasupport.JavaEmbedUtils;
|
14
|
+
|
15
|
+
public class Main
|
16
|
+
{
|
17
|
+
public static void main(String[] args) throws Exception
|
18
|
+
{
|
19
|
+
RubyInstanceConfig config = new RubyInstanceConfig();
|
20
|
+
config.setArgv(args);
|
21
|
+
Ruby runtime = JavaEmbedUtils.initialize(new ArrayList(0), config);
|
22
|
+
String mainRubyFile = "main";
|
23
|
+
|
24
|
+
ArrayList<String> config_data = new ArrayList<String>();
|
25
|
+
try{
|
26
|
+
java.io.InputStream ins = Main.class.getClassLoader().getResourceAsStream("run_configuration");
|
27
|
+
if (ins == null ) {
|
28
|
+
System.err.println("Did not find configuration file 'run_configuration', using defaults.");
|
29
|
+
} else {
|
30
|
+
config_data = getConfigFileContents(ins);
|
31
|
+
}
|
32
|
+
}
|
33
|
+
catch(IOException ioe)
|
34
|
+
{
|
35
|
+
System.err.println("Error loading run configuration file 'run_configuration', using defaults: " + ioe);
|
36
|
+
}
|
37
|
+
catch(java.lang.NullPointerException npe)
|
38
|
+
{
|
39
|
+
System.err.println("Error loading run configuration file 'run_configuration', using defaults: " + npe );
|
40
|
+
}
|
41
|
+
|
42
|
+
for(String line : config_data) {
|
43
|
+
String[] parts = line.split(":");
|
44
|
+
if("main_ruby_file".equals(parts[0].replaceAll(" ", ""))) {
|
45
|
+
mainRubyFile = parts[1].replaceAll(" ", "");
|
46
|
+
}
|
47
|
+
}
|
48
|
+
|
49
|
+
runtime.evalScriptlet("require '" + mainRubyFile + "'");
|
50
|
+
}
|
51
|
+
|
52
|
+
public static URL getResource(String path) {
|
53
|
+
return Main.class.getClassLoader().getResource(path);
|
54
|
+
}
|
55
|
+
|
56
|
+
private static ArrayList<String> getConfigFileContents(InputStream input) throws IOException, java.lang.NullPointerException {
|
57
|
+
BufferedReader reader = new BufferedReader(new InputStreamReader(input));
|
58
|
+
String line;
|
59
|
+
ArrayList<String> contents = new ArrayList<String>();
|
60
|
+
|
61
|
+
while ((line = reader.readLine()) != null) {
|
62
|
+
contents.add(line);
|
63
|
+
}
|
64
|
+
reader.close();
|
65
|
+
return(contents);
|
66
|
+
}
|
67
|
+
}
|
data/src/platform.rb
ADDED
@@ -0,0 +1,28 @@
|
|
1
|
+
require 'rbconfig'
|
2
|
+
|
3
|
+
module Platform
|
4
|
+
|
5
|
+
@@operating_system = Config::CONFIG['host_os']
|
6
|
+
|
7
|
+
def using_unix?
|
8
|
+
@using_unix ||= !using_windows?
|
9
|
+
end
|
10
|
+
|
11
|
+
def using_windows?
|
12
|
+
@using_windows ||= (@@operating_system =~ /^win|mswin/i)
|
13
|
+
end
|
14
|
+
|
15
|
+
def using_linux?
|
16
|
+
@using_linux ||= (@@operating_system =~ /linux/)
|
17
|
+
end
|
18
|
+
|
19
|
+
def using_osx?
|
20
|
+
@using_osx ||= (@@operating_system =~ /darwin/)
|
21
|
+
end
|
22
|
+
|
23
|
+
def argument_delimiter
|
24
|
+
using_windows? ? ';' : ':'
|
25
|
+
end
|
26
|
+
|
27
|
+
module_function :using_unix?, :using_windows?, :using_osx?, :argument_delimiter, :using_linux?
|
28
|
+
end
|
@@ -0,0 +1,122 @@
|
|
1
|
+
require 'fileutils'
|
2
|
+
#require 'rawr'
|
3
|
+
|
4
|
+
module Gemini
|
5
|
+
class ProjectGenerator
|
6
|
+
include FileUtils
|
7
|
+
|
8
|
+
def initialize(options)
|
9
|
+
@project_dir = options[:project_dir]
|
10
|
+
@project_title = options[:project_title]
|
11
|
+
@rawr_install_args = options[:rawr_install]
|
12
|
+
end
|
13
|
+
|
14
|
+
def generate_project
|
15
|
+
generate_default_dirs
|
16
|
+
generate_main
|
17
|
+
generate_main_with_natives
|
18
|
+
copy_libs
|
19
|
+
rawr_install
|
20
|
+
generate_hello_world_state
|
21
|
+
copy_gemini_jar
|
22
|
+
end
|
23
|
+
|
24
|
+
def generate_main
|
25
|
+
mkdir_p File.expand_path(File.join(@project_dir, 'src'))
|
26
|
+
path = File.expand_path(File.join(@project_dir, 'src', 'main.rb'))
|
27
|
+
|
28
|
+
File.open(path, "w") do |f|
|
29
|
+
f << <<-ENDL
|
30
|
+
require 'java'
|
31
|
+
|
32
|
+
$LOAD_PATH.clear
|
33
|
+
$LOAD_PATH << File.expand_path(File.dirname(__FILE__))
|
34
|
+
|
35
|
+
# only when running in non-standalone
|
36
|
+
if File.exist? File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'java'))
|
37
|
+
jar_glob = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'java', '*.jar'))
|
38
|
+
Dir.glob(jar_glob).each do |jar|
|
39
|
+
$CLASSPATH << jar
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
require 'gemini'
|
44
|
+
|
45
|
+
begin
|
46
|
+
# Change :HelloState to point to the initial state of your game
|
47
|
+
Gemini::Main.start_app("", 800, 600, :HelloWorldState, false)
|
48
|
+
rescue => e
|
49
|
+
warn e
|
50
|
+
warn e.backtrace
|
51
|
+
end
|
52
|
+
ENDL
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def generate_main_with_natives
|
57
|
+
mkdir_p File.expand_path(File.join(@project_dir, 'src'))
|
58
|
+
path = File.expand_path(File.join(@project_dir, 'src', 'main_with_natives.rb'))
|
59
|
+
File.open(path, "w") do |f|
|
60
|
+
f << <<-ENDL
|
61
|
+
system("jruby -J-Djava.library.path=lib/native_files \#{File.expand_path(File.join(File.dirname(__FILE__)), 'main.rb')}")
|
62
|
+
ENDL
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def copy_gemini_jar
|
67
|
+
destination = File.expand_path(File.join(@project_dir, 'lib', 'java'))
|
68
|
+
source = File.expand_path(File.join(File.dirname(__FILE__), '..', 'package', 'jar', 'gemini.jar'))
|
69
|
+
|
70
|
+
mkdir_p destination
|
71
|
+
cp source, destination
|
72
|
+
end
|
73
|
+
|
74
|
+
#TODO: Implement
|
75
|
+
def build_gemini_jar
|
76
|
+
|
77
|
+
end
|
78
|
+
|
79
|
+
def generate_default_dirs
|
80
|
+
mkdir_p File.expand_path(File.join(@project_dir, 'src', 'game_objects'))
|
81
|
+
mkdir_p File.expand_path(File.join(@project_dir, 'src', 'behaviors'))
|
82
|
+
mkdir_p File.expand_path(File.join(@project_dir, 'src', 'input_mappings'))
|
83
|
+
mkdir_p File.expand_path(File.join(@project_dir, 'src', 'input_helpers'))
|
84
|
+
mkdir_p File.expand_path(File.join(@project_dir, 'src', 'states'))
|
85
|
+
end
|
86
|
+
|
87
|
+
def generate_hello_world_state
|
88
|
+
mkdir_p File.expand_path(File.join(@project_dir, 'src', 'states'))
|
89
|
+
path = File.expand_path(File.join(@project_dir, 'src', 'states', 'hello_world_state.rb'))
|
90
|
+
File.open(path, "w") do |f|
|
91
|
+
f << <<-ENDL
|
92
|
+
class HelloWorldState < Gemini::BaseState
|
93
|
+
end
|
94
|
+
ENDL
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
def rawr_install
|
99
|
+
mkdir_p @project_dir
|
100
|
+
# TODO: Replace with equivalent of Rake's FileUtils.sh method
|
101
|
+
puts `rawr install #{@rawr_install_args} #{@project_dir}`
|
102
|
+
build_config_path = File.join(@project_dir, 'build_configuration.rb')
|
103
|
+
build_config = File.read build_config_path
|
104
|
+
build_config.sub!('#c.java_library_path = "lib/java/native"', 'c.java_library_path = "lib/java/native_files"')
|
105
|
+
build_config.sub!('#c.jvm_arguments = "-server"', 'c.jvm_arguments = "-XX:+UseConcMarkSweepGC -Djruby.compile.mode=FORCE -Xms256m -Xmx512m"')
|
106
|
+
build_config.sub!(%Q{#c.jars[:data] = { :directory => 'data/images', :location_in_jar => 'images', :exclude => /bak/}}, %Q{c.jars[:data] = { :directory => 'data', :location_in_jar => 'data', :exclude => /bak/}})
|
107
|
+
build_config.sub!(%Q{#c.files_to_copy = Dir['other_files/dir/**/*']}, %Q{c.files_to_copy = Dir['lib/java/native_files/**/*']})
|
108
|
+
File.open(build_config_path, 'w') {|f| f << build_config}
|
109
|
+
end
|
110
|
+
|
111
|
+
def copy_libs
|
112
|
+
mkdir_p File.expand_path(File.join(@project_dir, 'lib', 'java'))
|
113
|
+
copy_libs = %w{ibxm.jar jinput.jar jogg-0.0.7.jar jorbis-0.0.15.jar lwjgl.jar lwjgl_util_applet.jar natives-linux.jar natives-mac.jar natives-win32.jar phys2d.jar slick.jar}
|
114
|
+
copy_libs.each do |copy_lib|
|
115
|
+
from = File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', copy_lib))
|
116
|
+
cp from, File.join(@project_dir, 'lib', 'java')
|
117
|
+
end
|
118
|
+
# mkdir_p File.expand_path(File.join(@project_dir, 'lib', 'java', 'native_libs'))
|
119
|
+
cp_r File.expand_path(File.join(File.dirname(__FILE__), '..', 'lib', 'native_files')) + '/', File.join(@project_dir, 'lib', 'java', 'native_files')
|
120
|
+
end
|
121
|
+
end
|
122
|
+
end
|