Submit Your Article


 
RPG Maker

Welcome Guest ( Log In | Register )


  Games Resources RPG Maker VX RPG Maker XP Scripts Tutorials Downloads

 
Reply to this topicStart new topic
> Submission: Cursor Script, Self explanatory
jens009
post Jul 2 2007, 10:09 PM
Post #1


L Did you know? Death gods... only eat apples
Group Icon

Group: +Gold Member
Posts: 2,976
Type: Scripter
RM Skill: Skilled




Script Title: Cursor Script
Script Author: Selwyn
Script Version:Unspecified

Description: Replaces the highlited box when selecting skills, characters, etc. with a cursor.

Screenshots:

CODE
#==============================================================================
# â–  Cursor Script
#------------------------------------------------------------------------------
#  Script to display a cursor instead of a highlight box
#   by Selwyn
#   selwyn@rmxp.ch
#==============================================================================

#==============================================================================
# â–  Cursor_Sprite
#==============================================================================

class Sprite_Cursor < Sprite
  #--------------------------------------------------------------------------
  # ● instances
  #--------------------------------------------------------------------------
  attr_accessor :true_x
  attr_accessor :true_y
  #--------------------------------------------------------------------------
  # ● initialize
  #--------------------------------------------------------------------------
  def initialize(x = 0, y = 0)
    super()
    self.x = @true_x = x
    self.y = @true_y = y
    self.z = 10000
    self.bitmap = RPG::Cache.picture("cursor") rescue Bitmap.new(32, 32)
  end
  #--------------------------------------------------------------------------
  # ● update
  #--------------------------------------------------------------------------
  def update
    super
    
    if self.y < @true_y
      n = (@true_y - self.y) / 3
      n = 1 if n == 0
      self.y += n
    elsif self.y > @true_y
      n = (self.y - @true_y) / 3
      n = 1 if n == 0
      self.y -= n
    end

    if self.x < @true_x
      n = (@true_x - self.x) / 3
      n = 1 if n == 0
      self.x += n
    elsif self.x > @true_x
      n = (self.x - @true_x) / 3
      n = 1 if n == 0
      self.x -= n
    end
  end
end

#==============================================================================
# â–  Window_Selectable
#==============================================================================

class Window_Selectable < Window_Base
  #--------------------------------------------------------------------------
  # ● instances
  #--------------------------------------------------------------------------
  attr_accessor :cursor
  alias initialize_cursor initialize
  alias update_cursor_moves update
  alias dispose_cursor dispose
  #--------------------------------------------------------------------------
  # ● initialize
  #--------------------------------------------------------------------------
  def initialize(x, y, width, height)
    initialize_cursor(x, y, width, height)
    @cursor = Sprite_Cursor.new(x, y)
    update_cursor
  end
  #--------------------------------------------------------------------------
  # ● x=
  #--------------------------------------------------------------------------
  def x=(x)
    super
    @cursor.x = x if !@cursor.nil?
  end
  #--------------------------------------------------------------------------
  # ● y=
  #--------------------------------------------------------------------------
  def y=(y)
    super
    @cursor.y = y if !@cursor.nil?
  end
  #--------------------------------------------------------------------------
  # ● visible=
  #--------------------------------------------------------------------------
  def visible=(visible)
    super
    if !@cursor.nil? and visible == false
      @cursor.visible = false
    end
  end
  #--------------------------------------------------------------------------
  # ● dispose
  #--------------------------------------------------------------------------
  def dispose
    dispose_cursor
    @cursor.dispose
  end
  #--------------------------------------------------------------------------
  # ● update_cursor_rect
  #--------------------------------------------------------------------------
  def update_cursor_rect
    if @index < 0
      self.cursor_rect.empty
      return
    end
    row = @index / @column_max
    if row < self.top_row
      self.top_row = row
    end
    if row > self.top_row + (self.page_row_max - 1)
      self.top_row = row - (self.page_row_max - 1)
    end
    cursor_width = self.width / @column_max - 32
    x = @index % @column_max * (cursor_width + 32)
    y = @index / @column_max * 32 - self.oy
    self.cursor_rect.set(x, y, cursor_width, 32)
  end
  #--------------------------------------------------------------------------
  # ● update_cursor
  #--------------------------------------------------------------------------
  def update_cursor
    @cursor.true_x = self.cursor_rect.x + self.x - 8
    @cursor.true_y = self.cursor_rect.y + self.y + 16
    @cursor.update
    @cursor.visible = (self.visible and self.index >= 0)
  end
  #--------------------------------------------------------------------------
  # ● update
  #--------------------------------------------------------------------------
  def update
    update_cursor_moves
    update_cursor
  end
end


Script Instructions:
First of all, you need an image that has a 32x32 pixel size. Then, name the image "cursor"
Import that image and put it in the pictures folder of your rmxp game.

Here's a sample cursor image(32x32 pixel size) for you lazy leechers out there.


Oh, to get rid of the annoying glowing blue thing, just edit your current window skin and remove that window.

Plug and play pretty much.

Compatibility: Compatible with everything except to those who modifies the cursor heavily which is highly unlikely.

Credits and Thanks: Selwyn for the script, Jens009 for submitting it.

This post has been edited by jens009: Jul 3 2007, 10:35 AM


__________________________

My RMXP Project:


Farewell RRR. =]
Go to the top of the page
 
+Quote Post
   

Reply to this topicStart new topic
1 User(s) are reading this topic (1 Guests and 0 Anonymous Users)
0 Members:

 

Lo-Fi Version Time is now: 20th June 2013 - 01:37 AM
RPG RPG Revolution is an Privacy Policy and Legal
eXTReMe Tracker