General RGSS/RGSS2/RGSS3 Help

Started by G_G, March 04, 2009, 12:14:28 am

Previous topic - Next topic

Blizzard

With inconsistent data I meant that you take some data from before 10 seconds and some from now. This won't work because that combination of data never existed. i.e. There was no moment where the party had 5000 Gold and all characters were level 11. There was a moment where they were level 10 and had 5000 Gold and there was a moment where they had level 11 and they had 5500 Gold. You took the party state from before and the current state of the actors and so you got 5000 Gold with everybody on level 11 which actually never existed. Even worse, you SAVED that data. That is inconsistent data.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

I've been trying to keep myself busy seeing I'm sick, I tried doing all sorts of things but its too boring...anyways I was looking at all the scripts I made and then this idea just popped in my head.

I want to make a tileset creator. You import pictures and stuff into the pictures folder, use this command window showing all the options, you click one of your pictures, then you drag it on a layed out tileset sheet. I think its a great idea but I'm missing a few things. Mouse script and a resolution script (for larger tileset)

Okay so I found this resolution script but I dont really understand how to use it..maybe you guys can help me with it.
#==============================================================================
# ■ Resolution
#------------------------------------------------------------------------------
#  created by Selwyn
#  selwyn@rmxp.ch
#
#  released on the 19th of June 2006
#
#  allows to change the game window's resolution to 800 by 600.
#==============================================================================

module Resolution
  #--------------------------------------------------------------------------
  # ● instance variables
  #--------------------------------------------------------------------------
  attr_reader :state
  #--------------------------------------------------------------------------
  # ● initialize
  #--------------------------------------------------------------------------
  def initialize
    title = "\0" * 256
    Win32API.new('kernel32', 'GetPrivateProfileString','PPPPLP', 'L').call("Game", "Title", "", title, 256, ".\\Game.ini")
    title.delete!("\0")
    @set_resolution  = Win32API.new('Display.dll', 'SetResolution', 'III', 'I')
    @set_window_long = Win32API.new('user32', 'SetWindowLong', 'LIL', 'L')
    @set_window_pos  = Win32API.new('user32', 'SetWindowPos', 'LLIIIII', 'I')
    @gsm             = Win32API.new('user32', 'GetSystemMetrics', 'I', 'I')
    @gcr             = Win32API.new('user32', 'GetClientRect', 'LP', 'I')
    @kbe             = Win32API.new('user32', 'keybd_event', 'LLLL', '')
    @gaks            = Win32API.new('user32', 'GetAsyncKeyState', 'L', 'I')
    @window = Win32API.new('user32', 'FindWindow', 'PP', 'I').call("RGSS Player", title)
    @default_size = size
    if size[0] < 800 or size[1] < 600
      print("A minimum screen resolution of [800 by 600] is required in order to play #{title}")
      exit
    end
    @state = "default"
    self.default
  end
  #--------------------------------------------------------------------------
  # ● fullscreen
  #--------------------------------------------------------------------------
  def fullscreen
    @default_size = size
    @set_window_long.call(@window, -16, 0x14000000)
    @set_window_pos.call(@window, -1, 0, 0, 802, 602, 64)
    @set_resolution.call(800, 600, 4)
    @state = "fullscreen"
  end
  #--------------------------------------------------------------------------
  # ● default
  #--------------------------------------------------------------------------
  def default
    x = @default_size[0] / 2 - 403
    y = @default_size[1] / 2 - 316
    @set_window_long.call(@window, -16, 0x14CA0000)
    @set_window_pos.call(@window, 0, x, y, 808, 627, 0)
    @set_resolution.call(@default_size[0], @default_size[1], 0)
    @state = "default"
  end
  #--------------------------------------------------------------------------
  # ● trigger?(key)
  #--------------------------------------------------------------------------
  def trigger?(key)
    return @gaks.call(key) & 0x01 == 1
  end
  #--------------------------------------------------------------------------
  # ● private
  #--------------------------------------------------------------------------
  private :fullscreen
  private :default
  private :trigger?
  #--------------------------------------------------------------------------
  # ● size
  #--------------------------------------------------------------------------
  def size
    width = @gsm.call(0)
    height = @gsm.call(1)
    return width, height
  end
  #--------------------------------------------------------------------------
  # ● change
  #--------------------------------------------------------------------------
  def change
    if @state == "default"
      self.fullscreen
    else
      self.default
    end
  end
  #--------------------------------------------------------------------------
  # ● update
  #--------------------------------------------------------------------------
  def update
    if trigger?(121) # F10
      self.change
    end
    if Input.trigger?(Input::ALT) or Input.press?(Input::ALT)
      @kbe.call(18, 0, 2, 0)
    end
  end
  #--------------------------------------------------------------------------
  # ● module functions
  #--------------------------------------------------------------------------
  module_function :initialize
  module_function :fullscreen
  module_function :default
  module_function :trigger?
  module_function :size
  module_function :change
  module_function :update
end


And maybe ideas on a mouse script that detects the holding down of the left button, detects input of both right and left clicks and can detect mouse x and y. So help is appreciated

Blizzard

Tons' input module handles mouse buttons. o.o; I'm just too lazy right now to release the mouse controller. It just needs one last component to be coded. Man. ._.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

But I needed the mouse controller O_O but I guess I can code everything else for now, wait or can i? DUH DUH DUH DUH!!!!!

Anyways what about that resolution script up there?

Blizzard

I might finish it then. ;>_>

Higher resolution = more lag, that's all I can say. You need to call Resolution.fullscreen, but first change the parameters in that method. The script is coded quite inconsistently. "Resolution" is conceptually not suited to be a module. -_- "Screen" should be the module and the most important method should be "set_resolution(x = 640, y = 480)" which obviously uses 640x480 as default parameters. -_-
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

Okay I'm using the bitmap.blt method in a scene. And its not showing any images. Am I supposed to be updating the bitmap?

@tile = Bitmap.new(256, 600)
@tile.blt(0, 0, bitmap, Rect.new(0, 0, 256, 600))

Blizzard

Nope. Just make sure "bitmap" is not nil.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

its not nil I even printed it but its not showing anything.

so here's my entire code right now,
Resolution.initialize
class TileCreator
  def main
    #@back = Sprite.new
    @back = RPG::Cache.tileset("Back")
    @grid = Sprite.new
    @grid.bitmap = RPG::Cache.tileset("Grid")
    @commands = ["New", "Insert", "Export", "Exit"]
    @names = []
    dir = Dir.new('Graphics/Pictures/')
    dir.entries.each {|file| next unless file.include?('.png')
    @names.push(file); RPG::Cache.picture(file)}
    @command = Window_Command.new(160, @commands)
    @graphics = Window_Command.new(160, @names)
    @graphics.active = false
    @graphics.visible = false
    @active = false
    @tile = Bitmap.new(256, 600)
    @tile.blt(0, 0, @back, Rect.new(0, 0, 256, 600))
    @command.x = 800-@command.width
    @graphics.x = @command.x-@graphics.width
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    @graphics.dispose
    @back.dispose
    @grid.dispose
    @commands.dispose
    @mouse.dispose if @mouse != nil
  end
  def update
    @graphics.update
    @command.update
    if @command.active
      update_command
      return
    end
    if @graphics.active
      update_graphics
      return
    end
    if @active
      update_active
      return
    end
  end
  def update_command
    if Input.trigger?(Input::B)
      @command.index = 4
      $game_system.se_play($data_system.cancel_se)
      return
    end
    if Input.trigger?(Input::C)
      case @command.index
      when 0
        $game_system.se_play($data_system.decision_se)
        @tile.dispose
        @tile = nil
        @tile = Bitmap.new(256, 600)
      when 1
        $game_system.se_play($data_system.decision_se)
        @graphics.active = true
        @command.active = false
        @graphics.visible = true
      when 2
        @tile.make_png("CustomTile")
        $game_system.se_play($data_system.decision_se)
      when 3
        $scene = nil
      end
      return
    end
  end
  def update_graphics
    if Input.trigger?(Input::B)
      $game_system.se_play($data_system.cancel_se)
      @graphics.active = false
      @graphics.visible = false
      @command = true
      return
    end
    if Input.trigger?(Input::C)
      $game_system.se_play($data_system.decision_se)
      @mouse = Sprite.new
      @mouse.bitmap = RPG::Cache.picture("#{@names[@graphics.index]}")
      @mouse.x = Input.mouse_x? if Input.mouse_x? != nil
      @mouse.y = Input.mouse_y? if Input.mouse_y? != nil
      @active = true
      @graphics.active = false
    end
   
  end
  def update_active
    @mouse.x = Input.mouse_x? if Input.mouse_x? != nil
    @mouse.y = Input.mouse_y? if Input.mouse_y? != nil
    if Input.trigger?(Input::MOUSE_L)
      rect = Rect.new(0, 0, 256, 600)
      @tile.blt(Input.mouse_x?, Input.mouse_y?, @mouse.bitmap, rect)
      @mouse.dispose
      @mouse = nil
      @active = false
      @graphics.active = true
    end
   
  end
 
end


bitmap in the code is actually @mouse.bitmap

Satoh

shouldn't it be' @mouse.Bitmap '?

I'm not positive, I'm still new to sprite calls... but it seems like that might be the problem...
Requesting Rule #1: BE SPECIFIC!!

Light a man a fire and he'll be warm for a night...
Light a man afire and he'll be warm for the rest of his life... ¬ ¬;

My Resources

fugibo

Quote from: Satoh on September 12, 2009, 02:04:36 pm
shouldn't it be' @mouse.Bitmap '?

I'm not positive, I'm still new to sprite calls... but it seems like that might be the problem...


No, the @bitmap variable is lowercase.

G_G

Well I know for sure its placing the bitmap on the screen because I can export it into an actual tile but I cant see where I'm placing it... man this is just stumping me...

Satoh

try commenting out the current coordinate assignment method you're using and give it absolute coords directly... if you can see the bitmap then your coordinate method is the issue... if not, then your issue is that the bitmap call isn't working properly (or as you would expect it to work rather)...

Did that make sense?
Requesting Rule #1: BE SPECIFIC!!

Light a man a fire and he'll be warm for a night...
Light a man afire and he'll be warm for the rest of his life... ¬ ¬;

My Resources

G_G

September 12, 2009, 09:22:18 pm #232 Last Edit: September 12, 2009, 09:35:14 pm by game_guy
Yea I tried that, I made it go to 0,0 and it still not working. So maybe if I make it a window? Yea I'll try that

EDIT:
Okay if I made it a window would I still be able to add contents to it? like
@window_tile.contents.blt?

Thanks in advance

EDIT 2:
w00tness I got it. I tried my above idea but I added a method that added a blt method so w00t I got it now. Yes a tilesetcreator is coming!!!

Satoh

Quote from: game_guy on September 12, 2009, 09:22:18 pm
Yea I tried that, I made it go to 0,0 and it still not working. So maybe if I make it a window? Yea I'll try that

EDIT:
Okay if I made it a window would I still be able to add contents to it? like
@window_tile.contents.blt?

Thanks in advance

EDIT 2:
w00tness I got it. I tried my above idea but I added a method that added a blt method so w00t I got it now. Yes a tilesetcreator is coming!!!


Grats on the whole winning @ life thing... but what exactly is the purpose of the tileset creator... (not to go off topic or anything)
Requesting Rule #1: BE SPECIFIC!!

Light a man a fire and he'll be warm for a night...
Light a man afire and he'll be warm for the rest of his life... ¬ ¬;

My Resources

G_G

Well now that you say that I'm finding it more useless than I imagined >_>

but anyways you import little pics and tiles and stuff you want in a tileset into the pictures folder. Run the game, and you can places those pictures you imported onto a grid. Theres an option turning Snap To Grid on/off, and then when you're all done, you press Export then type in a name for it and it'll save it into a tileset.

Satoh

basically a better way than using MSPaint, but without the hassle of waiting for Photoshop to take its Adobe freaking time to load... right?

I've not messed with file exporting before, but it sounds like it could be useful... if I ever find a way for it to be...


The real irony of me making a CMS, is that it will most likely be useless if I release it, as it's tailored to my needs and probably isn't versatile... and I'll probably never make a Star Ocean spinoff... because I simply lack the battle system, plot, and sprites necessary to do so...

However, every little bit that I get working, makes me feel a little more confident in my abilities... so I'm not quitting just yet...

I am still having difficulty deciding the best method for iterating through separate windows that are meant to be a single menu to scroll through...
Requesting Rule #1: BE SPECIFIC!!

Light a man a fire and he'll be warm for a night...
Light a man afire and he'll be warm for the rest of his life... ¬ ¬;

My Resources

G_G

September 13, 2009, 02:56:45 am #236 Last Edit: September 13, 2009, 12:19:26 pm by game_guy
yup it even deals with transparency ;)

okay another question, I'm going to add a few more features like saving and loading a tileset from a .rxdata to make it so you can work on it later. Could I just dump the bitmap into a .rxdata and still load it?

How would I go doing it?

EDIT
One question as well, how high can the hue go? Like when your getting a character
RPG::Cache.character(file, hue)

how hue can it go to?

fugibo

Quote from: game_guy on September 13, 2009, 02:56:45 am
yup it even deals with transparency ;)

okay another question, I'm going to add a few more features like saving and loading a tileset from a .rxdata to make it so you can work on it later. Could I just dump the bitmap into a .rxdata and still load it?

How would I go doing it?

EDIT
One question as well, how high can the hue go? Like when your getting a character
RPG::Cache.character(file, hue)

how hue can it go to?


11.

Blizzard

Technically hue goes from 0 to 359. If you use more than 359, it will just cycle it.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


Quote from: winkioI do not speak to bricks, either as individuals or in wall form.

Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.

G_G

Okay so how do we draw a rectangle?

One thats just an outline? And then one thats just filled?