ippa / chingu Goto Github PK
View Code? Open in Web Editor NEWOpenGL accelerated 2D game framework for Ruby
Home Page: http://ippa.se/chingu
License: GNU Lesser General Public License v2.1
OpenGL accelerated 2D game framework for Ruby
Home Page: http://ippa.se/chingu
License: GNU Lesser General Public License v2.1
I tried uninstalling and re-installing various old versions of Ruby to see if I could load up some of my old video games from eight years ago. The main Gosu Gem still works okay. But I have not been able to get Chingu to install in most cases. And in the one old version of Ruby where I was able to install Chingu, I was still not able to get the games to work. In all cases I encountered loading errors. ippa, are you out there? I have posted more details on the Gosu forum. Thanks! --EagleDog
The input system checks to see if a class given is directly inheriting from GameState, so if you have
self.input = { :space => StartGame }
where:
StartGame < MyGameState < Chingu::GameState
then StartGame won't get recognised as a GameState (Not a priority for me since you can just use a very simple #new to get around the issue; just something I noticed). InputDispatcher.rb line 96, anyway.
EDIT: Could also raise an exception if they pass the wrong value, rather than just ignoring it.
I get a black screen. Am I using these GameStates correctly?
require 'rubygems' rescue nil
$LOAD_PATH.unshift File.join(File.expand_path(__FILE__), "..", "..", "lib")
require 'chingu'
include Gosu
include Chingu
class Game < Chingu::Window
def initialize
super
end
def setup
switch_game_state(MainState)
end
end
class MainState < Chingu::GameState
def initialize
super
$name = "Player"
$points = 500
$high_score_list = Chingu::HighScoreList.load(:size => 10)
$window.push_game_state(GameStates::EnterName.new(:callback => method(:got_name)))
end
def got_name(name)
$name = name
$newscore = $high_score_list.add({name: $name, score: $points})
puts "Got name: #{name}"
pop_game_state
$window.switch_game_state(HighScores)
end
end
class HighScores < Chingu::GameState
def initialize
super
create_text
end
def create_text
$high_score_list.each_with_index do |high_score, index|
y = index * 25 + 100
Text.create(high_score[:name], :x => 200, :y => y, :size => 20)
Text.create(high_score[:score], :x => 400, :y => y, :size => 20)
end
end
end
Game.new.show
There is a problem when using Parallax and Viewpoint together since Parallax is GameObject but does not have @image set and therefor the draw_relative method fails:
chingu-0.7.5/lib/chingu/game_object.rb:155:in `draw_relative': undefined method `draw_rot' for nil:NilClass (NoMethodError)
Minimal code reproducing the issue is:
class Flying < Chingu::GameState
trait :viewport
def initialize(options = {})
super
@parallax = Chingu::Parallax.create(:x => 0, :y => 0, :rotation_center => :top_left)
end
end
class Game < Chingu::Window
def initialize
switch_game_state(Flying)
end
end
Is there something wrong with my understanding or is it an issue? AFAIK it is not fixed in master branch but I am willing to consult it and commit a fix, please let me know.
thanks
Jakub
Hello,
I installed chingu trought gem install chingu, and used it without a problem. But then I decided to download the code and when I do the "require", I get the following errors:
/usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in gem_original_require': /home/garoe/Aptana Studio 3 Workspace/chingu/lib/chingu/gosu_ext/sample.rb:41: odd number list for Hash (SyntaxError) volume: DEFAULT_VOLUME, ^ /home/garoe/Aptana Studio 3 Workspace/chingu/lib/chingu/gosu_ext/sample.rb:41: syntax error, unexpected ':', expecting '}' volume: DEFAULT_VOLUME, ^ /home/garoe/Aptana Studio 3 Workspace/chingu/lib/chingu/gosu_ext/sample.rb:41: dynamic constant assignment from /usr/lib/ruby/1.8/rubygems/custom_require.rb:31:in
require'
from /home/garoe/Aptana Studio 3 Workspace/chingu/lib/chingu/require_all.rb:91:in require_all' from /home/garoe/Aptana Studio 3 Workspace/chingu/lib/chingu/require_all.rb:89:in
each'
from /home/garoe/Aptana Studio 3 Workspace/chingu/lib/chingu/require_all.rb:89:in `require_all'
from /home/garoe/Aptana Studio 3 Workspace/chingu/lib/chingu.rb:38
I'm working with ruby 1.8.7 on ubuntu 11.04 64 bits. Any help is apreciated :-)
I've found that with a transitional game state set, pushing a new state then popping it back results in a new copy of the previous state being pushed onto the stack. Behold my hypothetical situation:
push_game_state OptionsMenu
pop_game_state
I can't quite pinpoint it, but it seems to be a logic error in either GameStateManager#pop_game_state
or #switch_game_state
.
(eval):1:in `const_missing': uninitialized constant Gosu::Button (NameError)
from /usr/local/lib/ruby/gems/1.9.1/gems/chingu-0.6.8/lib/chingu/input.rb:24:in `<module:Input>'
I get this crash when trying to run any Chingu app with the latest versions
Rect has somewhat unexpected method names. I can use GameObject#center_x, but have to use Rect#centerx (I know they mean different things in the two contexts, but what I am pointing out is that they are written differently). I assume the reason for this is that Rect is taken from Rubygame, rather than being created for Chingu specifically. Please add method_aliases so I can use methods such as Rect#center_x (which is what I expect to work). I personally don't think that renaming/deprecating, rather than just aliasing the existing methods, is worth the effort.
Hello,
I'm trying to install chingu from sources on osx Lion with ruby 1.9.2p2 (installed by macports) and rake fails with a segmentation fault, can someome help me? see the message below for a detailed trace:
Chingu::GameStateManager
initial configuration
$window should have a game_state_manager
should have 0 game states
push_game_state
should change current game state
should keep last game state
/Users/francescopischedda/lavoro/chingu/lib/chingu/named_resource.rb:179: [BUG] Segmentation fault
ruby 1.9.2p290 (2011-07-09 revision 32553) [x86_64-darwin11.1.0]
-- control frame ----------
c:0052 p:0019 s:0195 b:0195 l:000194 d:000194 METHOD /Users/francescopischedda/lavoro/chingu/lib/chingu/named_resource.rb:179
c:0051 p:0028 s:0191 b:0191 l:000177 d:000190 BLOCK /Users/francescopischedda/lavoro/chingu/lib/chingu/named_resource.rb:195
c:0050 p:---- s:0187 b:0187 l:000186 d:000186 FINISH
c:0049 p:---- s:0185 b:0185 l:000180 d:000184 IFUNC
c:0048 p:---- s:0183 b:0183 l:000182 d:000182 CFUNC :each
c:0047 p:---- s:0181 b:0181 l:000180 d:000180 CFUNC :find
c:0046 p:0013 s:0178 b:0178 l:000177 d:000177 METHOD /Users/francescopischedda/lavoro/chingu/lib/chingu/named_resource.rb:194
c:0045 p:0013 s:0173 b:0173 l:000172 d:000172 METHOD /Users/francescopischedda/lavoro/chingu/lib/chingu/assets.rb:50
c:0044 p:0149 s:0166 b:0166 l:000165 d:000165 METHOD /Users/francescopischedda/lavoro/chingu/lib/chingu/assets.rb:81
c:0043 p:0088 s:0159 b:0159 l:000158 d:000158 METHOD /Users/francescopischedda/lavoro/chingu/lib/chingu/game_states/pause.rb:38
c:0042 p:---- s:0155 b:0155 l:000154 d:000154 FINISH
c:0041 p:---- s:0153 b:0153 l:000152 d:000152 CFUNC :new
c:0040 p:0035 s:0150 b:0150 l:000149 d:000149 METHOD /Users/francescopischedda/lavoro/chingu/lib/chingu/game_state_manager.rb:307
c:0039 p:0043 s:0145 b:0145 l:000144 d:000144 METHOD /Users/francescopischedda/lavoro/chingu/lib/chingu/game_state_manager.rb:148
c:0038 p:0025 s:0138 b:0138 l:000137 d:000137 METHOD /Users/francescopischedda/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/forwardable.rb:182
c:0037 p:0022 s:0133 b:0133 l:001068 d:000132 BLOCK /Users/francescopischedda/lavoro/chingu/spec/chingu/game_state_manager_spec.rb:24
c:0036 p:---- s:0131 b:0131 l:000130 d:000130 FINISH
c:0035 p:---- s:0129 b:0129 l:000128 d:000128 CFUNC :instance_eval
c:0034 p:0019 s:0126 b:0126 l:000125 d:000125 METHOD /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:35
c:0033 p:0014 s:0122 b:0122 l:000113 d:000121 BLOCK /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:70
c:0032 p:---- s:0119 b:0119 l:000118 d:000118 FINISH
c:0031 p:---- s:0117 b:0117 l:000116 d:000116 CFUNC :each
c:0030 p:0025 s:0114 b:0114 l:000113 d:000113 METHOD /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:70
c:0029 p:0030 s:0110 b:0110 l:000109 d:000109 METHOD /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:116
c:0028 p:0024 s:0104 b:0104 l:000095 d:000103 BLOCK /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:221
c:0027 p:---- s:0101 b:0101 l:000100 d:000100 FINISH
c:0026 p:---- s:0099 b:0099 l:000098 d:000098 CFUNC :each
c:0025 p:0054 s:0096 b:0096 l:000095 d:000095 METHOD /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:221
c:0024 p:0039 s:0092 b:0092 l:000091 d:000091 METHOD /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:145
c:0023 p:0011 s:0089 b:0089 l:001560 d:000088 BLOCK /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:47
c:0022 p:0024 s:0086 b:0086 l:000085 d:000085 METHOD /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:107
c:0021 p:0059 s:0082 b:0082 l:001560 d:001560 METHOD /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:45
c:0020 p:0071 s:0076 b:0076 l:000065 d:000075 BLOCK /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:294
c:0019 p:---- s:0071 b:0071 l:000070 d:000070 FINISH
c:0018 p:---- s:0069 b:0069 l:000068 d:000068 CFUNC :map
c:0017 p:0017 s:0066 b:0066 l:000065 d:000065 METHOD /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:290
c:0016 p:0096 s:0062 b:0062 l:000061 d:000061 METHOD /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:262
c:0015 p:0014 s:0055 b:0055 l:000046 d:000054 BLOCK /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263
c:0014 p:---- s:0052 b:0052 l:000051 d:000051 FINISH
c:0013 p:---- s:0050 b:0050 l:000049 d:000049 CFUNC :map
c:0012 p:0113 s:0047 b:0047 l:000046 d:000046 METHOD /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263
c:0011 p:0014 s:0040 b:0040 l:000024 d:000039 BLOCK /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24
c:0010 p:---- s:0037 b:0037 l:000036 d:000036 FINISH
c:0009 p:---- s:0035 b:0035 l:000034 d:000034 CFUNC :map
c:0008 p:0035 s:0032 b:0032 l:000024 d:000031 BLOCK /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24
c:0007 p:0022 s:0029 b:0029 l:000028 d:000028 METHOD /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/reporter.rb:12
c:0006 p:0113 s:0025 b:0025 l:000024 d:000024 METHOD /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:21
c:0005 p:0055 s:0020 b:0020 l:000019 d:000019 METHOD /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80
c:0004 p:0101 s:0014 b:0014 l:000013 d:000013 METHOD /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:69
c:0003 p:0021 s:0007 b:0006 l:001758 d:000005 BLOCK /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11
c:0002 p:---- s:0004 b:0004 l:000003 d:000003 FINISH
-- Ruby level backtrace information ----------------------------------------
/Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:11:in block in autorun' /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:69:in
run'
/Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/runner.rb:80:in run_in_process' /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:21:in
run'
/Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/reporter.rb:12:in report' /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in
block in run'
/Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in map' /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/command_line.rb:24:in
block (2 levels) in run'
/Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in run' /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in
map'
/Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:263:in block in run' /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:262:in
run'
/Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:290:in run_examples' /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:290:in
map'
/Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:294:in block in run_examples' /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:45:in
run'
/Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:107:in with_around_hooks' /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:47:in
block in run'
/Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example.rb:145:in run_before_each' /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:221:in
eval_before_eachs'
/Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:221:in each' /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/example_group.rb:221:in
block in eval_before_eachs'
/Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:116:in run_hook' /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:70:in
run_all'
/Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:70:in each' /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:70:in
block in run_all'
/Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:35:in run_in' /Users/francescopischedda/.rvm/gems/ruby-1.9.2-p290/gems/rspec-core-2.6.4/lib/rspec/core/hooks.rb:35:in
instance_eval'
/Users/francescopischedda/lavoro/chingu/spec/chingu/game_state_manager_spec.rb:24:in block (3 levels) in <module:Chingu>' /Users/francescopischedda/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/forwardable.rb:182:in
push_game_state'
/Users/francescopischedda/lavoro/chingu/lib/chingu/game_state_manager.rb:148:in push_game_state' /Users/francescopischedda/lavoro/chingu/lib/chingu/game_state_manager.rb:307:in
game_state_instance'
/Users/francescopischedda/lavoro/chingu/lib/chingu/game_state_manager.rb:307:in new' /Users/francescopischedda/lavoro/chingu/lib/chingu/game_states/pause.rb:38:in
initialize'
/Users/francescopischedda/lavoro/chingu/lib/chingu/assets.rb:81:in []' /Users/francescopischedda/lavoro/chingu/lib/chingu/assets.rb:50:in
autoload'
/Users/francescopischedda/lavoro/chingu/lib/chingu/named_resource.rb:194:in find_file' /Users/francescopischedda/lavoro/chingu/lib/chingu/named_resource.rb:194:in
find'
/Users/francescopischedda/lavoro/chingu/lib/chingu/named_resource.rb:194:in each' /Users/francescopischedda/lavoro/chingu/lib/chingu/named_resource.rb:195:in
block in find_file'
/Users/francescopischedda/lavoro/chingu/lib/chingu/named_resource.rb:179:in `exist?'
-- C level backtrace information -------------------------------------------
[NOTE]
You may have encountered a bug in the Ruby interpreter or extension libraries.
Bug reports are welcome.
For details: http://www.ruby-lang.org/bugreport.html
rake aborted!
ruby -S rspec ./spec/chingu/animation_spec.rb ./spec/chingu/assets_spec.rb ./spec/chingu/basic_game_object_spec.rb ./spec/chingu/console_spec.rb ./spec/chingu/fpscounter_spec.rb ./spec/chingu/game_object_list_spec.rb ./spec/chingu/game_object_map_spec.rb ./spec/chingu/game_object_spec.rb ./spec/chingu/game_state_manager_spec.rb ./spec/chingu/helpers/input_client_spec.rb ./spec/chingu/helpers/input_dispatcher_spec.rb ./spec/chingu/helpers/options_setter_spec.rb ./spec/chingu/inflector_spec.rb ./spec/chingu/input_spec.rb ./spec/chingu/network_spec.rb ./spec/chingu/parallax_spec.rb ./spec/chingu/text_spec.rb ./spec/chingu/window_spec.rb failed
This is more of a question rather than a issue, but Im wondering how I can disable the enter_name gamestate once a user has already entered and successfully added their name to the remote highscores list? My idea initially was to re-assign the input that pushed the enter_name gamestate to something else, but that doesnt seem to work? Any ideas?
Also, is there a better place to ask general questions?
Thanks!
Jacob
I believe the title states the problem.
rest-client was used in the source but wasn't pulled in as a dependency.
name always equals itself (timer trait)
def stop_timer(name)
@_timers.reject! { |name, start_time, end_time, block| name == name }
@_repeating_timers.reject! { |name, start_time, end_time, block| name == name }
end
Hello, I'm an aspiring game developer and I've chosen Gosu + Chingu libraries as my stepping stone to greater glory. I've been playing around with it for quite some time now and I really have an annoying problem with animations.
I've looked up on the animation example and tried doing the same thing, problem is I'm always getting this NoMethodError on 'next'. What might be causing this?
For Text objects, #width returns a value affected by scaling factor and #height/#size returns the absolute height, unaffected by scaling. This did confuse me for a while.
For consistency with retrofied Image, could be implemented as #width (unaffected by scaling), #height/#size (as now), #screen_width (as current #width) and #screen_height (height affected by factor). Alternatively, #width and #height being the actual screen sizes and a #font_size to find the unscaled height of the font. Not at all sure which of those two methods is best though.
Image::autoload_dirs and Sample::autoload_dirs methods do not correctly connect to the class instance variable used to autoload assets. Instead, they return a regular class variable (@@autoload_dirs) which is always an empty array and is not the same array as the one used to load assets, so altering it has no effect.
Hi, there is a way to create a .exe of my game? That is, just click on the .exe and run the game without Chingu or ruby installed. I mean something like Ocra and Gosu. I tried to create a .exe of a game in Chingu with Ocra and I get errors, not executed. And if it can, as I do? What I need?.
I try the game state following the example 24, and it works great. Then I decided to use it after a previous state but then I got the following error : prueba.rb:24:in 'initialize': undefined method 'push_game_state' for nil:NilClass (NoMethodError). So it seems that the this state can only be pushed by Chingu::Window and not by any other state. The code that shows the error is:
class Game < Chingu::Window
def initialize
super(800,400,false) # leave it blank and it will be 800,600,non fullscreen
self.input = { :escape => :exit } # exits example on Escape
self.caption = "Demonstration of GameStates::EnterName"
push_game_state(Name_Select)
end
end
class Name_Select < Chingu::GameState
def initialize(options = {})
super
push_game_state(GameStates::EnterName.new(:callback => method(:got_name)))
end
def got_name(name)
puts "Got name: #{name}"
exit
end
end
Fails because of this line 59 of traits/bounding_box.rb
width, height = self.size
replace with
width, height = self.width, self.height
and Text and normal GameObjects work
Hi, I have a question about game objects. How can I know if exist objects of a particular class? That is, I need to do something like:
if Enemy.empty?
# logic if not objects of Enemy class.
end
Could create an Array with all the enemies but do not want to create variables if not necessary. I tried with "Array(Enemy).empty?" but nothing.
Another question is that when I load a font, the console throws me this:
ERROR: failed to open './resources/8_bit_madness.ttf'
ERROR: CreateFile failed
The code is this:
@ text_starge = Text.create (: text => "# {@ starge STARGE}",: size => 25,: font => "resources/8_bit_madness.ttf")
Any help?. Thanks!
While going through the examples, I found that on Ubuntu 14.04 the Gosu Tutorial example FPS goes from 60 to 30's/20's. The problems seems to be the on screen display of the score, once that is removed it works fine and there is not a FPS drop.
I'm trying to use a simple parallax in a viewport example21_sidescroller_with_edit.rb similar to, but when I walk too much parallax repeated stops, these two traits are incompatible? and tested in various ways and nothing.
At first he repetipe several times but when I move a lot of stops and the only thing left is the black background of the viewport. Any help?
Sorry for the bad English :)
Basically, this is what I'm doing:
class Nivel1 < GameState
traits :viewport
def initialize(options = {})
super
self.input = {:e => :edit}
self.viewport.game_area = [0, 0, 3000, HEIGHT]
@parallax = Chingu::Parallax.create(:x => 0, :y => 0, :rotation_center => :top_left)
@parallax.add_layer(
:image => "space.png",
:repeat_x => true,
:repeat_y => false,
:damping => 5
)
load_game_objects
@player = Player.create
end
def edit
push_game_state(GameStates::Edit.new(
:grid => [32,32], #tamaño de las rejillas en el modo editor.
:classes => [
Player,
Rocks,
Water
]))
end
def update
super
self.viewport.center_around(@player)
@parallax.camera_x, @parallax.camera_y = self.viewport.x, self.viewport.y
end
end
Make animation-trait OCRA safe
Basically
:holding_left,up, right. down works perfectly
but
if you try
:holding_a ( or any letter ) it will not call the method with the same name, or any name for that matters. ( but in the case of having the same method name as the input, it will complain if it's not here, which is good and as expected )
It's just not calling the action as it should, or not detecting the hold for that key...
I don't know if I'm doing something wrong but the editor works like magic. The saved yml file is like this
but when I try to load the saved yml file it says: Couldn't create class 'Tiles::Wall'
I thought it might be an issue in the save/load objects code.
Hi, I thinks that this is a minor issue, but it may help if anyone else has the same issue that I had while running the code for the example 7 with the latests released version (0.8.1).
The example makes a call to #fill_circle method, defined in Chingu::Helpers::GFX. But the 0.8.1 version doesn't have the code for that method, which makes it crash.
I just downloaded the latest version of the helper file and added to my local gem. When the newest version of the gem is released this won't be a problem anymore, I guess.
Hello, I am trying to pass a parameter to a gamestate and I can't find the way, and tried in the following ways:
switch_game_state(Play.new(parameter=100))
switch_game_state(Play, options={:parameter=>100})
but nothing. I have a simple class that inherits from Chingu::GameState, which has the method intialize(parameter).
Any help?
Bounding boxes are one pixel too big on right and bottom side.
Width should be "left + width - 1", not "left + width".
How do I remove a GameObject from memory? If I create a space game and shoot an alien, I want that alien completely destroyed. So I do an alien.destroy. But his update method is still being called 60 times/second.
Fix is either to scale x & y (* factor) when displayed and scale w/h (/factor) for collisions.
For example, on a Mac command + q is common for quitting. How can I bind this to :exit?
Thanks
I guess the issue is the dependency on Gosu. This is on Windows 7:
C:\Users\Scott>gem install chingu
Fetching: gosu-0.7.45.gem (100%)
ERROR: Error installing chingu:
The 'gosu' native gem requires installed build tools.
Please update your PATH to include build tools or download the DevKit
from 'http://rubyinstaller.org/downloads' and follow the instructions
at 'http://github.com/oneclick/rubyinstaller/wiki/Development-Kit'
So I installed the DevKit (there were 2 other devkits, this seemed to be the latest and 64-bit, DevKit-mingw64-64-4.7.2-20130224-1432-sfx.exe).
C:\Users\Scott\Downloads\devkit>gem install chingu
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing chingu:
ERROR: Failed to build gem native extension.
C:/Ruby200-x64/bin/ruby.exe extconf.rb
This gem is not meant to be installed on Windows. Instead, please use:
gem install gosu --platform=i386-mingw32
Gem files will remain installed in C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/gosu-0.7.45 for inspection.
Results logged to C:/Ruby200-x64/lib/ruby/gems/2.0.0/gems/gosu-0.7.45/linux/gem_make.out
C:\Users\Scott\Downloads\devkit>gem install gosu --platform=x64-mingw32
Temporarily enhancing PATH to include DevKit...
Building native extensions. This could take a while...
ERROR: Error installing gosu:
ERROR: Failed to build gem native extension.
C:/Ruby200-x64/bin/ruby.exe extconf.rb
This gem is not meant to be installed on Windows. Instead, please use:
gem install gosu --platform=i386-mingw32
I tried every permutation of x64-mingw32, i386-mingw32, i386-mingw64, etc. Nothing helped.
Hi:
/Users/piotr/.rbenv/versions/1.9.3-p0/lib/ruby/gems/1.9.1/bundler/gems/chingu-962ef58b03bc/lib/chingu/game_states/enter_name.rb:66:in `initialize': uninitialized constant Chingu::GameStates::EnterName::Color (NameError)
from /Users/piotr/Work/GitHub/apocalypse/lib/apocalypse/game_window.rb:8:in `new'
from /Users/piotr/Work/GitHub/apocalypse/lib/apocalypse/game_window.rb:8:in `initialise'
And this is the code:
require 'chingu'
module Apocalypse
class GameWindow < Chingu::Window
def initialize
super
push_game_state GameStates::EnterName.new(:callback => method(:add))
end
def add(name)
puts "User entered name #{name}"
end
end
end
I think it would be better if Chingu address the absolute namespaces in the code e.g.:
@texts[@index].color = ::Gosu::Color::RED
instead of
@texts[@index].color = Color::RED
Yaml is only included when a map is loaded/saved, but assuming you stop Ocra from running as far as a window opening, it won't get included unless you manually include it. Best to always require it, even if it isn't needed. Doesn't really waste any time and removes this likelihood (and yaml is a standard library, so no worries there).
I'm getting this Exception whenever I exit a program written using Chingu or the program stops for any error.
Screenshot: https://img.skitch.com/20110617-nue4kssps1qfqepb7466ww1an9.jpg
Backtrace from the problem report:
Process: ruby [25821]
Path: /Users/martin/.rvm/rubies/ruby-1.9.2-p136/bin/ruby
Identifier: ruby
Version: ??? (???)
Code Type: X86 (Native)
Parent Process: zsh [4491]
Date/Time: 2011-06-17 21:04:01.281 +1000
OS Version: Mac OS X 10.6.7 (10J869)
Report Version: 6
Interval Since Last Report: 78880 sec
Crashes Since Last Report: 87
Per-App Crashes Since Last Report: 87
Anonymous UUID: 93EBC185-888E-47E1-9F88-CF462049CB36
Exception Type: EXC_CRASH (SIGABRT)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Crashed Thread: 0 Dispatch queue: com.apple.main-thread
Application Specific Information:
abort() called
Thread 0 Crashed: Dispatch queue: com.apple.main-thread
0 libSystem.B.dylib 0x95dec156 __kill + 10
1 libSystem.B.dylib 0x95dec148 kill$UNIX2003 + 32
2 libSystem.B.dylib 0x95e7e899 raise + 26
3 libSystem.B.dylib 0x95e949b8 abort + 93
4 libstdc++.6.dylib 0x901c4fda __gnu_cxx::__verbose_terminate_handler() + 433
5 libstdc++.6.dylib 0x901c317a __cxxabiv1::__terminate(void ()()) + 10
6 libstdc++.6.dylib 0x901c31ba __cxxabiv1::__unexpected(void ()()) + 0
7 libstdc++.6.dylib 0x901c32b8 __gxx_exception_cleanup(_Unwind_Reason_Code, Unwind_Exception) + 0
8 gosu.for_1_9.bundle 0x0060a2da SwigDirector_Window::needsRedraw() const + 378
9 gosu.for_1_9.bundle 0x00656ae3 Gosu::Window::Impl::doTick(Gosu::Window&) + 307
10 com.apple.Foundation 0x98abc8d4 __NSFireTimer + 141
11 com.apple.CoreFoundation 0x953d7adb __CFRunLoopRun + 8059
12 com.apple.CoreFoundation 0x953d5464 CFRunLoopRunSpecific + 452
13 com.apple.CoreFoundation 0x953d5291 CFRunLoopRunInMode + 97
14 com.apple.HIToolbox 0x949f6e04 RunCurrentEventLoopInMode + 392
15 com.apple.HIToolbox 0x949f6bb9 ReceiveNextEventCommon + 354
16 com.apple.HIToolbox 0x949f6a3e BlockUntilNextEventMatchingListInMode + 81
17 com.apple.AppKit 0x917f278d _DPSNextEvent + 847
18 com.apple.AppKit 0x917f1fce -[NSApplication nextEventMatchingMask:untilDate:inMode:dequeue:] + 156
19 com.apple.AppKit 0x917b4247 -[NSApplication run] + 821
20 gosu.for_1_9.bundle 0x0065651c Gosu::Window::show() + 284
21 gosu.for_1_9.bundle 0x00634574 wrap_Window_show(int, unsigned long, unsigned long) + 84
22 libruby.1.9.1.dylib 0x001758e5 call_cfunc + 581 (vm_insnhelper.c:315)
Does this look like a gosu wrapper problem or an issue with Chingu?
One strange this is I'm having the problem on one Macbook but not another that is nearly identical.
regards
Martin
sanderson@shiny-3:~/code/hexed$ ruby hexed.rb
/usr/local/lib/ruby1.9/gems/1.9.1/gems/chingu-0.5.1/lib/chingu/helpers.rb:81:in dispatch_action': undefined method
superclass' for "exit":String (NoMethodError)
from /usr/local/lib/ruby1.9/gems/1.9.1/gems/chingu-0.5.1/lib/chingu/helpers.rb:30:in block in dispatch_button_down' from /usr/local/lib/ruby1.9/gems/1.9.1/gems/chingu-0.5.1/lib/chingu/helpers.rb:28:in
each'
from /usr/local/lib/ruby1.9/gems/1.9.1/gems/chingu-0.5.1/lib/chingu/helpers.rb:28:in dispatch_button_down' from /usr/local/lib/ruby1.9/gems/1.9.1/gems/chingu-0.5.1/lib/chingu/window.rb:168:in
button_down'
from hexed.rb:167:in show' from hexed.rb:167:in
The following game object causes a segfault in my ruby interpreter when trying to save an instance of it to yaml
class Building < Chingu::GameObject
traits :bounding_box, :collision_detection
def initialize options
super
@image = Gosu::Image["1x1.png"]
@color = 0xff808080
end
end
occurs for 1.9.2 rc1 and rc2
I see that chingu maps gosu's keys to nice simple symbols. But there doesn't seem to be a symbol for the semicolon or quote characters (or others I'm sure). I don't know what they would map to for gosu or if gosu takes into account those characters either.
What can I do to listen to semicolon and quote keypresses?
You forgot to convert the to symbol the strings for the Gamepad buttons. :)
I suspect most people won't be using the online high scores list, especially for smaller projects. Would it be possible to load OnlineHighScoreList
or rest-client and crack on demand?
Trying to help my cousin learn Chingu and currently the dependency on rest-client is preventing Chingu loading at all. His Ubuntu installation seems to be missing net/https.rb
and none of the advice online has actually yielded a result.
Making these dependencies optional since they're used only by a small part of the library would also be nice for people who just don't want to use them to reduce system clutter.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.