Tutorial: RPG Maker RGSS – Basic Window

RPG Maker (RGSS)

Tutorial: RPG Maker RGSS – Basic Window

Create a simple window in RPG Maker RGSS.

Let’s examine another build-in class from RGSS called Window. Building a window is quite easy as RGSS is taking care of everything for us. It requires almost no intervention from the programmer. We only need to create a window object and set the properties with values.

CREATE A BASE WINDOW

The following code will allow a very basic window to appear on the screen.

1-) Open RPG Maker VX and open the Script Editor (F11).
2-) Delete every pieces of code there. Absolutely everything.
3-) Insert a new entry and name it something like ‘My New Script’
4-) Enter the following piece of code in the editor.

my_window = Window.new()

my_skin = Bitmap.new("Graphics/System/Window")
my_window.windowskin = my_skin

my_window.x = 72
my_window.y = 50
my_window.width = 400
my_window.height = 100
my_window.opacity = 255
my_window.back_opacity = 150

loop do
Graphics.update
end

Do you see how ridiculously easy it is?

After instantiating the window object, my_window = Window.new(), and then creating a bitmap object to hold the skin, my_skin = Bitmap.new(“Graphics/System/Window”), we simply need to plug this skin to the window object, my_window.windowskin = my_skin. The window class almost act like a sprite object; the bitmap object cannot display anything on the screen by itself given it’s only data.

Behind the curtains, the skin is secretly assembled in an invisible part of RGSS. Sadly we cannot see the code level of it or interfere with it. So if you want to import a custom-made skin, remember that it’s important to have the same visual layout, and RGSS will do the rest for you.

P.S. The filename path is relative to the .exe file of the project folder.

ADDING CONTENTS IN OUR WINDOW

Let’s test the following code:

my_window = Window.new()
my_window.x = 72
my_window.y = 50
my_window.width = 400
my_window.height = 64
skin = Bitmap.new("Graphics/System/Window")
my_window.windowskin = skin

my_window.contents = Bitmap.new(368, 32)
my_window.contents.draw_text(0, 0, 368, 20, "Hello World, again!", 0)

loop do
Graphics.update
end

let’s not forget that the ‘contents’ property in the Window class actually refers to the Bitmap class used for the window’s contents. I initialized the width to 368, and the height to 32. (-32 offset from our window framework, our window is actually 400×64, so our content will be centered with a margin of 32 pixels)

EMBED AN IMAGE

Embedding an image within a window is quite easy. It’s the same as displaying text.

my_window = Window.new()
my_window.x = 72
my_window.y = 10
my_window.width = 410
my_window.height = 410
skin = Bitmap.new("Graphics/System/Window")
my_window.windowskin = skin
my_img="Graphics/System/IconSet"
my_window.contents = Bitmap.new(my_img)

loop do
Graphics.update
end

If you open the RGSS Reference Manual, remember that there are two ways to call the initialize method from our Bitmap class: Bitmap.new(filename) and Bitmap.new(width, height)

Thus, in our current demo we simply needed the one that needed a filename to be specified. I simply loaded IconSet and I made certain the window size would be large enough to view it.

This part is no different than what we did with bitmap objects in the previous tutorials. Bitmap is only data, and it always need to be rendered from a sprite-based object. It’s safe to say that two bitmap objects are encapsulated within it: windowskin and contents.

Leave a Reply

Your email address will not be published. Required fields are marked *