Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Rubygame issues

Hi guys,
I've recently left RPGMaker and started developing in Rubygame; however, I keep running into problems.



Issue #1
libfreetype-6 has the strangest behaviour when outside of system32. I've specified SDL_PATHS yet it will only ever work if in the same folder as the initial .rb.



Issue #2
I cannot draw on any surfaces. Say I do this (already required and included):
Ruby:
 

@screen = Screen.open [1024, 768],0,SWSURFACE

@screen.load('image.png')

 
It always crashes and says that the method 'load' is private.
wtf.



Issue #3
I create a sprite in a new class called Character:
Ruby:
 

require 'rubygame'

class Character

  include Rubygame

  include Sprites::Sprite

  def initialize(x,y,filename,show=false)

    super()

    @image = Surface.load(filename)

    @rect = @image.make_rect

    @rect.x = x

    @rect.y = y

  end

end

 
And it keeps saying 'Failed loading libpng' and that the module couldn't be found. (SDLError)
Am I dong something wrong?

Please help, because I cant find information on these errors anywhere!
 
My project is actually coming along really well now. I'm surprised how much I prefer Rubygame over RGSS, actually!
There's just one thing I can't work out for the life of me, though.
I managed to work around the other issues, however, does anyone know how to use Surfaces and .blit well?
Because I could use a hand xD
In short, I can't 'blit' any sort of image with a transparency onto the screen, without the outer edges going black (but it sometimes works???)

Here, for example, i was making a method of drawing better text (@font is a has containing different TTF instances):
Ruby:
 

  def draw_text(font,string,color)

    size = @font[font].size_text(string)

    rect1 = rect2 = rect3 = rect4 = rect5 = Rect.new(2,2,size[0]+8,size[1]+8)

    rect2.x+=4

    rect3.x-=4

    rect4.y+=4

    rect5.y-=4

    text1 = @font[font].render(string,false,[0,0,0])

    text2 = @font[font].render(string,false,color)

    surface = Surface.new [size[0]+8,size[1]+8]

    text1.blit(surface,rect1)

    text1.blit(surface,rect2)

    text1.blit(surface,rect3)

    text1.blit(surface,rect4)

    text2.blit(surface,rect1)

    text1.blit(surface,rect5)

    return surface

  end

 

When I call '@text = draw_text('ubuntu,16','Armor',[255,255,255])
And then: .render('Armor',true,[255,255,255])
@text.blit($screen, Rect.new(16,16,@text.make_rect.w,@text.make_rect.h))
 
 
[/code]
Works fine :\
Please help, if you can!
 
I don't use RubyGame, but I see a few questionable things....

Shouldn't text2.blit(surface,rect1) be drawn last?

If you're drawing text2 to rect1, you don't need to draw text1 to rect1. (redundant, but not harmful)

I assume you have an underlying image on $screen. Are you refreshing $screen each time you draw (blit) new @text?

1. Each time the image is blitted overwrites the previous surface (so it doesnt show any of the black outline)

That is how .blit works. once you /paste/ the new pixels, the old pixels are gone.

2. The white text is surrounded by a black square.

Sounds like you are not transferring a fully transparent block. Try drawing just text1 in one position.
Also check the SRCALPHA flag on the surface being returned from your method. (I didn't see a default. I would assume ON, but you never know.)

Good Luck
 
Thanks for taking the time to reply, Brew :D

What I'm trying to do, is make a shadow for the text, and then put colored text on top.
So I start with rendering the text to an image (with alpha enabled), and then I blit it onto a canvas repeatedy with adjusted x and y axis to make it wider than the text itself. Whats happening is that when I blit an image onto the canvas (canvas has SRCALPHA enabled), it erases whats underneath. I don't understand how, because both surfaces have alpha enabled, and yet it overwrites the previous canvas's pixels each time.
I can blit just the image (the rendered text on their own) without putting it onto the canvas to the screen, and it works fine, but going image -> canvas -> screen just doesn't work. So I figure there's something wrong with how I'm blitting to my canvas, or my canvas in general.

I tried changing the canvas to SRCALPHA as you said, but it still drew the box. Infact, I made the canvas SRCALPHA and changed the dimensions to the same as the screen, left it blank and blitted it to the screen, and the screen went black.
So there's something wrong with my canvas.

Currently my canvas is made with:

@canvas = Surface.new [$screen.w,$screen.h],0,[HWSURFACE,SRCALPHA]
 
Maybe if both surfaces have alpha, the transparent transfers from one to the other??? (replaces all pixels, even the alpha ones)
Did you try setting the target's alpha to off, and the sources to on?

Just spit-balling. in RGSS, I've done it the same way, but the draw_text method is already there. (so you don't use .blt)
i.e., instead of .blt, just draw(render) the text 5 times to the same bitmap.
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top