Chaos Project

RPG Maker => General Discussion => Topic started by: Calintz on January 31, 2008, 06:51:46 pm

Title: Tilesets, Autotiles, and Charasets...How??
Post by: Calintz on January 31, 2008, 06:51:46 pm
How does the game split the graphics, like tilesets being 32 x 32...How does the game do it?? and what syntax would i use to do it??
Title: Re: Tilesets, Autotiles, and Charasets...How??
Post by: Blizzard on January 31, 2008, 07:02:54 pm
Tilesets in RMXP are internally defined. Max width is 256, max height is any number dividable by 32. Autotiles are 96x128, animated autotiles are 384x128.
Title: Re: Tilesets, Autotiles, and Charasets...How??
Post by: Calintz on January 31, 2008, 07:06:56 pm
I know,  I mean, to make an animated sprite of my own in a script...

>> I think I would have to have the game look for the bitmap, and set rect.new, and do block transfers, right??
Title: Re: Tilesets, Autotiles, and Charasets...How??
Post by: Blizzard on January 31, 2008, 07:34:15 pm
Yeah.
Title: Re: Tilesets, Autotiles, and Charasets...How??
Post by: Calintz on January 31, 2008, 07:42:08 pm
Lol, got that much then...Now to figure out how to do it!! Haha
Title: Re: Tilesets, Autotiles, and Charasets...How??
Post by: Sally on January 31, 2008, 09:23:03 pm
so u want tilesets to be animated?
wow.. thats cool
Title: Re: Tilesets, Autotiles, and Charasets...How??
Post by: Calintz on January 31, 2008, 09:23:34 pm
No, but thats a thought that I like!!
Title: Re: Tilesets, Autotiles, and Charasets...How??
Post by: Fantasist on February 02, 2008, 01:04:47 am
If you want an animated tileset, ...don't ask me, I don't know :/
If you want to animate, say, something like a character graphic (which has frames stacked together and you want to use those frames the way you like), you need a sprite,
@da_sprite = Sprite.new
You need to set the bitmap to the graphic
@da_sprite.bitmap = RPG::Cache.picture('Charset_experiment')

Then, you need to keep changing the source rectangle (src_rect) to suit your needs, like this:

@da_sprite.src_rect.set(x, y, w, h)

where x and y are the coordinates of the top-left corner of the required rectangle, w and h are also obvious. You might want to check the 'update' method of the class 'Arrow_Base' in the default scripts. There, the battle cursor blinking is done in the same way. The spurce rect is changed every 8 frames. You can get a clear idea.
Title: Re: Tilesets, Autotiles, and Charasets...How??
Post by: Calintz on February 02, 2008, 06:35:22 pm
I think I'm understanding, Thank you very much Fantasist!! You came closest to answering my wuestion.
Title: Re: Tilesets, Autotiles, and Charasets...How??
Post by: Calintz on February 02, 2008, 09:59:40 pm
I can't get it to work...This is my line of code:
Spoiler: ShowHide
def update
    # Update menuactor frame count
    @menuactor = (@menuactor + 1) % 8
    # Update for menuactor
    if @menuactor < 0
      @menuactor.src_rect.empty
    else
      if @menuactor < 4
        @menuactor.src_rect.set(0, 0, 32, 48)
      else
        if @menuactor < 8
          @menuactor.src_rect.set(32, 48, 32, 48)
        else
          if @menuactor < 12
            @menuactor.src_rect.set(64, 96, 32, 48)
          else
            @menuactor.src_rect.set(96, 128, 32, 48)
          end
        end
      end
    end
  end
end


**But I always get this error >>
Spoiler: ShowHide
(http://i212.photobucket.com/albums/cc283/Derek16438/RMXP%20Errors/untitled.png)
Title: Re: Tilesets, Autotiles, and Charasets...How??
Post by: Fantasist on February 03, 2008, 09:57:30 am
@menuactor is supposed to be a sprite, not a number. src_rect is a property of a sprite, not a number (the 'Fixnum' roughly means the numbers class). You use another variable to control the counter, like @count or something. It should be like this:


Spoiler: ShowHide
def update
    # Update menuactor frame count
    @counter = (@counter + 1) % 8
    # Update for menuactor
    if @counter < 0
      @menuactor.src_rect.empty
    else
      if @counter < 4
        @menuactor.src_rect.set(0, 0, 32, 48)
      else
        if @counter < 8
          @menuactor.src_rect.set(32, 48, 32, 48)
        else
          if @counter < 12
            @menuactor.src_rect.set(64, 96, 32, 48)
          else
            @menuactor.src_rect.set(96, 128, 32, 48)
          end
        end
      end
    end
  end
end


Another thing. Instead of
"else
if"

You can directly use "elsif" like this:
Spoiler: ShowHide
def update
    # Update menuactor frame count
    @counter = (@counter + 1) % 8
    # Update for menuactor
    if @counter < 0
      @menuactor.src_rect.empty
    elsif @counter < 4
      @menuactor.src_rect.set(0, 0, 32, 48)
    elsif @counter < 8
      @menuactor.src_rect.set(32, 48, 32, 48)
    elsif @counter < 12
      @menuactor.src_rect.set(64, 96, 32, 48)
    else
      @menuactor.src_rect.set(96, 128, 32, 48)
    end
  end


And of course, don't forget to do this in the initialize method:
Spoiler: ShowHide
@menuactor = Sprite.new
@menuactor.bitmap = <set your bitmap, like RPG::Cache.picture('pic_name') or just Bitmap.new('path with name')>
@counter = 0
Title: Re: Tilesets, Autotiles, and Charasets...How??
Post by: Calintz on February 03, 2008, 04:19:26 pm
Alright!! See now I understand!! Thank you Fantasist!

>> I've been tinkering with this script snipplet for some time now, and I still haven't been able to get it to work, is it because I'm trying to use it in a window, which is constantly refreshing itself?? The Arrow_Base doesn't have a single refresh methos in it's coding...

Is it possible to call an @"whatever" from a different class, so long as they are in the same script??

For reference, say I just wanted to sexperiment with this snipplet, where would I use it?? In a window, or a scene or what?? Where does this code go??
Title: Re: Tilesets, Autotiles, and Charasets...How??
Post by: Sally on February 03, 2008, 08:11:37 pm
can someone make a script that makes tilesets animated? and add it to tons :P
Title: Re: Tilesets, Autotiles, and Charasets...How??
Post by: Blizzard on February 03, 2008, 08:28:08 pm
How about using autotiles and auto animated events? -_-
Title: Re: Tilesets, Autotiles, and Charasets...How??
Post by: Calintz on February 03, 2008, 08:33:03 pm
I don't understand what you mean Blizzard...

BTW, you think you might be able to shed some light on the subject being discussed??
Title: Re: Tilesets, Autotiles, and Charasets...How??
Post by: Blizzard on February 03, 2008, 08:48:08 pm
You can have animated autotiles like the water tile. And how about using events to animate stuff like flowers. A fully animated tileset could be possibly made by modifying the tileset swap script. In any of those cases the lag would increase pretty much.
Title: Re: Tilesets, Autotiles, and Charasets...How??
Post by: Calintz on February 03, 2008, 09:07:59 pm
I'm not concerned with animated tilesets, I use charactersets for animated events. I'm more concerned with the animated charactersets being shown in windows...
Title: Re: Tilesets, Autotiles, and Charasets...How??
Post by: Nortos on February 04, 2008, 12:04:05 am
he was answering Susys question not yours than Calintz
Title: Re: Tilesets, Autotiles, and Charasets...How??
Post by: Calintz on February 04, 2008, 12:05:42 am
I know...
Title: Re: Tilesets, Autotiles, and Charasets...How??
Post by: Fantasist on February 04, 2008, 09:51:51 am
QuoteI've been tinkering with this script snipplet for some time now, and I still haven't been able to get it to work, is it because I'm trying to use it in a window, which is constantly refreshing itself??

Depends on whether you're updating the window in the scene's update.

Simple Answer: ShowHide
put this code in the update method of the scene:
@the_win.update
where @the_win is an instance of the window in which you defined the update method (changing rects)

Note that you need to initialize (@the_win = Window_AnimChar.new) in the scene's 'main' method


Complex Answer: ShowHide

You defined the code for src_rect in a method called 'update'. Now, that code is executed only when the method is 'called'. In every scene, in main, you see this:

loop do
  Graphics.update
  Input.update
  update
  if $scene != self
    break
  end
end

So you see? The 'update' method is called every frame, that is, 40 times per second. That's why in every scene, most of your code goes into the method 'update'. Now let's say you've used your code in a window class named Window_AnimChar. That is, you've defined a class Window_AnimChar, and defined the update method as in the code (changing the rect). Now you've initialized (or 'created') this object in the scene, say Scene_Menu, like this in 'main:

@char_win = Window_AnimChar.new

Now unless you update this window in the scene's update, it wont be updated. So in the scene's update method, you add this:

@char_win.update

So now, since the update of the scene is 'called' every frame, all the code gets executed all the time. And You called the update of the window (@char_win.update), so even that gets updated every frame. Get it?

Tip: None of the followin methods are in-built into the RGSS dll, you can change how everything works and you can see how everything works unlike built-in functions.

1. main
2. update
3. refresh