Author Topic: [XP] Scene_SketchBook  (Read 3426 times)

Offline LiTTleDRAgo

  • Astral Trancist
  • *****
  • Posts: 851
  • LV: 517
  • Gender: Male
    • View Profile
    • ~
[XP] Scene_SketchBook
« on: October 07, 2012, 02:01:05 PM »
Scene_SketchBook
Authors: LiTTleDRAgo
Version: 1.00
Type: Unknown
Key Term: Misc Add-on

Introduction

Screenshot tells everything

Features

  • You can create a sketch in game

Screenshots

(click to show/hide)

Demo

http://littledrago.blogspot.com/2012/10/rgss-scenesketchbook.html

Instructions

$scene = Scene_SketchBook.new

Compatibility

Require Glitchfinder Mouse Input Module, 66rpg's BitmapToPng code, and edited Mouse Gesture script
all of them are in demo

Credits and Thanks

  • LiTTleDRAgo
  • Glitchfinder (Mouse Script)
  • 66rpg (BitmapToPng code)

Author's Notes

I don't think this will useful for developing game, but oh well....

enjoy ~

Offline Calintz

  • Guardian of Chaos
  • ********
  • Posts: 3803
  • LV: 108
  • Gender: Male
  • A Pixel's Worst Nightmare
    • View Profile
Re: [XP] Scene_SketchBook
« Reply #1 on: October 07, 2012, 11:32:27 PM »
..this is just neat, LOL. level up for being different, haha.

Offline Wecoc

  • Transcended Spirit
  • ***
  • Posts: 108
  • LV: 45
  • Gender: Male
    • View Profile
    • Mundo Maker
Re: [XP] Scene_SketchBook
« Reply #2 on: January 05, 2013, 08:29:11 AM »
I love this! I made an edit that allows you to choice colors, like a "very poor MSPaint" inside RPG maker xD

DRG - Mouse Gestures:
Code: [Select]
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
# [Xp/Vx-VxA] DRG - Mouse Gesture
# Version: 1.50
# Author : LiTTleDRAgo
# Edit by: Wecoc
#:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:=:
module LiTTleDRAgo
  module MouseGestures
    
  VXA = defined?(Window_BattleActor)
#==============================================================================
# ** CONFIGURATION
#==============================================================================
  ALLOWED_SCENE = ['Scene_SketchBook']
          # Insert name scene you want to activate mouse gesture
                  
  # Enter all the condition and result you want here
  def result_mouse_gesture(result)
    if scene.is_a?(Scene_SketchBook)
      save_gesture
      return
    end
  end
    
  # Enter all condition to disable mouse gesture here
  def forbid_mouse_gestures
    return false if !scene.is_a?(Scene_Map)
    if defined?(Window_ActorCommand)            # If VX or VXA
      return true if !$game_player.movable?
      return false
    end                                         # If XP
    return true if $game_system.map_interpreter.running?
    return true if $game_player.move_route_forcing
    return true if $game_temp.message_window_showing
  end
  
  # Enter all condition to ignore scene changing here
  def ignore_changing_scene
    return true if scene.is_a?(Scene_Map) && forbid_mouse_gestures
    return true if $game_system.disable_scene_gesture.include?(scene)
  end
#==============================================================================
# ** CONFIG END
#==============================================================================
  end
end

#==============================================================================
# ** Game_System
#------------------------------------------------------------------------------
#  This class handles data surrounding the system. Backround music, etc.
#  is managed here as well. Refer to "$game_system" for the instance of
#  this class.
#==============================================================================

class Game_System
  #--------------------------------------------------------------------------
  # * Initialize Gesture
  #--------------------------------------------------------------------------
  def init_gesture
    $game_system.disable_scene_gesture = [
            Scene_Battle,
            Scene_Load,
            Scene_Title,
    ]
  end
  #--------------------------------------------------------------------------
  # * Public Instance Variables
  #--------------------------------------------------------------------------
  attr_accessor :disable_scene_gesture
  attr_accessor :saved_gesture, :saved_index
end

#==============================================================================
# ** Game_Temp
#------------------------------------------------------------------------------
#  This class handles temporary data that is not included with save data.
#  Refer to "$game_temp" for the instance of this class.
#==============================================================================

class Game_Temp
  attr_accessor :saved_gesture
end

module LiTTleDRAgo
  module MouseGestures
        
  def update_mouse_gestures
    return if forbid_mouse_gestures
    clear_mouse_gesture if @mouse_gesture.nil?
    $game_temp.saved_gesture = {} if !$game_temp.saved_gesture
    
    if Mouse.trigger?(Mouse::LBUTTON)
      wecoc_choice_color
    end
      
    if Mouse.dragging?
      point = @mouse_gesture[0][@mouse_gesture[4]]
      if point == nil ||  point.disposed?
        @mouse_gesture[0][@mouse_gesture[4]] = Sprite.new
      end
      @mouse_gesture[0][@mouse_gesture[4]].x = @mouse_gesture[4] == 0 ?
      Mouse.drag_coor[0] : Mouse.x
      @mouse_gesture[0][@mouse_gesture[4]].y = @mouse_gesture[4] == 0 ?
      Mouse.drag_coor[1] : Mouse.y
      recog_mouse_gesture # if @mouse_gesture[6] == Mouse.pos
      @mouse_gesture[6] = Mouse.pos if @mouse_gesture[6] != Mouse.pos
      @mouse_gesture[4] += 1
    else
      if !@mouse_gesture[0].empty?
        @mouse_gesture[1].each_with_index { |s,i|
        @mouse_gesture[1][i-1] = nil if i > 0 && s == @mouse_gesture[1][i-1] }
        result_mouse_gesture(@mouse_gesture[1].compact)
        @mouse_gesture[0].each {|i| i.dispose }
        @mouse_gesture[2].each {|i| i.dispose }
        clear_mouse_gesture
      end
    end
  end
  
  def save_gesture
    return if @mouse_gesture[2][0].nil?
    $game_temp.saved_gesture[index] = @mouse_gesture[2][0].bitmap.clone
  end
  
  def index
    ($game_system.saved_index || 1).abs
  end
  
  def change_scene(some_scene=nil)
    $game_system.init_gesture if !$game_system.disable_scene_gesture
    return if ignore_changing_scene
    VXA ? SceneManager.call(some_scene) : $scene = some_scene.new
  end
  
  def scene() VXA ? SceneManager.scene : $scene end
  def clear_mouse_gesture()  @mouse_gesture = [[],[],[],0,0,0] end
  def draw_mouse_line(start_x,start_y,end_x,end_y,
                start_color,width=1,end_color=start_color)
    point = @mouse_gesture[2][0]
    if point == nil || point.disposed?
      @mouse_gesture[2][0] = Sprite.new
      @mouse_gesture[2][0].bitmap = Bitmap.new(640,480)
      @mouse_gesture[2][0].z = 9999
    end
    distance = (start_x - end_x).abs + (start_y - end_y).abs
    if end_color == start_color
      (1..distance).each {|i|
        x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
        y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
        @mouse_gesture[2][0].bitmap.fill_rect(x, y, width, width, start_color)
        if scene.is_a?(Scene_SketchBook)
          $game_temp.saved_gesture[index.to_s] = [] if
                   !$game_temp.saved_gesture[index.to_s]
          $game_temp.saved_gesture[index.to_s] << [x,y]
        end}
    else
      (1..distance).each {|i|
        x = (start_x + 1.0 * (end_x - start_x) * i / distance).to_i
        y = (start_y + 1.0 * (end_y - start_y) * i / distance).to_i
        r = start_color.red*(distance-i)/distance+end_color.red*i/distance
        g = start_color.green*(distance-i)/distance+end_color.green*i/distance
        b = start_color.blue*(distance-i)/distance+end_color.blue*i/distance
        a = start_color.alpha*(distance-i)/distance+end_color.alpha*i/distance
        @mouse_gesture[2][0].bitmap.fill_rect(x, y, width,
        width, Color.new(r, g, b, a))
        if scene.is_a?(Scene_SketchBook)
          $game_temp.saved_gesture[index.to_s] = [] if
                   !$game_temp.saved_gesture[index.to_s]
          $game_temp.saved_gesture[index.to_s] << [x,y]
        end}
    end
    @mouse_gesture[3] += 1
  end
  
  def wecoc_choice_color
    if Mouse.x > 10 and Mouse.x < 50 and Mouse.y > 390 and Mouse.y < 430
      @ini_color = Color.new(0,0,0)
    end
    if Mouse.x > 10 and Mouse.x < 50 and Mouse.y > 430 and Mouse.y < 470
      @ini_color = Color.new(255,255,255)
    end
    
    if Mouse.x > 60-5 and Mouse.x < 100-5 and Mouse.y > 390 and Mouse.y < 430
      @ini_color = Color.new(255,0,0)
    end
    if Mouse.x > 60-5 and Mouse.x < 100-5 and Mouse.y > 430 and Mouse.y < 470
      @ini_color = Color.new(128,0,0)
    end

    if Mouse.x > 110-10 and Mouse.x < 150-10 and Mouse.y > 390 and Mouse.y < 430
      @ini_color = Color.new(255,255,0)
    end
    if Mouse.x > 110-10 and Mouse.x < 150-10 and Mouse.y > 430 and Mouse.y < 470
      @ini_color = Color.new(128,128,0)
    end

    if Mouse.x > 160-15 and Mouse.x < 200-15 and Mouse.y > 390 and Mouse.y < 430
      @ini_color = Color.new(0,255,0)
    end
    if Mouse.x > 160-15 and Mouse.x < 200-15 and Mouse.y > 430 and Mouse.y < 470
      @ini_color = Color.new(0,128,0)
    end
    
    if Mouse.x > 210-20 and Mouse.x < 250-20 and Mouse.y > 390 and Mouse.y < 430
      @ini_color = Color.new(0,255,255)
    end
    if Mouse.x > 210-20 and Mouse.x < 250-2 and Mouse.y > 430 and Mouse.y < 470
      @ini_color = Color.new(0,128,128)
    end    

    if Mouse.x > 260-25 and Mouse.x < 300-25 and Mouse.y > 390 and Mouse.y < 430
      @ini_color = Color.new(0,0,255)
    end
    if Mouse.x > 260-25 and Mouse.x < 300-25 and Mouse.y > 430 and Mouse.y < 470
      @ini_color = Color.new(0,0,128)
    end    

    if Mouse.x > 310-30 and Mouse.x < 350-30 and Mouse.y > 390 and Mouse.y < 430
      @ini_color = Color.new(255,0,255)
    end
    if Mouse.x > 310-30 and Mouse.x < 350-30 and Mouse.y > 430 and Mouse.y < 470
      @ini_color = Color.new(128,0,128)
    end        
  end
  
  def recog_mouse_gesture
    awal = @mouse_gesture[0][@mouse_gesture[5]]
    akhir = @mouse_gesture[0][@mouse_gesture[4]]
    
    if not @ini_color.instance_of?(Color)
      @ini_color = Color.new(0,0,0)
    end
    
    draw_mouse_line(awal.x,awal.y, akhir.x,akhir.y, @ini_color,3)
    sensitivity = 1#25
    if awal.x - akhir.x > sensitivity && (awal.y - akhir.y).abs < sensitivity
      @mouse_gesture[1] << 'left'
    end
    if awal.x - akhir.x < -sensitivity && (awal.y - akhir.y).abs < sensitivity
      @mouse_gesture[1] << 'right'
    end
    if awal.y - akhir.y > sensitivity && (awal.x - akhir.x).abs < sensitivity
      @mouse_gesture[1] << 'up'
    end
    if awal.y - akhir.y < -sensitivity && (awal.x - akhir.x).abs < sensitivity
      @mouse_gesture[1] << 'down'
    end
    if awal.x - akhir.x > sensitivity && awal.y - akhir.y > sensitivity
      @mouse_gesture[1] << 'upleft'
    end
    if awal.x - akhir.x < -sensitivity && awal.y - akhir.y > sensitivity
      @mouse_gesture[1] << 'upright'
    end
    if awal.x - akhir.x > sensitivity && awal.y - akhir.y < -sensitivity
      @mouse_gesture[1] << 'downleft'
    end
    if awal.x - akhir.x < -sensitivity && awal.y - akhir.y < -sensitivity
      @mouse_gesture[1] << 'downright'
    end
    @mouse_gesture[5] = @mouse_gesture[4]
  end
  end
end


#==============================================================================
# ** Scene_Something
#------------------------------------------------------------------------------
#  This class is definition from All Class
#==============================================================================
LiTTleDRAgo::MouseGestures::ALLOWED_SCENE.each {|kelas| eval "
class #{kelas}
  include LiTTleDRAgo::MouseGestures
  alias drg_143_upd update unless method_defined?(:drg_143_upd) ||
                                 !method_defined?(:update)
  def update
    drg_143_upd
    update_mouse_gestures
  end
end#"}
#==============================================================================
# ** Input
#------------------------------------------------------------------------------
#  This module performs key input processing
#==============================================================================
module Input
  class << self
    if !method_defined?(:glitch_input_keys_update)
      raise "This Script needs Glitchfinder's Key Input Module and "+
         "Glitchfinder's Mouse Input Module"
    end
  end
end


$drago_mouse_gestures = true

Back image: http://s8.postimage.org/8cervzvgl/paint_back.png

Screen:
(click to show/hide)
« Last Edit: January 05, 2013, 11:14:17 AM by Wecoc »

Offline bigace

  • Transcended Spirit
  • ***
  • Posts: 211
  • LV: 16
  • Gender: Male
    • View Profile
    • Bigace Scripting World
Re: [XP] Scene_SketchBook
« Reply #3 on: January 08, 2013, 07:30:58 AM »
nice script, never would of thought of this.
level up++ :up:


Use Dropbox to upload your files. Much simpler than other upload sites, you can simply place a folder on your desktop that will sync with your DropBox account.