Forum
I'd like to chime in to add that, if you absolutely must manage multiple ruby versions on your system, use
rbenv instead of rvm. It's missing some of the more advanced features of rvm, but you probably don't use them.
rbenv doesn't handle installing Ruby versions on its own, but there is a plugin,
ruby-build, that will do that for you.
Do Z80 next! I ported libz80 to JavaScript a while back for a project that ultimately got a bit overwhelming and I lost interest, but I learned a lot about the venerable-if-wacky Z80 (and the hardware of various 8-bit computers and game consoles) in the process.
I followed the DCPU-16 scene for a while, but ultimately that architecture is a bit too regular to be particularly interesting. C:
ugh, is rvm seriously installing gcc just to compile Ruby? Man, I'm glad I ditched it a long time ago for rbenv.
Yeah, I recommend using the system cursor because it's easy. Just override
needs_cursor?
in your Window class:
def needs_cursor?
true
end
Yeah, I've got so much enjoyment out of Gosu, it really just feels good to contribute back.
Maybe one of these days I'll finish one of the projects I've started.
Yep, the layout would actually take a lot more work to change than the content! YARD theming is undocumented territory.
Thanks! I wanted to work on
something, saw an opportunity and took it. It was about a day's work IIRC and actually pretty fun. Mostly adding actual documentation for a lot of the parameters, fixing a few errors and elaborating on descriptions I thought were unclear. Pretty proud of my work.
I've actually got
a writeup explaining the blending modes floating around too but I think I haven't pushed it yet for some reason. Maybe I'll work a bit more on my local copy and send a pull request later this week when I'm not busy.
Wow, that's a pretty cool find! Might also be useful when I get off my butt and start working on that new Adium message style I've been kicking around for a while.
Consider sticking that parsing code up on
GitHub? I think it'd have a bit better longevity than on a file sharing site. C:
Re separating "game" from graphics: AFAIK Gosu's rendering system is tightly integrated into the run loop. There's some stuff that has to happen before and after your custom draw method, and I think extracting that from the rest of the library would be difficult and not worthwhile. The architecture is what it is.
I think OpenGL is the best choice for graphics, even 2D. It's much faster than SDL's software-based rendering and it's much easier to do fancy stuff like rotation, perspective transformation and blending modes—not to mention the potential to use GLSL for advanced effects. Gosu doesn't directly support GLSL just yet, but there are already libraries like Ashton that support it as an add-on.
I don't have an answer or opinion for the other questions really.
Document it on Font#draw
; add a "see also" to Image#from_text
with a note saying that that method supports the same formatting codes.
Also, you should note in the docs that this is not actually XML or HTML so XML-style nesting rules don't apply—e.g., <b>bold <i>bold-italic</b> italic</i>
is perfectly valid.
The startup time for any nontrivial application with Ruboto is pretty bad. It's bad enough to be a deal breaker for me.
Plus it's really difficult to debug because you end up with really big stack traces that include jruby internals (think of what Ruby on Rails stack traces look like) and it's often not clear where the error has actually originated in your code. I don't know whether this is a jruby problem or a problem with Ruboto's glue code.
Ruboto doesn't feel like a finished product to me, more of a proof-of-concept.
TextMate 2 is complaining about that bundle.
The bundle “RubyGosu” could not be installed because it is malformed.
The bundle lacks mandatory keys in its property list file.
but it doesn't actually say which keys are missing. Hrmph.
I wish the ENet people (person?) would publish, like, a formal description of the actual protocol and algorithms used so that there can be more than one implementation. The reference implementation's API is kind of…not that great. :\
If you made a TextMate bundle part of the official Gosu distribution, I would be so happy.
I have yet to find a full IDE that doesn't just get in my way.
TextMate (Mac) and
Notepad++ (Windows) are both great free code editors (not full IDEs). They do some completion and syntax highlighting, but they don't do as much as Aptana, Visual Studio or Eclipse. You can write your own completions and macros for TextMate, though.
Not exactly what you asked for, but I hope it helps.
There's no way to change it, but you can always draw_quad
a shape that fills the whole window. Pass -Float::INFINITY
for z to make sure it's drawn below everything.
This is more of a general Ruby question, but—
'text[2]_plus[4]'.scan(/\[\d+\]/) #=> ["[2]", "[4]"]
There's a
GitHub app for Windows that should alleviate the headaches if you don't like the command interface. I haven't used it myself, but the Mac app is excellent. Learning Git is a great idea, though, and you'll thank yourself later. C:
You should put this on
GitHub! It's free.
Also, the Ruby parts seem like they would be generally useful outside of the Windows world. Consider making that a separate project so Mac and Linux can play too? C:
2) I'm pretty sure that's up to your OpenGL library and hardware. Someone please correct me if I'm wrong.
4) Precisely.
I'll leave the other questions to folks who are better equipped to answer them.
It's also a good idea to floor
your drawing coordinates if your game uses floats for positioning and stuff. Even with smoothing disabled, drawing a sprite at 0.5, 0.5 is going to have the "pixels" misaligned.
@image.draw @x.floor, @y.floor, @z
or whatever.
Using Chipmunk also means you don't have to write your own spatial hash implementation, though. C:
Oh hell, I can't believe I forgot Symphony of the Night. But really, who hasn't played that? :D
It's a pretentious JRPG with giant mecha and the story is incomplete because it was meant to be part of a series. You can probably safely skip it if that doesn't appeal to you. :D
Like the Saturn, where the PlayStation really shined was 2D, but 3D was the hip new thing back then unfortunately. If you want a good PlayStation game, try Tomba or Rayman!
Man, I'm liking this look too. It kind of reminds me of Xenogears. Did you ever play that?
something something O(n) blah blah. 8D
The only way to really protect that is for the server side to have complete control.
There's no way to do it that can't be trivially reverse engineered. That's what copyright law is for, though.
Here's a kinda hacky function to get the name of a button from its button id if it helps. For keys that produce printable characters, it returns the character; otherwise, it returns the constant name.
Public domain because it's trivial.
def button_name id
unless defined? @button_names
button_constants = Gosu.constants(false)
.grep(/^(?:Gp|Kb|Ms)/)
.inject({}) { |h, k| h.merge! Gosu.const_get(k) => k }
@button_names = Hash.new do |names, id|
ch = button_id_to_char id
names[id] = (ch and ch.ord > 0x20) ? ch.upcase : button_constants[id]
end
end
@button_names[id]
end
Oh my god, I had not seen that. :D Wow, the arrogance from the developers. That's kind of sad.
Yes, if you want to use punctuation keys you'll need to have some way for users to configure the keys themselves if you want it to work cross-platform.
I definitely wouldn't recommend putting the username and password in the program and connecting to MySQL directly. If you hide your source code, even if you obfuscate it somehow, it's still trivially easy to run the application under a debugger or even open it with a hex editor and find that information. If you encrypt it, you need to also distribute the keys to decrypt, or they can't run your game at all. There's just no way to do something like that securely.
Better to hide the SQL database behind a CGI script (or better still, a web application) that can only add high scores to the table and retrieve them.
> If you think that your code is so good that people will steal it, you are a better coder than me. If you think people shouldn't learn by freely looking at your code, then you are a worse person than me :D
This, a thousand times. I think you've summed up my philosophy on, well, pretty much any creative endeavour. I take it one step further and license everything I release permissively, but I won't hold it against anyone who chooses not to take that extra step. C:
JRuby is written in Java and runs on the Java VM, so any C extension support would most likely have to be a wrapper around JNI.
There is experimental support for C extensions in the latest version, but experimental's the keyword here: most libraries that use it aren't quite working yet and there's no guarantee it won't crash. The more non-trivial a library is (Gosu is very non-trivial; most SWIG-generated bindings are), the less likely it is to work.
Also, I'd be surprised if JRuby's extension support is binary-compatible with MRI; you probably have to recompile. It's pretty hard to actually find any information about it, though.
I think the reason we've forgotten about it is because Gosu doesn't (and can't easily be made to) work with it.
Well, that's my advice, but it's up to you to decide what you think is right for your game. Don't let me tell you what to do if you don't agree. :Ɔ
Some kind of resource manager is always a good idea for a project of any size. I wouldn't personally load every song and sound effect at the beginning, though, unless there are only a few of them.
I might have implemented something like this:
class Audio
AUDIO_PATH = File.join(File.dirname(__FILE__), 'Audio')
BGM_PATH = File.join(AUDIO_PATH, 'BGM')
SE_PATH = File.join(AUDIO_PATH, 'SE')
def initialize(source)
@source = source # The game window
@bgm = {}
@se = {}
end
# Clear preloaded audio resources.
def clear
@bgm.clear
@se.clear
end
# Preload the BGM +file+.
def preloadBGM(file)
@bgm[file] ||= File.join(BGM_PATH, "#{file}.wav")
end
# Preload the sound effect +name+.
def preloadSE(file)
@se[file] ||= File.join(SE_PATH, "#{file}.wav")
end
# Play the BGM +file+. If +file+ hasn't been preloaded, it will be loaded
# on demand the first time it's played.
def playBGM(file)
preloadBGM(file).play
end
# Play the sound effect +file+. If +file+ hasn't been preloaded, it will be
# loaded on demand the first time it's played.
def playSE(file)
preloadSE(file).play
end
end
Call clear at the end of a level, scene change or whatever, then preload any files that you anticipate using.
See, if I were designing ocra myself, I would have linked with a static libruby, catted a tar archive containing the user-supplied scripts and only the absolutely necessary Ruby libraries to the end of the executable and overridden require with a custom version that searches that archive instead of looking elsewhere on the system. But I'm sure there's a reason I didn't design ocra.
Yeah, I think I might have got the bitmask wrong though for the Texplay example! I think the color Texplay returns is ARGB, not RGBA, so it would really be get_pixel(x, y) >> 24 & 0xff
.
Here's a magic incantation that returns an array of boolean values for each pixel. true
means the pixel has an alpha of over 50%.
mask = image.to_blob.unpack('L>*').map{|x| (x & 0xff) >= 0x80 }.join(' ')
The array is flat, so index with mask[x + y * image.width]
. This is also a very inefficient way to store this information (one pointer to a Ruby object per pixel, plus whatever overhead an Array has), but I'll leave improving on it as an exercise for you. :D
Alternatively, you can use TexPlay, which adds a get_pixel(x, y)
method (along with several drawing methods and lots of other nifty image manipulation fun that you probably won't need) and test the transparency that way.
require 'texplay'
class Gosu::Image
def solid? (x, y); (get_pixel(x, y) & 0xff) >= 0x80; end
end
I'm not sure what the implications are for performance if you do it that way, but it's a lot easier.
I think what OP wants is hit testing that takes transparency into account. I assume they're getting hits on the "wrong" sprite (i.e., not the one it looks like they're clicking) when the transparent region of one is overlapping a non-transparent region of another.
OP: Once you've found your candidates by the usual bounding box method, you'll need to figure out some other way of querying the transparent regions. One way would be to build a bitmask based on the alpha channel and test that. You can get the raw image data by calling
Image#to_blob.
The C++ methods scale
, rotate
etc. return a transformation matrix (Gosu::Transform
, actually an array of double
). You actually want to call Graphics::pushTransform(const Transform&)
to apply a transformation, then Graphics::popTransform()
when you're done with it.
You can also create arbitrary transformations like skew IIRC, but I'm not an expert on matrix maths.
As implied by the names push and pop, transformations stack, so don't forget to pop everything you push.
Oh, well, that's fine. I guess it's the same problem Gosu has in general, right?
Somewhat related, because a terrible idea has stuck me: is record
callable from a thread? Is it meant to be? C: I know that most of Gosu isn't.
It might be cool to have a sort of provider/consumer model for map chunks where one thread generates and managed recorded chunks according to the camera position and the other draws whatever's available. Only for large maps, of course. :D
Now you're just being silly. :D
KbÖ appears to be a valid identifier in Ruby 1.9.3. C:
Ooh, when did that happen? I missed the news somehow. :D
Foo. I wanted to check this out because it was featured yesterday and I guess I missed the original post. But now I see the download link (and the one for the init script too, since I'm on Mac) has gone 403. Any chance you could reupload elsewhere?
Sorry in advance for practicing thread necromancy.
Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill