Not logged inGosu Forums
Forum back to Help Search Register Login
Up Topic Gosu / Gosu Showcase / Bottomless Mine v.1.0-beta2
1 2 3 Previous Next  
Parent - By Spooner Date 2012-07-15 23:43
Depending on what you want to do, Ashton might well not replace Texplay for you (or you may be able to replace the slower stuff in Texplay). Anyway, I am not sure I want to get your hopes up on that score, but it really depends what you are struggling to achieve in TexPlay. If you have any specific requests though, I might be able to suggest better ways of doing it in the existing TexPlay/Gosu or, if it is not possible, add it to Ashton.

I'll take a look at the game now :)
Parent - - By Spooner Date 2012-07-15 23:57
OK, had a bit of a go, but I only had the opportunity to do stuff that didn't seem to work :)

* Use the option with ocra to avoid putting up a console window when the game starts (or use Releasy to do it :D): --windows
* Switching to full-screen meant I had bits of desktop sticking out at right and bottom of the actual window (1680x1050 native res). Needs to scale to a resolution I actually support or it will be glitchy like that - I think we should always run full-screen at native screen resolution when using Gosu and scale/translate to ensure the game fills most, if not all, of the screen. If we could query available resolutions, that might be different.
* I could use up/down to select different options in the main menu, except exit, but neither space nor enter did anything. I pressed a lot of keys, but had no idea how to actually choose an option and was unable to start the game.
* Having a progress bar when loading was good, but loading seemed to stay in a single update, so the window never got updated and appeared unresponsive. Try using Ruby Fibres to do all your loading in a coroutine while keeping the window updated.
* Reinitializing player: Pressing a key didn't seem to skip anything, although that is what it suggests you do.
* Don't show FPS in the window caption (in a proper release), since updating the caption text is extremely slow (will cost you significant FPS slowdown just for that!).
Parent - - By lol_o2 Date 2012-07-16 07:32
Thanks for all your advices :)
Menu controls are in ReadMe and Left Control (by default) is used to accept.
I don't know how to use Fibers, so they'll wait for next release. Skipping loading should be done before player graphics, because it loads over 300 images in one frame. It may be faster when I could make this:
I tried to scale the fullscreen window, but it looked so ugly that I left it as it is.

As for Ahston: I use TexPlay for collision masks. Every room has mask image and every tile is splicing to it. If framebuffers would support get_pixel I could hopefully replace the images with framebuffers and it would probably be faster in loading map and in-game manipulation.
Parent - By Spooner Date 2012-07-16 08:52
Texplay splice is horrifically slow and should only really be used in cases where you need to alpha-blend. I did suggest how you could make it orders of magnitude faster by using Window#render_to_image (from Texplay), which doesn't support alpha-blending, but that is fine for tile-maps. . You almost certainly would have done better using Gosu's inbuilt Window#record for this, which would have been fast enough, but you need to use the newer versions for this to work without being buggy.

Ashton::Framebuffer would be even faster and would support alpha blending as well. Not sure that Framebuffer#[x, y] and Frambuffer#[x, y]= would be faster than Texplay's system, but I think it makes sense to implement that, at least. The fundamental difference between Texplay and Framebuffer is that Texplay maintains a copy of the image in main memory, alters that data and syncs it back to the card. This makes operations like splice very slow, whereas drawing into a Framebuffer doesn't require any data to pass to or from the graphics memory, beyond instructions on what to do.

When scaling to full-screen, you need to be aware that the screen might not be in 4:3 ratio like the window. You need to scale up based on height of the screen, then put a global Window#translate in to move the drawn area a bit to the right, and also Window#clip_to so you don't over-draw the black bands you want at the sides of the screen.
Parent - - By Spooner Date 2012-07-17 11:40
Using Ctrl to move onto starting the game, I got to a screen where it is drawing out an intro text, character by character. I have no idea how you are doing it, but it runs at 2 fps and it takes several minutes to completely render the image.

Once fully rendered, it tells me to "press start" although I have no idea what the start button is. Why is start (enter) a different key to "activate" (ctrl) ? Seems to be needless complexity. The keys appear to be extremely arbitrary and non-intuitive, I'm afraid, and saying "press B" when it doesn't mean press the B key, but press whatever button you have bound to action B is extremely confusing for me.
Parent - - By lol_o2 Date 2012-07-17 17:18
Starting text is based on my old method which makes image_from_text each frame. I have >10 FPS there :) Needs to be changed -_-
And sorry for controls, game is based on Metroid and naming controls as on GBA may not be friendly to everyone. Maybe I should replace these B, A, START etc. with actual controls or at least some normal names?
Parent - - By Spooner Date 2012-07-17 17:35
Yeah, image_from_text is extremely slow _especially if you have Texplay loaded and don't turn off caching_. Really, you should just be rendering it directly on the screen, which would avoid the entire issue.

And yes, unless you have a GBA, then those naming conventions are pretty bad. Why not just call them "activate" "jump" or whatever, which is what they do, rather than the name of the key on a specific piece of hardware?
Parent - By lol_o2 Date 2012-07-17 18:01
I played on emulator and I just got used  to this naming. On some Metroid forum where I also posted my game, nobody complained the controls, but if more people would play it, I'll just change these names. Thanks for suggestion anyway.
Parent - By erisdiscord Date 2012-07-17 18:29
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)
                             .inject({}) { |h, k| h.merge! Gosu.const_get(k) => k }
      @button_names = do |names, id|
        ch = button_id_to_char id
        names[id] = (ch and ch.ord > 0x20) ? ch.upcase : button_constants[id]
Parent - - By jlnr (dev) Date 2012-07-16 02:47
Still downloading the game. Re Gosu 0.7.28: Have you tried rendering these MOD files into OGG? Would that change the final size of the game a lot?
Parent - - By lol_o2 Date 2012-07-16 07:33
I tried with smallest file and from 122 kB grown to 1.97 MB, so with 22 modules final size would be ~20 MB bigger.
Parent - By Spooner Date 2012-07-16 08:59
I just converted boss1.mod to boss1.ogg and it went up from 600k to 1000k, which doesn't seem that bad at all. Also, remember that although it seems like increasing the download by 20MB (+50% size) seems like a lot, the actual difference in download time between 40mb and 60mb is trivial unless you are on dial-up!
Parent - - By ml Date 2013-08-24 22:27
Hi lol_o2, I previously posted in the Son of Sword discussion, which will give you some background. I am attempting once again to try running your games on my system (Linux). Now that I know a little bit more about Ruby and Gosu, I think I am getting close.

I am running once again into errors that seem to center around specjal.rb:27, although texplay is also mentioned in the error.

I have tried installing earlier versions of texplay, but my system seems to not be able to install version 0.3.1 or version 0.3.5. Not sure if this would have anything to do with it.

Any suggestions would be appreciated!
Parent - - By lol_o2 Date 2013-08-25 09:31
In Son of Sword all files are loaded with proper case.
But in Bottomless Mine every resource in code is loaded with lower case only.
As for TexPlay, you can disable it (it's loaded in Bottomless_Mine.rb and in Mapper.rb). It's used only for a secret end-game feature and can be safely disabled.
Parent - - By ml Date 2013-08-26 01:48
Thank you I will try disabling Texplay and see what happens....
Parent - By ml Date 2013-08-26 04:26 Edited 2013-08-26 04:35
Hey I just had another look at it, and based on your comments, I looked into the code and I see that there is definitely an issue of case-sensitivity differences. I'm going to try to see if there's a better way to get it working than to go in and manually change all the code (or conversely all the filenames in the respective folders)...

EDIT: I think the best approach at this point might be to first update my mac to 10.6, and then try it out on there....
Parent - - By ml Date 2013-08-26 02:37
Hey I just tried things out again, and I think I might have identified where my confusion is coming from.

Sometimes when I try out other people's games, they only work after I add in a little bit of $LOAD_PATH code at the beginning. I don't entirely understand the LOAD_PATH completely, but I do know that I sometimes have unique issues with it on my OS, which I am sometimes able to resolve.

At the beginning of Bottomless_Mine.rb, there is some code defining $path:


Also, the following code is deactivated:

$path=$path+(if $path != '' then '/' else Dir.getwd+'/' end)

I wonder if I could make some manual changes affecting $path, or if there is an alternate way (for newbs) to handle this segment from specjal.rb:

class Img
  def Img.[](name,reload=nil,tileable=false)
    @@images = unless defined?(@@images)
    if @@images[name] and !reload
      @@images[name] =$screen,$path+"../gfx/"+name+".png",tileable)

  def Img.reset

Maybe I could go in and load all of the images one by one to get around this. But my level of understanding is still quite limited, in terms of being able to anticipate how such changes would affect the rest of the game....

I just went back and tried out Sapphire again as well. I created a game template called Example. When I run Example.rb I run into the same issue in specjal.rb, but this time at line 21 (essentially the same).
Parent - By ml Date 2013-08-26 04:08
As a sidenote, I also find that I often (but not always) have to add "../" in places where images and other files are loaded, in order for things to work properly. Not sure if this affects anything relating to BottomlessMine...
Parent - - By darkhog Date 2014-01-16 17:33
Very good game. I am currently playing heck outta it (still didn't finished it) and didn't come upon any issues you mentioned so far.

Anyway, for .mod playback, maybe you could use fmod-ruby gem, bypassing Gosu's soundsystem (at least for music)? Then, you could use newest available Gosu version.

Any etat when/if game will be fully complete, though?
Parent - - By lol_o2 Date 2014-01-16 19:24
WOW, anyone is really playing it O_o
Anyway, I converted music to .ogg's so I can use newest Gosu.
And the game is completed, but it's in beta, because there still may be some bugs, especially when I switched from TexPlay to Ashton. For something to do, I can only speed-up loading of player's graphics.
I remember there was also some crash in this version in crystal area, but I was to lazy to upload again the 100MB.
Thanks for interest though :)
Parent - - By darkhog Date 2014-01-17 09:13
My friend tried to play it today, because I recommended it, and couldn't play it because where game asks you to press return (enter), none works. He tried to press both regular and numpad one.
Parent - By lol_o2 Date 2014-01-17 12:17
He didn't try hard enough :)
Ok, sorry, but it's a but with calculating text length. You can continue few seconds after or just load the save again, so this text is skipped.
I'll re-upload the game fixing some bugs.
- - By flowerthief Date 2012-08-07 08:16
Yay, a metroidvania! You were wise to put a screenshot of a metroid-ish map up there, as it's all the persuasion I need to want to play the game. doesn't seem to have joystick support :(
Parent - - By Spooner Date 2012-08-07 10:29
Gosu doesn't support joysticks, but does support digital joypads (sadly not analogue joypads), which may or may not be handled by this game. You can probably map your joystick to keys though.
Parent - - By jlnr (dev) Date 2012-08-07 11:09
Gosu should map all analogue sticks to left/right/up/down. Is there a bug I'm not aware of?
Parent - - By Spooner Date 2012-08-07 11:12
I don't know (I don't own anything past a keyboard and, mouse).
Parent - By jlnr (dev) Date 2012-08-07 14:18
Too bad. I was looking for an excuse to buy one more "development device" :)
- - By lol_o2 Date 2012-08-24 18:40

Today I decided to make finally some fixes. This one runs with 60 FPS, thanks to Spooner :)
Parent - - By lol_o2 Date 2012-08-24 20:20
And there's the first problem.
I tried to replace map masking method from TexPlay to Ashton. It seemed quite well, but I encountered strange bug (or is it some my fault?)
I replaced Image with Ashton::Texture. First, white quad is drawn on it and then tiles draw their masks etc. But when I later want to e.g. change black color into white (by drawing quad), it's still read as black (using Texture#[]). Most interesting is that when I draw the texture, changes are visible (so that black is white). Hope I explained it well :) It looks like Texture#[] bug.
Parent - - By Spooner Date 2012-08-24 23:07
Ah yes, the problem is that Ashton::Texture doesn't magically know when you've drawn something on it and so doesn't update the cached data in main memory (that [] accesses). I was in too minds whether to force a recaching operation after you have the opportunity to render, but since the recaching is lazy, there is actually no cost for me to call #refresh_cache after any #render block (or #disable) since it will only do something if and when #[] is next called. I've pushed the fix and hopefully that should work fine for you now!
Parent - - By lol_o2 Date 2012-08-25 08:52 Edited 2012-08-25 09:07
Thanks :) It's working. Now I need this 'instant image duplication' you said about.
But I also found a bug with Stencil. It's below, marked with red arrow:

Making good, fast and simple lighting effect was surprisingly easy, but there's a small problem with it. These 'lights' are just circle image with alpha-smoothed borders. But when they intersect, you can see a Stencil bug with overlapping of mid-alpha pixels. It would probably work with only 0/255 alpha values, but that way it looks better.

And, the second problem comes to Gosu. I converted whole soundtrack to .ogg's, but OpenAL seems to be bugged. When I play some loud/noisy/high-pitched sound, the game is silencing. You can't hear anything, but some similar, noisy sounds. And it lasts few seconds, so it looks like explosion sounds are stunning audio :) There was no such problems before, but when I switched to newer Gosu, everything is rustling (maybe not always)
Parent - - By Spooner Date 2012-08-25 13:56
By instant image duplication, I assume you mean....Texture#dup - not instant, but orders of magnitude faster than Texplay can manage.

As to why you are getting a grey circle like that, I have no idea. I'd have to see some of your code to even hazard a guess. It could be that you need to remember to use :add mode when drawing the circles into the buffer?

I really doubt, however, that you need to use the stencil shader for that effect. Stencil is only be necessary if you need to draw without affecting the pixels underneath, but you just have a blackness "behind" the things you stencil. You should be able to do it by drawing the background normally, then rendering the circles into a WindowBuffer (which is just a window-sized Texture) which was first filled with black using a quad (which reminds me I should allow a colour to be passed to Texture#clear), then drawing the texture using :mode =>:multiply. Remember that you'll need to draw the circles differently for the :multiply to work correctly (with the :add mode), but I'm sure you can work that out. This will actually give a better lighting effect than stencilling anyway!
Parent - - By lol_o2 Date 2012-08-25 19:41
Uh, Texture? Isn't it possible to duplicate Images with this speed? I tried to make shader for that palette, but was too hard and now I need fast duplication.

For this Stencil: I draw these circles and then apply them to black-buffer and then draw it. It tried different modes with no better result :/

Also I forgot to mention about a bug with translation. I used the Window.translate and this lighting buffer was drawn like with doubled translation.
I translate graphics when game is fullscreen and code for this buffer looks like this (with global translation (16, 12):
@cover.draw($screen.fullscreen? ? -16 : 0, $screen.fullscreen? ? -12 : 0, 3.9, shader: @dark, multitexture: @scene)
Parent - - By Spooner Date 2012-08-25 20:04
No, sadly we can't duplicate images anything near as fast. The reason for this is that you can copy a Texture purely on the graphics card (it creates a new texture of the given size, then draws the old one into it using :replace mode). In TexPlay, to copy an image, it has to get a copy of the pixel data and pass that to the Image constructor, which is obviously a lot slower! To fix this, Gosu would have to allow you to create a blank image of a given size (then we could render the old image into it on the graphics card).

Incidentally, in case you missed it, the relative benchmarks are here:

Still no idea how your stencilling is going wrong. As I said, there is no real need to use stencilling and you'll actually get a better effect as I described before (using :multiply mode).

I don't quite understand why you need to translate the draw only when running fullscreen. Why not just draw @cover outside the translation at 0, 0? Maybe I'm still not understanding the exact problem though. Can you make a simple example that shows this issue?

I know I had some issues with offsets being doubled before, but that was because the x/y values were being used directly as C integers, rather than being translated from Ruby VALUES (duh!). Still, this shouldn't affect movement caused by using Gosu's Window#translate though!

Thanks for reporting bugs rather than giving up! Ashton really needs some more strenuous real-world testing like this (the examples and Throckmorton only go so far).
Parent - - By lol_o2 Date 2012-08-25 20:30
I use this translation, because with my resolution, Gosu switches to 800x600 making window not fitting the screen. I just made clipped black frame around the screen. Translation is global, in window where the game state is drawn, so I can't draw anything outside.
Parent - - By Spooner Date 2012-08-25 21:00

    @light_buffer = # Or Texture of however big you need.
    @circle_of_light = # Your light circle image.

The circle shoudl be white in the centre and shaded out to opaque black at the edge OR
white at the center and shaded out to transparent white at the edge. The effect is the same, so it is whichever is easiest. You can, alternatively, draw this with TexPlay when you load the game, but that is a task I'm not going to help you with because life is too short and you can draw it with GIMP or something easily.


@light_buffer.render do
   # <=== Draw an opaque black quad to clear it. Yes, I should implement #clear color: Gosu::Color::BLACK, but not today.

   @light_sources.each do |light|
      @circle_of_light.draw light.x, light.y, 0, 1, 1, 0xffffff, :add # Use Gosu::Image#draw additively, so that lights make each other lighter when they blend.


# <==draw scene normally

@light_buffer.draw 0, 0, 0, mode: :multiply # Look up multiplicative blending to see why this is best for lighting.

# <== draw GUI

I'll see about this translate issue, but it will be a few days I think. Please post an issue on github if you want me to remember :)
Parent - - By lol_o2 Date 2012-08-26 10:21 Edited 2012-08-26 10:57
Now I don't understand anything O_o
Oh, yes, your code helped me, it's im my game and is working. But strange things are happening. The least important. Stencil was making grey circles. Multiplying makes... white

Better visible here:

It doesn't look so bad so it don't need to be fixed. Just a bonus effect :)

But, I want also to make a semi-dark room. With Stencil it was as it should, but now I can't to figure it. When I clear texture, even with multiplying, it should appear invisible. But it's black. I can skip drawing this quad and the texture is still black when cleared (lights are of course visible). So there's no matter ho alpha the quad has, you can see nothing through the dark.
And most interesting. When you charge beam, the hero is altering it's color. But it seems to affect... lights. Charging changes only player's color and it's a different class, but somehow, my lights are drawing with last color used by player. AND, charging missile is also changing character's color, but... not lights'. Maybe it's something in my code, but it seems impossible. I tried using color: Color::WHITE with no result. Also, when you stop charging, the light is still colored. I looks fun, but not desirable  :)  :/

If it helps you, I'm giving source code:
To see how it behaves, load the first save and go down the door. Left Shift to shoot/charge beam, Space to charge missiles. Left Control to jump. To see more interesting charging effect, double tap C key.
And the lighting code is int data/scripts/rooms.rb, line 250.

It's also for jlnr, because you can hear there the OpenAL noise
Parent - - By Spooner Date 2012-08-26 18:16
Playing it for 5 minutes, I failed to work out how to "go down the door", so I gave up.

If you have two lights on top of each other and they both peak at white, then you will end up with white circles like that when you draw them all additively. If you know you are going to overlap a lot of lights, then you might be better having the centre more mid or light grey, so that doesn't happen.

The way multiplication works is that you can see where it is white and you won't see where it is black (which is not the same as stencilling, which uses alpha channel only). I think I said that you can do it with alpha only, which wasn't right. The way with black<->grey<->white (as in your Light.png) is correct when multiplying. The main advantage of this approach is that colours are preserved, when they are darkened, much better when multiplying than stencilling. You can also use coloured lighting, which is nice too :)

Honestly, using github (or alternative) hosting would be a lot easier, for us at least, than mediafire downloads.
Parent - - By lol_o2 Date 2012-08-26 18:53
Uh, it really doesn't explain to much.
To open the door, just shoot it. Down + LeftShift while in air or Z + Down + LeftShift when you stand on it.
And if you have problems with reading code, I of course can make GitHub account. But is it worth for only one thing?
Parent - By Spooner Date 2012-08-26 19:34
It isn't reading the code that is the problem, though it does make it easier to link a line directly, rather than making someone download/extract/find file/find line to do the same thing. It is more that it is easier to update it here next time you need it looked at, compared to redownloading the whole thing, unzipping it, etc. Also makes clear what has been changed. Not a big thing, but it does make life easier for those you want to help you *cough*
Parent - - By jlnr (dev) Date 2012-08-27 00:11
+1 for moving your code to github :) They could also upload ZIPs there.
Parent - By lol_o2 Date 2012-08-27 08:32
Parent - - By lol_o2 Date 2012-08-28 19:17
Another thing I found: Fibers don't work with Gosu::Image
I tried to fix this loading screen. But for first, somehow Fibers I make don't have #alive? method. And, when trying to yield Gosu::Image, game crashes without throwing error.
Any ideas?
Parent - - By Spooner Date 2012-08-28 23:30
I have used Fibers with Gosu, but with an older version of Gosu, can't remember which one, they did just crash the application. I assume you are on Gosu 0.7.45, so that shouldn't be the same problem as you are having.

Fiber only has really basic functionality (only, Fiber.yield and Fiber#resume, I think) unless you require 'fiber' to load the rest of the functionality (like #alive?). Just the same as Thread really: You have Thread, but unless you require 'thread' you miss out on most of what Threads do.

Maybe include some code if you are still struggling to make them work?
Parent - - By lol_o2 Date 2012-08-29 18:50
I used this require and alive? is really working, but there seem to be no way to load these images, because it's simply crashing. Just a basic example:

require 'gosu'
require 'fiber'
include Gosu

class GameWindow < Window
  def initialize
    super(640, 480, false)
    self.caption = "Test Game"

  def update do
      yield @images <<, 'image1.png')
      yield @images <<, 'image2.png')
      yield @images <<, 'image3.png')
    end if !@fiber
    @fiber.resume if @fiber.alive?

  def draw

  def button_down(id)
Parent - - By Spooner Date 2012-08-29 19:27
yield != Fiber.yield (You aren't understanding how either work there :D).

multiline do...end if x is really ugly syntax too. You want:

@fiber ||= do
  @images <<, 'image1.png')
  @images <<, 'image2.png')
  @images <<, 'image3.png')

@fiber.resume if @fiber.alive?
Parent - - By lol_o2 Date 2012-08-29 19:45 Edited 2012-08-29 19:55
Oh, thanks. I know there should be Fiber.yield, I made mistake in example :)
And it's a weird... bug (?) Fiber don't work in Window.update. Calling resume there makes crash. But it works in draw
And, I first time see this ' ||= ' but I sometimes I make much worse syntax than here :)

No, it don't work  even in draw. Fiber.resume don't crash, but when it 'dies', there's some 'cfp consistency error'
Parent - By Spooner Date 2012-08-29 22:28
In this case, it is probably better to create @fiber in #initialize, so you don't need to use ||= anyway. It has its uses, certainly, but doesn't seem necessary here.

Not sure why it still isn't working properly, but there are still a lot of places where it could be going wrong in your full game, which I assume is doing things a bit more complex than we see in the example. If the example still doesn't work, then I can't really help; jlnr probably hasn't a clue either!
- - By ExplodingCookie Date 2012-08-29 20:43
I don't know if this is because I have a Mac, but I need require rubygems present before the require gosu function for it to initialize. By the way, what is gl and glu?
Parent - - By Spooner Date 2012-08-29 22:23 Edited 2012-08-29 22:29
That is only necessary if you use Ruby 1.8.7 (or earlier). I strongly recommend you use Ruby 1.9.3 though, since it is a lot faster and 1.8.7 is pretty close to being deprecated.

gl and glu are prefixes for methods that are provided by OpenGL or OpenGL Utilities libraries, respectively. The Window#gl block in Gosu, however, is there so you can write OpenGL commands directly, which I don't recommend :)
Up Topic Gosu / Gosu Showcase / Bottomless Mine v.1.0-beta2
1 2 3 Previous Next  

Powered by mwForum 2.29.7 © 1999-2015 Markus Wichitill