a couple questions

Started by Poe, June 09, 2012, 06:27:09 pm

Previous topic - Next topic

Poe

1)does the tilemap create a sprite for every tile you place on the map? or is it one very large sprite that bitmaps get blitted onto? or, what lol? which brings me to the next question:

2)is there a way to see/alter the code of the standard rgss methods and classes? for example Sprite's bush_depth makes part of the sprite transparent, could one make it be partially blended instead?

3)if anyone knows cos i can't find anything about this on google, if i try to use scripts that use DLL's i get "rgss player stopped working" notice and it crashes. my OS is vista, is there something else i need to do with these DLL's to make them work?

thanks.

ForeverZer0

You can overwrite/alias the built-in RGSS classes the same as any other class. They are actually written in C or C++ within the RGSS dll, but they are interfaced to Ruby and can be overwritten. Using a sprite for each tile would not be very efficient at all, it likely builds layers by creating a large bitmaps with lots of blits.

Here is an example of a Tilemap re-write I made a while back if it helps you understand any better.
http://forum.chaos-project.com/index.php/topic,7814.0.html

I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

June 09, 2012, 06:55:54 pm #2 Last Edit: June 09, 2012, 07:01:51 pm by Blizzard
1. I'm not sure if it's using sprites. I believe it uses simplified versions of sprites (i.e. lightweight sprites), because otherwise the priority (z coordinate) wouldn't work properly. It definitely is not a made from one sprites per layer with blitted bitmaps. That would consume way too much memory (e.g. a map of 30x40 would already require 3 Bitmaps of size 1280x960 which is basically 12 MB memory). So I'm pretty sure there is one sprite for every tile on every layer and they all use src_rect to determine which tile is displayed. And there is actually one additional row/column of sprite because when you move, the map needs additional sprites. I can back up this claim by an observed behavior of the Tilemap with a special script that altered the resolution of the RMXP window wto 800x600 and when I removed the viewport from the Tilemap, it would act exactly as if there is one sprite per tile with 21x16 sprites (including that extra row/column).

2. Not really as these classes are implemented in C++. You can only overwrite them as F0 already said and use your own implementation. As all implementation details are internal, you will probably have to rewrite the entire class. Just rewriting one method won't really work.

3. F0 already gave you a link.
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.

Poe

hm, so i guess both methods work. that script helps a lot ForeverZer0, thanks. so, you rewrote the Tilemap class from how you think it works/should work, without knowing the original?

that's weird though, the DLL i was talking about is screenshot.dll, but in the Custom Resolution script it works fine and in the snapshot scripts (any of them) it crashes my game.

ForeverZer0

What are the arguments you are using for the Win32API call?
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

My custom input module crashes RMXP that uses RGSS100J.dll. Try to find another DLL if you are using this one.
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.

Poe

Quote from: ForeverZer0 on June 12, 2012, 06:18:18 pm
What are the arguments you are using for the Win32API call?

nothing i made myself, i tried game_guy's snapshot script, tried yours as well Blizzard and then some combination of various things i found, all of them make it crash on my end. getting snapshot.dll from another source didn't help.

i pasted the script here anyway if it helps:
Spoiler: ShowHide
module GameGuy
  SnapShot_Key = Input::A # Shift Key
  def self.snap
    snp = Win32API.new('screenshot.dll', 'Screenshot', %w(l l l l p l l), '')
    window = Win32API.new('user32', 'FindWindowA', %w(p p), 'l')
    ini = (Win32API.new 'kernel32', 'GetPrivateProfileStringA', %w(p p p p l p),
      'l')
    game_name = "\0" * 256
    ini.call('Game', 'Title', '', game_name, 255, '.\Game.ini')
    game_name.delete!('\0')
    win = window.call('RGSS Player', game_name)
    dir = Dir.new("Snapshots/")
    count = 0
    dir.entries.each {|i| count += 1}
    file_name = "Snapshots/snap_#{count}.png"
    snp.call(0, 0, 640, 480, file_name, win, 2)
  end
end
module Input
  class << self
    alias gg_update_input_snapshot_lat update
  end
  def self.update
    if Input.trigger?(GameGuy::SnapShot_Key)
      GameGuy.snap
    end
    gg_update_input_snapshot_lat
  end
end




Quote from: Blizzard on June 12, 2012, 06:52:30 pm
My custom input module crashes RMXP that uses RGSS100J.dll. Try to find another DLL if you are using this one.

i'm not using either of those, the snapshot demo crashes as well.:/

ForeverZer0

June 17, 2012, 02:32:30 pm #7 Last Edit: June 17, 2012, 03:10:36 pm by ForeverZer0
I'll make you an quick script. Give me a few minutes.


EDIT:

Screenshot.dll

Spoiler: ShowHide
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# Screenshot
# Author: ForeverZer0
# Version: 1.0
# Date: 6.17.2012
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
#
# Script for taking snapshots of the game screen and saving to a PNG file.
#
# Instructions:
#   
#   Use the following script call: Screen.snap(FILENAME, QUALITY)
#     FILENAME - Filename to save as excluding extension. If omitted, one
#                will be generated using configured values
#     QUALITY  - Quality of the image. 0 = High, 1 = Low.
#                 If omiited, high quality will be used by default.
#
#  Requires "Screenshot.dll"
#     https://dl.dropbox.com/u/20787370/RMXP/screenshot.dll
#
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:

module Screen
 
  # Define the directory for snapshots
  DIRECTORY = "Snapshots"
 
  # Define the basename for snapshots
  FILENAME = "snap"
 
  #-----------------------------------------------------------------------------
  # Takes a snapshot of the screen
  #   filename - Filename to save as excluding extension.
  #              A name will be generated if this omitted
  #   quality  - Quality of the screenshot
  #              0 = High quality
  #              1 = Low Quality
  #-----------------------------------------------------------------------------
  def self.snap(filename = nil, quality = 0)
    title = "\0" * 256
    GetPrivateProfileString.call('Game', 'Title', '', title, 256, '.\\Game.ini')
    title.delete!("\0")
    window = FindWindow.call('RGSS Player', title)
    unless File.directory?(DIRECTORY)
      Dir.mkdir(DIRECTORY)
    end
    if filename == nil
      count = 0
      files = Dir.entries(DIRECTORY) - ['.', '..']
      files.collect! {|f| File.basename(f, File.extname(f)) }
      filename = "#{FILENAME}#{count}"
      while files.include?(filename)
        count += 1
        filename = "#{FILENAME}#{count}"
      end
      filename = "#{DIRECTORY}/#{filename}.png"
    end
    ScreenShot.call(0, 0, 640, 480, filename, window, quality)
  end
 
  #-----------------------------------------------------------------------------
  # Private Constants - DO NOT EDIT
  #-----------------------------------------------------------------------------
  GetPrivateProfileString =
    Win32API.new('kernel32', 'GetPrivateProfileString','PPPPLP', 'L')
  FindWindow = Win32API.new('user32', 'FindWindow', 'PP', 'I')
  ScreenShot = Win32API.new('screenshot.dll', 'Screenshot', 'LLLLPLL', '')
end


Or if you prefer...
http://pastebin.com/XYHGGKj4

This works 100%.
One question about what you had: Did you rename your game file? As in instead of "Game.exe" and "Game.ini", you have somethings else?
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

You can try this:

snp = Win32API.new('screenshot', 'Screenshot', %w(l l l l p l l), '')


I remember that adding the .dll extension sometimes caused problems. Other than that, you can wait for F0.
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.

Poe

i didn't rename anything, removing the extension didn't work either. but this new script work great! much appreciated.

Blizzard

:facepalm: Can you tell me what is so very wrong with this line, F0?

Code: original script
ini.call('Game', 'Title', '', game_name, 255, '.\Game.ini')


I guess I found the cause of the original crash after all. xD
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.

ForeverZer0

June 17, 2012, 06:22:33 pm #11 Last Edit: June 17, 2012, 06:24:31 pm by ForeverZer0
Haha, I didn't notice the buffer size was the wrong and missing a "\" in the filename, I guess that shows how well I was actually looking.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Poe

June 18, 2012, 04:41:04 am #12 Last Edit: June 18, 2012, 05:25:55 am by Poe
Quote from: Blizzard on June 17, 2012, 06:11:25 pm
:facepalm: Can you tell me what is so very wrong with this line, F0?

Code: original script
ini.call('Game', 'Title', '', game_name, 255, '.\Game.ini')


I guess I found the cause of the original crash after all. xD

it still crashes though even if i change that:p besides, it seems to work for other people?


ForeverZer0, i'm looking through your custom resolution tilemap class, it uses one sprite per priority, so 6 sprites all with a bitmap the size of the entire map, isn't that a huge drain on memory (going by Blizzard's argument)? i'm just trying to understand, i'd like to make extra basement and ceiling layer groups (for caves and bridges, 2nd floor,...) but then there would be 18 giant bitmaps.X_X

Blizzard

There are probably other things wrong with it. xD
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.

Poe

so i started first to try and recreate the tilemap as it normally works in rmxp.

i tried three systems:
a) ForeverZer0's Custom Resolution: one sprite with bitmap for each priority, the size of the entire map.
performance on this was great except for two things: it takes a long time to create the bitmaps for big maps (which is a priority), and the Game.exe process becomes gigantic (~1GB at 200x200) without any other sprites, events, added scripts. maps bigger than 200x200 fail to be created at all.

b) one tile-one sprite (per priority): based on Blizzard's view, only on the current screen plus one extra row and column. the idea was that when player "moves", all these tile sprites move the opposite way and the outermost (out of view) jump to the other way and get the next line of tiles blitted onto them.
in this way performance was off, dropping to 25 FPS right away and farther down when moving. as Blizzard suggested, it probably needs lightweight sprites to function this way (which i have no idea how to create).

c) hybrid: one sprite per priority, blits instead of sprites. this shows the best promise, but i can't get it to work.XD
the problem is the movement. it takes too much to be constantly refreshing all the tiles, so i want to move the whole sprites and refresh only the appriopriate one-tile lines.

well in short i don't know how to pull this off, i tried for a while with resizing the bitmap rect, but it's read only so i tried making it an accessor...errors unsued. i just don't know enough about bitmaps and frankly i can't find any online sources for it, it's all FreeImage and RMagick stuff and i'm like wut o_O is that.

so if any of you can help, or if there's anywhere i can read up on how this is done commonly?

Poe

i tried to snap back the layers after movement to original position, and blit the whole thing 32 pixels off + refresh one row/column of blocks, turns out that's even slower than refreshing all the tiles.o_O

any help/examples are welcome as always. how is this being done in ARC? spanks in advance.

ForeverZer0

Using a whole different type of rendering. The Bitmap and Sprite class are just loose wrappers, or more like "helper classes", for the underlying objects used for the way game graphics are actually done. You can write data to render targets and backbuffers without and performing draws in one motion. You also only need to redraw invalidated areas instead of the whole thing. There isn't really an RGSS equivalent way of doing it. You need a lower level language that deals with graphic contexts and allows more control of what/when things are drawn.
I am done scripting for RMXP. I will likely not offer support for even my own scripts anymore, but feel free to ask on the forum, there are plenty of other talented scripters that can help you.

Blizzard

ARC uses the 21x16 sprites implementation (for 640x480, other resolutions are adapted by using a different number obviously). This implementation is good as only the sprite x,y,z coordinates have to be updated along with src_rect depending on the tile ID at $game_map.display_x and $game_map.display_y and the sprites own offset on the screen. Also, since ARC is implemented in C++ using Direct3D9, we're obviously using a lightweight sprite implentation instead of the normal sprites for the tilemap.
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.