New account registration is temporarily disabled.

TRIHAN'S PROFILE

Trihan
"It's more like a big ball of wibbly wobbly...timey wimey...stuff."
3359
Sidhe Quest
When everything goes wrong, it's up to our heroes to go and do a bunch of other stuff!

Search

Filter

Slip into Ruby part 3: Making a Scene continued.

No worries about the questions! I'm here to help. :)

You are correct; the fourth argument is the rectangular portion of the source image that will be block transferred.

Basically what I'm doing, if the full image doesn't fit, is taking half the difference between the full image width and available destination width as the x, and half the difference between the full image height and available destination height as the y, and then slicing out a portion of the image that fits in the space available for it.

So say I have a 150x150 window for the enemies, and my graphic is 204x280.

The x will be (204 - 150) / 2, or 27. The y will be (280 - 150) / 2, or 65. So the source rect will be (27, 65, 150, 150) which should end up taking roughly the centre 150x150 "square" of the image.

There is a stretch_blt method which makes the image scale to fit the destination.

Slip into Ruby part 2 - Making a Scene

author=fishure
Hey, I've just started learning Ruby, and, inspired by RPGM games, I've decided to have a go at learning RGSS while I'm at it using your guide. I'm just confused about some things.
In the constructor for Window_EnemyList, you write
data = []

self.index = 0

1. Should data be @data or self.data, since its not used in the constructor? If not, how come?
2. What actually is the difference between saying @index and self.index, and why do you opt for self.index here, and @data when referring to the data later?
Also, the Scene Manager calls a class rather than creating a new instance of the class, so there's no initialize happening or anything, how does that work? Does it run 'start' instead?
And one more thing, which is more related to me not knowing a thing about RGSS. 'refresh' only occurs once, when you open up the scene right?


1. Oh goodness you're absolutely right, it should be @data or self.data.

2. As a property, they're pretty much interchangeable. I didn't have any particular reason for using one over the other. self. can also call methods though, which instance variables obviously can't.

SceneManager's call method creates an instance of the destination scene as part of its implementation, so that part is taken care of for you. This will include calls to the initialize and start methods, which you can see by looking at Scene_Base.

Yes, refresh is only called once when objects are created because it's only called from the constructors. If you wanted it to run every frame, you'd put it in update instead.

Slip into Ruby part 2 - Making a Scene

This won't work for XP; RGSS2 is quite significantly different from RGSS3.

Slip into Ruby part 2 - Making a Scene

When you say "this isn't working" what's not happening that should, or happening that shouldn't?

Jump into Javascript part 9

Part 9 has now been updated with the correct content!

Jump into Javascript part 9

Note that I screwed this up a bit and inadvertently covered the same classes I already did 2 years ago. In the process of writing the proper instalment.

Slip into Ruby - Under the Hood part 16: Bo (window_)selecta(ble)!

Hey Shadow_Fox, thanks for the update. Glad to hear things are going well for you. :)

Slip into Ruby - Under the Hood part 3: Game Objects

They follow the same principle. You can do

if $game_switches[#]


just as easily as unless.

Ruby is one of the few languages that supports this syntax of putting your condition after the line of code to execute.

Slip into Ruby - Under the Hood part 3: Game Objects

That's it! Though personally I'd just do

BattleManager.abort unless $game_switches[#]


I try never to use explicit method calls for boolean checks if all I'm doing is checking for truth, implicit true for the win!

Slip into Ruby - Under the Hood part 3: Game Objects

You'd use != for not equal to.

When you click the "code" tag it asks you what the language is. If you enter "ruby" it'll automatically colour the code for you.
Pages: first 12345 next last