PDA

View Full Version : Rgss Tutorial - basics


Blizzy
April 7th, 2005, 01:52 PM
ok, i've made another toturial:
read it carefully...

RGSS Toturial [Basics]

● Drawing a picture on screen:

@image = Sprite.new
@imate.bitmap = RPG::Cache.picture("name of picture")

You can give @image any other name you could think of,
but it needs to start with @.
This will draw a picture at x 0 and y 0,
To set the coördinates of the x & y: (you can use any number)

@image.x = 100
@image.y = 100

To set a layer, use:

@image.z = 100 # 1 - 9999+.

to move pictures, use .ox and .oy
example:

@image.ox += 1 or -= 1
@image.oy += 1 or -= 1


● Drawing text on Screen
To draw text, you'll need to have the following in "def initialize"

self.contents = Bitmap.new(width - 32, height - 32)

If you don't have this in the method, no text will be draw on screen.
to set text, use the following line:

self.contents.draw_text(x,y,width,height, "text")

x is the x-coördinate of the text
y is the y-coördinate of the text
width is the lengt of the text
height is the height of the text
the width & height is the same as the size of the font!
example:
"this is text", if width is "8"
it'll display something like this:
"this i" and the rest is invisible

● Switches
to modify switches, you*ll need to do:

$game_switches[ID] = flag value

ID is the number of the switch
flag value is: true or false (on/off)

● Variables
to modify variables:

$game_variables[ID] = number

ID is the number of the variable
you can do the following with variable:
set equal: =
add : +=
substract: -=
multiply : *=
divide : /=
there are more, but the're not hard to find

you can also store text in variables!
example:
$game_variables[1] = "look! text"
to test it, use this in a call script:
print $game_variables[1].to_s

● Local_Switches
to modify local_switches:

$game_self_switches = {[MapID, EventID, "LOCAL-SWITCH"] => flag value}
$game_map.need_refresh = true


MapID is the ID of the map
ID is the event ID
"Local-Switch" is "a,b,c or d"
flag value is true or false
after each local switch modify, you'll need to refresh the map:

$game_map.need_refresh = true


this is it for now.
i might do some more toturials about rgss.
if you have any ideas for next toturials plz post them.

comments & questions are welcome

Peekimon
April 7th, 2005, 01:56 PM
Great!!!
And with ox and oy, will the pic show the moving animation?
100/10 !

Blizzy
April 7th, 2005, 02:06 PM
it should, but for some reason, it doesn't work for me...very strange

ah, i know the problem, stupid me...it's:
@image.ox += 1
@image.oy -= 1


i'll edit it in the toturial now

Peekimon
April 7th, 2005, 02:12 PM
Ok.
But the moving animation will show, right?

Blizzy
April 7th, 2005, 02:16 PM
yes, that's correct!
there's a differend method too,
but that's with loops

Jeff_PKLight
April 8th, 2005, 07:06 AM
Really good tutorial! (though I already knew about 40% of it) This tutorial should help many people out :)

RM2K3kid
April 8th, 2005, 08:11 AM
I knew some of it but most of it is new to me! Nice work virtual! Can't wait to see more of your tutorials!

Dawson
April 8th, 2005, 08:16 AM
Excellent tutorial! It'll really help alot of newbies out.
BTW, I renamed the title because you spelt 'tutorial' wrong so I fixed it ^_^

Blizzy
April 8th, 2005, 08:34 AM
i'm not good in spelling :sleeping: , english isn't my first language you know :P
anyway, like i said at the end of the toturial...
does anybody have any idea's for next toturials
(not sure if i'm gonna do some more)

sameoldspud
April 8th, 2005, 03:51 PM
Very good tutorial but I have one question. Is there a way to make a window like the message window and put it right above the message window? I want to use faces in my game but Enterbrain took out the show face feature.

Blizzy
April 9th, 2005, 03:06 AM
there's already a script for that

click here (http://www.pokecommunity.com/showthread.php?t=30786)

Krazy_Meerkat
April 10th, 2005, 07:46 AM
Great work Virtual, I tried to do Dubalex's tutorial but I couldn't concentrate on the 2nd tutorial for long enough to learn much :(
Perhaps you will go a bit more in-depth for your next tutorial :D

Blizzy
April 13th, 2005, 11:41 AM
Great work Virtual, I tried to do Dubalex's tutorial but I couldn't concentrate on the 2nd tutorial for long enough to learn much :(
Perhaps you will go a bit more in-depth for your next tutorial :D
i guess i could go more in-depth next time,
but this is only explaining basic syntax