Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

3 Pages V   1 2 3 >  
Closed TopicStart new topic
> Screen Resolution Script v0.4, RGSS2/RPG Maker VX
ccoa
post Jan 15 2008, 06:01 AM
Post #1


Storm Goddess
Group Icon

Group: Revolutionary
Posts: 989
Type: Scripter
RM Skill: Masterful




Screen Resolution
Version 0.4 (beta)

Introduction

This is extremely simple, and not tested. But this will change the window size and what is displayed by the map. You will still need to remodel the menu and battle scenes to fit in the screen.

v0.3 - I've added code that will automatically center any windows if you up the screen resolution. Note that this will not work if you make the screen resolution smaller. If you want to turn off automatic centering, just find this:

CODE
WIDTH = 640
HEIGHT = 480
DELTA_WIDTH   = (WIDTH - 544).abs
DELTA_HEIGHT = (HEIGHT - 416).abs

class Game_Map
  def calc_parallax_x(bitmap)
    if bitmap == nil
      return 0
    elsif @parallax_loop_x
      return @parallax_x / 16
    elsif loop_horizontal?
      return 0
    else
      w1 = bitmap.width - WIDTH
      w2 = @map.width * 32 - WIDTH
      if w1 <= 0 or w2 <= 0
        return 0
      else
        return @parallax_x * w1 / w2 / 8
      end
    end
  end
end

class Spriteset_Map
  def create_viewports
    @viewport1 = Viewport.new(0, 0, WIDTH, HEIGHT)
    @viewport2 = Viewport.new(0, 0, WIDTH, HEIGHT)
    @viewport3 = Viewport.new(0, 0, WIDTH, HEIGHT)
    @viewport2.z = 50
    @viewport3.z = 100
  end
end

class Spriteset_Battle
  def create_viewports
    @viewport1 = Viewport.new(0, 0, WIDTH, HEIGHT)
    @viewport2 = Viewport.new(0, 0, WIDTH, HEIGHT)
    @viewport3 = Viewport.new(0, 0, WIDTH, HEIGHT)
    @viewport2.z = 50
    @viewport3.z = 100
  end
end

class Game_Player < Game_Character
  CENTER_X = (WIDTH / 2 - 16) * 8     # 画面中央の X 座標 * 8
  CENTER_Y = (HEIGHT / 2 - 16) * 8
end

class Sprite_Timer < Sprite
  def initialize(viewport)
    super(viewport)
    self.bitmap = Bitmap.new(88, 48)
    self.bitmap.font.name = "Arial"
    self.bitmap.font.size = 32
    self.x = WIDTH - self.bitmap.width
    self.y = 0
    self.z = 200
    update
  end
end

class Sprite_Base < Sprite
  def start_animation(animation, mirror = false)
    dispose_animation
    @animation = animation
    return if @animation == nil
    @animation_mirror = mirror
    @animation_duration = @animation.frame_max * 4 + 1
    load_animation_bitmap
    @animation_sprites = []
    if @animation.position != 3 or not @@animations.include?(animation)
      if @use_sprite
        for i in 0..15
          sprite = ::Sprite.new(viewport)
          sprite.visible = false
          @animation_sprites.push(sprite)
        end
        unless @@animations.include?(animation)
          @@animations.push(animation)
        end
      end
    end
    if @animation.position == 3
      if viewport == nil
        @animation_ox = WIDTH / 2
        @animation_oy = HEIGHT / 2
      else
        @animation_ox = viewport.rect.width / 2
        @animation_oy = viewport.rect.height / 2
      end
    else
      @animation_ox = x - ox + width / 2
      @animation_oy = y - oy + height / 2
      if @animation.position == 0
        @animation_oy -= height / 2
      elsif @animation.position == 2
        @animation_oy += height / 2
      end
    end
  end

end

class Window_Base < Window
  def x=(x)
    super(x + DELTA_WIDTH / 2)
  end
  
  def y=(y)
    super(y + DELTA_HEIGHT/ 2)
  end
end


class Scene_Battle < Scene_Base
  def create_info_viewport
    @info_viewport = Viewport.new(0, 288, WIDTH, HEIGHT)
    @info_viewport.z = 100
    @status_window = Window_BattleStatus.new
    @party_command_window = Window_PartyCommand.new
    @actor_command_window = Window_ActorCommand.new
    @status_window.viewport = @info_viewport
    @party_command_window.viewport = @info_viewport
    @actor_command_window.viewport = @info_viewport
    @status_window.x = 128
    @actor_command_window.x = 544
    @info_viewport.visible = false
  end
end

class Scene_Item < Scene_Base
   def start
    super
    create_menu_background
    @viewport = Viewport.new(0, 0, WIDTH, HEIGHT)
    @help_window = Window_Help.new
    @help_window.viewport = @viewport
    @item_window = Window_Item.new(0, 56, 544, 360)
    @item_window.help_window = @help_window
    @item_window.active = false
    @target_window = Window_MenuStatus.new(0,  0)
    hide_target_window
  end
  
  def show_target_window(right)
    @item_window.active = false
    width_remain = WIDTH - @target_window.width
    @target_window.x = right ? width_remain : 0
    @target_window.visible = true
    @target_window.active = true
    if right
      @viewport.rect.set(0, 0, width_remain, HEIGHT)
      @viewport.ox = 0
    else
      @viewport.rect.set(@target_window.width, 0, width_remain, HEIGHT)
      @viewport.ox = @target_window.width
    end
  end
  
  def hide_target_window
    @item_window.active = true
    @target_window.visible = false
    @target_window.active = false
    @viewport.rect.set(0, 0, WIDTH, HEIGHT)
    @viewport.ox = 0
  end
end

class Scene_Skill < Scene_Base
  def start
    super
    create_menu_background
    @actor = $game_party.members[@actor_index]
    @viewport = Viewport.new(0, 0, WIDTH, HEIGHT)
    @help_window = Window_Help.new
    @help_window.viewport = @viewport
    @status_window = Window_SkillStatus.new(0, 56, @actor)
    @status_window.viewport = @viewport
    @skill_window = Window_Skill.new(0, 112, 544, 304, @actor)
    @skill_window.viewport = @viewport
    @skill_window.help_window = @help_window
    @target_window = Window_MenuStatus.new(0, 0)
    hide_target_window
  end
  
  def show_target_window(right)
    @skill_window.active = false
    width_remain = WIDTH - @target_window.width
    @target_window.x = right ? width_remain : 0
    @target_window.visible = true
    @target_window.active = true
    if right
      @viewport.rect.set(0, 0, width_remain, HEIGHT)
      @viewport.ox = 0
    else
      @viewport.rect.set(@target_window.width, 0, width_remain, HEIGHT)
      @viewport.ox = @target_window.width
    end
  end

  def hide_target_window
    @skill_window.active = true
    @target_window.visible = false
    @target_window.active = false
    @viewport.rect.set(0, 0, WIDTH, HEIGHT)
    @viewport.ox = 0
  end
end


Then add this as the first line in Main:

CODE
  Graphics.resize_screen(WIDTH, HEIGHT)


Instructions

Simply change the HEIGHT and WIDTH values to the height and width you want.

Author's Notes

Free for noncommercial use. Please contact me for licensing options if you wish to use this commercially.

However, do not redistribute this script without permission. If you want to post it on a forum I am not active on, please link to this topic.


__________________________
Go to the top of the page
 
+Quote Post
   
XxZiggitxX
post Jan 15 2008, 06:39 AM
Post #2


HRRRRRRRRRRRRRRRRRNNNNNNG
Group Icon

Group: Revolutionary
Posts: 604
Type: None
RM Skill: Undisclosed




Hey, but Its our First VX script!
biggrin.gif

I think.


__________________________
BEARDS.ORG

IT'S A SITE FOR BEARDS. THIS IS ALL YOU NEED TO KNOW.
Go to the top of the page
 
+Quote Post
   
ccoa
post Jan 15 2008, 08:04 AM
Post #3


Storm Goddess
Group Icon

Group: Revolutionary
Posts: 989
Type: Scripter
RM Skill: Masterful




Possibly the first English VX script, period. happy.gif


__________________________
Go to the top of the page
 
+Quote Post
   
darkkyros
post Jan 15 2008, 04:29 PM
Post #4


Level 4
Group Icon

Group: Member
Posts: 50
Type: Artist
RM Skill: Intermediate




Thanks ccoa! Glad to see VX scripts coming out.
Go to the top of the page
 
+Quote Post
   
ccoa
post Jan 16 2008, 12:06 PM
Post #5


Storm Goddess
Group Icon

Group: Revolutionary
Posts: 989
Type: Scripter
RM Skill: Masterful




Okay, this update should make this script actually useable. Some searching revealed that some of the scenes create their own viewports, which would have caused some problems with cutting off windows.

Also, I added code that will center the menu, battle windows, etc instead of having them all crushed up in the upper left corner.


__________________________
Go to the top of the page
 
+Quote Post
   
TheJoan
post Jan 16 2008, 02:43 PM
Post #6


Level 2
Group Icon

Group: Member
Posts: 22
Type: Artist
RM Skill: Skilled




Hello everyone,

First of all, I want to greet you for this script, I really need one like this. ^^
But I have the regret to say that something's wrong (or I don't know what I have done but let me put my doubts on it).
When I launch the game, I realize that the new size (I took 320*240) is just a corner of the original window; in my case, just the left top quarter is shown, in a 320*240px window.

I'll find a way to fix that in my side, good luck and thanks again!
Go to the top of the page
 
+Quote Post
   
ccoa
post Jan 16 2008, 02:55 PM
Post #7


Storm Goddess
Group Icon

Group: Revolutionary
Posts: 989
Type: Scripter
RM Skill: Masterful




I'm not 100% sure I know what you're saying, could you post a screenshot?

My best guess is:

1. The window stayed the same size but you see black in the right and bottom. The solution is to add the line to main that I posted.

2. You made the game smaller, but that doesn't make the windows in game smaller! If you decrease the resolution, you will have to do some additional scripting to resize your various windows, such as the menu, message window, etc. This isn't a magic bullet, I'm afraid.

Also, be sure you took out the code I posted in the introduction. That will make the problem worse if you're making the resolution smaller.


__________________________
Go to the top of the page
 
+Quote Post
   
TheJoan
post Jan 16 2008, 03:04 PM
Post #8


Level 2
Group Icon

Group: Member
Posts: 22
Type: Artist
RM Skill: Skilled




That's 2.

Sorry, sometimes I lose my English ^^' .

Here are links to screens:

Screenshot 1

Screenshot 2

I will check once again but I'm sure I've done all you've written.

EDiT:
I did. ^^'

This post has been edited by TheJoan: Jan 16 2008, 03:08 PM
Go to the top of the page
 
+Quote Post
   
ccoa
post Jan 16 2008, 03:16 PM
Post #9


Storm Goddess
Group Icon

Group: Revolutionary
Posts: 989
Type: Scripter
RM Skill: Masterful




Yup.

The problem here doesn't seem to be my script. Unless it's not centering on the player? That would be a problem.

The problem is that I don't do anything to rewrite the various scenes. If you're going to change the screen resolution, you will need to remodel the menu, battle, title, shop, etc scenes to fit inside your new window size. Especially if you're going smaller. I can't anticipate every possible screen resolution people might want. sweat.gif

Once I actually have a copy of VX, I can probably help you more. I may do a quick remodel for 3-4 screen sizes (probably GBA sized, PSP sized, and RMXP sized). But right now, I'm sort of shooting in the dark and I don't feel very comfortable writing things as big as menus without being able to test! tongue.gif

In general, though, you will have to make your windows smaller and probably either show less data per window or make your font smaller.

Oh, and that gives me an idea for a contest...!


__________________________
Go to the top of the page
 
+Quote Post
   
Diedrupo
post Jan 16 2008, 06:30 PM
Post #10


Level 10
Group Icon

Group: Revolutionary
Posts: 150
Type: Event Designer
RM Skill: Undisclosed




If anything, the screenshots prove the script work, and I'm dying to test it out when VX comes out here (I plan on upping my game's resolution to 1024x768 and testing if it's playable at that res). I'm glad Enterbrain made it much easier to mess with that stuff with the resize_screen function. smile.gif
Go to the top of the page
 
+Quote Post
   
Ember
post Jan 17 2008, 08:17 PM
Post #11


Level 68
Group Icon

Group: Revolutionary
Posts: 2,799
Type: Artist
RM Skill: Advanced




QUOTE (TheJoan @ Jan 17 2008, 08:41 AM) *
That's 2.

Sorry, sometimes I lose my English ^^' .

Here are links to screens:

Screenshot 1

Screenshot 2

I will check once again but I'm sure I've done all you've written.

EDiT:
I did. ^^'

Yeah, it isn't ccoa's script. Like she said, you still have to change the menu and things. This goes for the title screen aswell.
Just open up your script editor and go to "Scene_Title", and at about line 155/156 it says:

CODE
    @command_window.x = (500 - @command_window.width) / 2
    @command_window.y = 288

It won't be 500 for you, it'll be like 544 or something. I changed mine a little to test it.
Just mess around the the x and y coordinates until your happy with where the Start, Continue and End box is.

;D I dunno how to do the menu or anything else though, I'll have a look.. but I know basically nothing about RGSS (Or RGSS2, obviously.), I'm just going off of common sense.

Hope this helped.


EDIT:
[
[Show/Hide] Example of the result


This post has been edited by ember2inferno: Jan 18 2008, 04:13 AM


__________________________
Go to the top of the page
 
+Quote Post
   
Diedrupo
post Jan 17 2008, 11:13 PM
Post #12


Level 10
Group Icon

Group: Revolutionary
Posts: 150
Type: Event Designer
RM Skill: Undisclosed




Gah, there's a limitation to resize_screen, and that is that 640x480 is the max you can use.
Hopefully someone can get around this limitation.
Go to the top of the page
 
+Quote Post
   
TheJoan
post Jan 18 2008, 05:12 PM
Post #13


Level 2
Group Icon

Group: Member
Posts: 22
Type: Artist
RM Skill: Skilled




ember2inferno:

Oh that's right, I forgot to check on the other scripts!
Thank you! wink.gif

I'll check for a way to adjust the spriteset disposition on the map (my hero appear in the right-bottom corner, this really is too bad... ^^' ).

This post has been edited by TheJoan: Jan 18 2008, 05:15 PM
Go to the top of the page
 
+Quote Post
   
Satosan
post Jan 20 2008, 12:20 AM
Post #14


Level 1
Group Icon

Group: Member
Posts: 5
Type: None
RM Skill: Undisclosed




This is a cool script. Keep up the good work.

Anyway, if you complete it, can you perhaps post a template?
Go to the top of the page
 
+Quote Post
   
deadlydan
post Jan 27 2008, 01:13 PM
Post #15


Level 5
Group Icon

Group: Member
Posts: 71
Type: Event Designer
RM Skill: Masterful




Hey guys, was just playing around with this script, i've got it so the player positions correctly into the middle of the screen, add this code after ccoa's and voila, there ya go smile.gif

Here's the code:

CODE
class Game_Player < Game_Character
  
  def update_scroll ( last_real_x, last_real_y )
    ax1 = $game_map.adjust_x(last_real_x)
    ay1 = $game_map.adjust_y(last_real_y)
    ax2 = $game_map.adjust_x(@real_x)
    ay2 = $game_map.adjust_y(@real_y)
    if ay2 > ay1 and ay2 > ( ( Graphics.height / 2 - 16 ) * 8 )
      $game_map.scroll_down(ay2 - ay1)
    end
    if ax2 < ax1 and ax2 <  ( ( Graphics.width  / 2 - 16 ) * 8 )
      $game_map.scroll_left(ax1 - ax2)
    end
    if ax2 > ax1 and ax2 >  ( ( Graphics.width  / 2 - 16 ) * 8 )
      $game_map.scroll_right(ax2 - ax1)
    end
    if ay2 < ay1 and ay2 < ( ( Graphics.height / 2 - 16 ) * 8 )
      $game_map.scroll_up(ay1 - ay2)
    end
  end
  
  def center ( x,  y )
    display_x = x * 256 - ( ( Graphics.width  / 2 - 16 ) * 8 )
    unless $game_map.loop_horizontal?
      max_x = ($game_map.width - 17) * 256
      display_x = [0, [display_x, max_x].min].max
    end
    display_y = y * 256 - ( ( Graphics.height / 2 - 16 ) * 8 )
    unless $game_map.loop_vertical?
      max_y = ($game_map.height - 13) * 256
      display_y = [0, [display_y, max_y].min].max
    end
    $game_map.set_display_pos(display_x, display_y)
  end
  
end


__________________________
Go to the top of the page
 
+Quote Post
   
ccoa
post Jan 28 2008, 06:32 AM
Post #16


Storm Goddess
Group Icon

Group: Revolutionary
Posts: 989
Type: Scripter
RM Skill: Masterful




Why didn't someone tell me it wasn't centering? sweat.gif I'd have fixed it.


__________________________
Go to the top of the page
 
+Quote Post
   
deadlydan
post Jan 28 2008, 02:52 PM
Post #17


Level 5
Group Icon

Group: Member
Posts: 71
Type: Event Designer
RM Skill: Masterful




Well, the code isn't as correct as i thought it was, i've fixed it now though, but it only works good for static resolutions, how would you do it ccoa?


__________________________
Go to the top of the page
 
+Quote Post
   
Diedrupo
post Jan 28 2008, 03:13 PM
Post #18


Level 10
Group Icon

Group: Revolutionary
Posts: 150
Type: Event Designer
RM Skill: Undisclosed




I didn't even notice that the player is not centered correctly, will have to go and fix that when I get home.
Go to the top of the page
 
+Quote Post
   
ccoa
post Jan 29 2008, 03:25 PM
Post #19


Storm Goddess
Group Icon

Group: Revolutionary
Posts: 989
Type: Scripter
RM Skill: Masterful




The latest update should fix it.


__________________________
Go to the top of the page
 
+Quote Post
   
deadlydan
post Jan 30 2008, 04:39 AM
Post #20


Level 5
Group Icon

Group: Member
Posts: 71
Type: Event Designer
RM Skill: Masterful




Thanks for the update, you might want to know that in changed resolutions there is a problem with the map scrolling, in smaller resolutions the map never scrolls to the whole distance of the map width and height-wise, like, if i go to the edge of the map on the right, in 320x240 resolution, it cuts off a lot of the map from the right, etc.


__________________________
Go to the top of the page
 
+Quote Post
   

3 Pages V   1 2 3 >
Closed TopicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 17th June 2013 - 10:20 PM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker