jruby-slick 1.1b → 1.1.0

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,3 +1,3 @@
1
- slick/*
1
+ vendor/*
2
2
  .DS_Store
3
- *.gem
3
+ *.gem
data/bin/jruby-slick.rb CHANGED
@@ -3,8 +3,36 @@ require 'rubygems'
3
3
  require 'rake'
4
4
 
5
5
  gem_dir = Gem::Specification.find_by_name("jruby-slick").gem_dir
6
-
7
6
  Rake.application.rake_require "jruby-slick", ["#{gem_dir}/jruby-slick/tasks"]
8
- Rake::Task['download_slick'].invoke
9
- Rake::Task['setup_natives'].invoke
10
- Rake::Task['build_example'].invoke
7
+
8
+ args = ARGV
9
+ nothing_run = true
10
+
11
+ if args.include? "install"
12
+ Rake::Task['download_slick'].invoke
13
+ Rake::Task['setup_natives'].invoke
14
+ Rake::Task['build_example'].invoke
15
+ nothing_run = false
16
+ end
17
+
18
+ if args.include? "gamestate"
19
+ idx = args.index "gamestate"
20
+ filename = "example_game_state.rb"
21
+ classname = "ExampleGameState"
22
+ unless args[idx+1].nil?
23
+ filename = "#{args[idx+1]}_game_state.rb"
24
+ classname = "#{args[idx+1]}_game_state".gsub(/\_[a-z]/) do |m|
25
+ m.upcase.gsub("_","")
26
+ end.capitalize
27
+ end
28
+
29
+ Rake::Task[:generate_game_state].invoke(filename, classname)
30
+ nothing_run = false
31
+ end
32
+
33
+ if nothing_run || args.include?("-h") || args.include?("--help")
34
+ puts "\njruby slick commands:\n"
35
+ puts " install - downloads the slick.jar, lwjgl natives, and gives an example file."
36
+ puts " gamestate [name] - generates a base gamestate file for you in lib/. Optional name will change class & filename. Example: `jruby-slick.rb gamestate=awesome` would create awesome.rb"
37
+ puts " -h | --help - shows this menu"
38
+ end
@@ -1,58 +1,96 @@
1
1
  require 'net/http'
2
+ require 'open-uri'
2
3
  require 'fileutils'
3
4
  require 'rubygems'
4
5
  require 'zip/zipfilesystem'
5
6
  require 'rbconfig'
6
- desc 'Download Slick Distribution'
7
7
 
8
+ desc 'Download Slick Distribution'
8
9
  task :download_slick do
9
-
10
- FileUtils.rm_rf "vendor/slick"
11
10
  FileUtils.mkdir_p "vendor/slick"
12
11
 
13
- res = Net::HTTP.get_response(URI("http://slick.cokeandcode.com/downloads/slick.zip"))
14
- File.open("temp.zip", "w+") do |f|
12
+ res = Net::HTTP.get_response(URI("http://www.slick2d.org/downloads/slick.jar"))
13
+ File.open("vendor/slick/slick.jar", "w+") do |f|
15
14
  f.write(res.body)
16
15
  end
17
- Zip::ZipFile.open("temp.zip") do |zipfile|
18
- zipfile.each do |entry|
19
- if entry.file? && /^lib\// =~ entry.name
20
- entry.extract entry.to_s.gsub(/^lib/, "vendor/slick")
21
- end
22
- end
23
- end
24
- File.delete("temp.zip")
16
+ puts "slick.jar downloaded into vendor/slick directory"
25
17
  end
26
18
 
19
+ desc 'Setup lwjgl natives'
27
20
  task :setup_natives do
28
21
  FileUtils.mkdir_p "bin" unless File.exists? "bin"
29
22
  target = RbConfig::CONFIG['target_os'].downcase
30
- platform = ''
23
+ platform = []
31
24
  if target.index('mswin')
32
- platform = 'mingw'
25
+ platform << 'windows'
26
+ valid = false
27
+ puts "Since you are using windows, please specify whether you are using 32 or 64 bit (32/64)"
28
+ bit = ''
29
+ until valid
30
+ bit = gets.chomp
31
+ valid = /^(32|64)$/ =~ bit
32
+ puts "Please enter 32 or 64" if !valid
33
+ end
34
+ platform << bit
33
35
  elsif target.index('darwin')
34
- platform = 'mac'
36
+ platform << 'macosx'
37
+ puts "Determined you are on OS X"
35
38
  elsif target.index('linux')
36
- platform = 'linux'
39
+ platform << 'linux'
40
+ puts "Determined you are on Linux"
41
+ end
42
+
43
+ puts "Downloading LWJGL"
44
+ open("lwjgl.zip", "wb") do |f|
45
+ f.print open("http://downloads.sourceforge.net/project/java-game-lib/Official%20Releases/LWJGL%202.8.5/lwjgl-2.8.5.zip?r=http%3A%2F%2Fsourceforge.net%2Fprojects%2Fjava-game-lib%2Ffiles%2FOfficial%2520Releases%2FLWJGL%25202.8.5%2F&ts=1354580536&use_mirror=iweb").read
37
46
  end
38
47
 
39
- Dir['vendor/slick/*.jar'].each do |jar_file|
40
- if jar_file.index('natives-') && jar_file.gsub('vendor/slick/natives-', '').gsub('.jar', '') == platform
41
- Zip::ZipFile.open(jar_file) do |natives|
42
- natives.each do |f|
43
- path = "bin/#{f.to_s}"
44
- File.delete path if File.exists? path
45
- f.extract "bin/#{f.to_s}"
48
+ puts "Finished downloading LWJGL"
49
+
50
+ Zip::ZipFile.open("lwjgl.zip") do |natives|
51
+ natives.each do |entry|
52
+ if entry.file? && /^lwjgl-2.8.5\/native\/#{platform[0]}/ =~ entry.name
53
+ target = "bin/#{entry.name.split('/')[-1]}"
54
+ unless File.exists? target
55
+ entry.extract target
56
+ puts "wrote file: #{target}"
57
+ end
58
+ elsif entry.file? && entry.name == "lwjgl-2.8.5/jar/lwjgl.jar" || entry.name == "lwjgl-2.8.5/jar/jinput.jar"
59
+ target = "vendor/slick/#{entry.name.split('/')[-1]}"
60
+ unless File.exists? target
61
+ entry.extract target
62
+ puts "wrote file: #{target}"
46
63
  end
47
64
  end
48
65
  end
49
66
  end
67
+
68
+ puts "removed lwjgl.zip"
69
+ FileUtils.rm "lwjgl.zip"
50
70
  end
51
71
 
72
+ desc 'Build base example file'
52
73
  task :build_example do
53
74
  gem_dir = Gem::Specification.find_by_name("jruby-slick").gem_dir
54
75
 
55
76
  unless File.exists? "bin/example.rb"
56
77
  FileUtils.cp "#{gem_dir}/jruby-slick/template/example.rb", "bin/example.rb"
57
78
  end
79
+ end
80
+
81
+ desc 'generate a default gamestate file'
82
+ task :generate_game_state, :file_name, :class_name do |t, args|
83
+ gem_dir = Gem::Specification.find_by_name("jruby-slick").gem_dir
84
+ file_name = args[:file_name]
85
+ class_name = args[:class_name]
86
+
87
+ FileUtils.mkdir_p "lib"
88
+ if File.exists? "lib/#{file_name}"
89
+ puts "File lib/#{file_name} already exists, will not overwrite. Delete it and run the command again if you wish to replace."
90
+ else
91
+ FileUtils.cp "#{gem_dir}/jruby-slick/template/example_game_state.rb", "lib/#{file_name}"
92
+ text = IO.read("lib/#{file_name}")
93
+ IO.write("lib/#{file_name}", text.gsub("ExampleGameState", class_name))
94
+ puts "Created file lib/#{file_name}"
95
+ end
58
96
  end
@@ -22,5 +22,5 @@ class ExampleGame < StateBasedGame
22
22
  end
23
23
 
24
24
  app = AppGameContainer.new(ExampleGame.new)
25
- app.setDisplayMode(GunzABlazin.width, GunzABlazin.height, false)
25
+ app.setDisplayMode(800, 600, false)
26
26
  app.start()
@@ -0,0 +1,116 @@
1
+ java_import org.lwjgl.input.Keyboard
2
+ java_import org.lwjgl.opengl.Display
3
+ java_import org.lwjgl.opengl.GL11
4
+ java_import org.newdawn.slick.GameContainer
5
+ java_import org.newdawn.slick.Graphics
6
+ java_import org.newdawn.slick.Image
7
+ java_import org.newdawn.slick.Input
8
+ java_import org.newdawn.slick.SlickException
9
+ java_import org.newdawn.slick.state.GameState
10
+ java_import org.newdawn.slick.state.StateBasedGame
11
+
12
+ class ExampleGameState
13
+ include GameState
14
+
15
+ def enter(gc, sbg)
16
+ end
17
+
18
+ def getID
19
+ # should return a unique number for each state you have in your game
20
+ 0
21
+ end
22
+
23
+ def initialize()
24
+ end
25
+
26
+ def init(gc, sbg)
27
+
28
+ end
29
+
30
+ def render(gc, sbg, g)
31
+
32
+ end
33
+
34
+ def update(gc, sbg, delta)
35
+
36
+ end
37
+
38
+ def isAcceptingInput
39
+ false
40
+ end
41
+
42
+ def leave(gc, sbg)
43
+
44
+ end
45
+
46
+ def inputEnded
47
+
48
+ end
49
+
50
+ def setInput(arg)
51
+
52
+ end
53
+
54
+ def keyPressed(keyval, keyChar)
55
+
56
+ end
57
+
58
+ def keyReleased(keyval, keyChar)
59
+
60
+ end
61
+
62
+ def isRenderPaused
63
+
64
+ end
65
+
66
+ def isUpdatePaused
67
+
68
+ end
69
+
70
+
71
+ def controllerButtonPressed(arg0, arg1)
72
+ end
73
+
74
+ def controllerButtonReleased(arg0, arg1)
75
+ end
76
+
77
+ def controllerDownPressed(arg0)
78
+ end
79
+
80
+ def controllerDownReleased(arg0)
81
+ end
82
+
83
+ def controllerLeftPressed(arg0)
84
+ end
85
+
86
+ def controllerLeftReleased(arg0)
87
+ end
88
+
89
+ def controllerRightPressed(arg0)
90
+ end
91
+
92
+ def controllerRightReleased(arg0)
93
+ end
94
+
95
+ def controllerUpPressed(arg0)
96
+ end
97
+
98
+ def controllerUpReleased(arg0)
99
+ end
100
+
101
+ def mouseClicked(arg0, arg1, arg2, arg3)
102
+ end
103
+
104
+ def mouseMoved(arg0, arg1, arg2, arg3)
105
+ end
106
+
107
+ def mousePressed(arg0, arg1, arg2, arg3)
108
+ end
109
+
110
+ def mouseReleased(arg0, arg1, arg2, arg3)
111
+ end
112
+
113
+ def mouseWheelMoved(arg0)
114
+ end
115
+
116
+ end
metadata CHANGED
@@ -1,32 +1,52 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jruby-slick
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1b
5
- prerelease: 3
4
+ prerelease:
5
+ version: 1.1.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Aaron McLeod
9
- autorequire:
9
+ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-08-08 00:00:00.000000000 Z
12
+ date: 2012-12-04 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- name: rake
16
- requirement: !ruby/object:Gem::Requirement
15
+ name: rubyzip
16
+ version_requirements: !ruby/object:Gem::Requirement
17
+ requirements:
18
+ - - ! '>='
19
+ - !ruby/object:Gem::Version
20
+ version: !binary |-
21
+ MA==
17
22
  none: false
23
+ requirement: !ruby/object:Gem::Requirement
18
24
  requirements:
19
25
  - - ! '>='
20
26
  - !ruby/object:Gem::Version
21
- version: '0'
22
- type: :development
27
+ version: !binary |-
28
+ MA==
29
+ none: false
23
30
  prerelease: false
31
+ type: :runtime
32
+ - !ruby/object:Gem::Dependency
33
+ name: rake
24
34
  version_requirements: !ruby/object:Gem::Requirement
35
+ requirements:
36
+ - - ! '>='
37
+ - !ruby/object:Gem::Version
38
+ version: !binary |-
39
+ MA==
25
40
  none: false
41
+ requirement: !ruby/object:Gem::Requirement
26
42
  requirements:
27
43
  - - ! '>='
28
44
  - !ruby/object:Gem::Version
29
- version: '0'
45
+ version: !binary |-
46
+ MA==
47
+ none: false
48
+ prerelease: false
49
+ type: :runtime
30
50
  description: ''
31
51
  email:
32
52
  - aaron.g.mcleod@gmail.com
@@ -35,34 +55,40 @@ executables:
35
55
  extensions: []
36
56
  extra_rdoc_files: []
37
57
  files:
38
- - jruby-slick/tasks/jruby-slick.rake
39
- - jruby-slick/template/example.rb
40
- - bin/jruby-slick.rb
58
+ - !binary |-
59
+ anJ1Ynktc2xpY2svdGFza3MvanJ1Ynktc2xpY2sucmFrZQ==
60
+ - !binary |-
61
+ anJ1Ynktc2xpY2svdGVtcGxhdGUvZXhhbXBsZS5yYg==
62
+ - !binary |-
63
+ anJ1Ynktc2xpY2svdGVtcGxhdGUvZXhhbXBsZV9nYW1lX3N0YXRlLnJi
64
+ - !binary |-
65
+ YmluL2pydWJ5LXNsaWNrLnJi
41
66
  - .gitignore
42
67
  - Rakefile
43
68
  homepage: http://github.com/agmcleod/jruby-slick
44
69
  licenses: []
45
- post_install_message:
70
+ post_install_message:
46
71
  rdoc_options: []
47
72
  require_paths:
48
73
  - .
49
74
  required_ruby_version: !ruby/object:Gem::Requirement
50
- none: false
51
75
  requirements:
52
76
  - - ! '>='
53
77
  - !ruby/object:Gem::Version
54
- version: '0'
55
- required_rubygems_version: !ruby/object:Gem::Requirement
78
+ version: !binary |-
79
+ MA==
56
80
  none: false
81
+ required_rubygems_version: !ruby/object:Gem::Requirement
57
82
  requirements:
58
- - - ! '>'
83
+ - - ! '>='
59
84
  - !ruby/object:Gem::Version
60
- version: 1.3.1
85
+ version: !binary |-
86
+ MA==
87
+ none: false
61
88
  requirements: []
62
- rubyforge_project:
89
+ rubyforge_project:
63
90
  rubygems_version: 1.8.24
64
- signing_key:
91
+ signing_key:
65
92
  specification_version: 3
66
- summary: A command line tool for downloading and unzipping all the basic jar files
67
- of the slick2d library.
93
+ summary: A command line tool for downloading and unzipping all the basic jar files of the slick2d library.
68
94
  test_files: []