Berans' Interactive Drumkit script v1.00

0 Members and 1 Guest are viewing this topic.

**
Rep: +0/-0Level 85
Beran's Interactive Drumkit script
Version: v1.00
Type: Interactive music player

Introduction

Another unique script by me, inspired, and with graphics, by Sniper308. It's a little Drumkit which lets you pump out some beats ingame.

Features

  • Easy to set up
  • Can customize drum-sounds however you like
  • Graphics included
  • Fully lagfree

Screenshots



Demo

Berans' Interactive Drumkit demo v1.00

Script


Spoiler for:
Code: [Select]
#==============================================================================
#==============================================================================
#Berans' "Interactive drumkit" script v1.00
#Last edited: 21 August 2008
#
#------------------------------------------------------------------------------
#
#This script creates an "interactive drumkit" allowing you to play some nice
#beats within your game. It's easy to adapt to your own liking to create
#many different sounds
#
#Credits: Berans    - Making the script
#         Sniper308 - Providing the graphics and idea for the script
#------------------------------------------------------------------------------
#Features
#------------------------------------------------------------------------------
# -Easy set-up
# -Can change drum sounds to anything you like
# -comes with nice graphics
# -Fully lagfree
#------------------------------------------------------------------------------
#Compatibility
#------------------------------------------------------------------------------
#This script does not rewrite any standard methods and does not use any global
#variables. Should be compatible with anything, including the SDK
#
#==============================================================================
#Instructions
#==============================================================================
#
#------------------------------------------------------------------------------
#Setup
#------------------------------------------------------------------------------
# -Download the demo if the script was obtained separately
# -Copy the Audio files in Audio/SE to your own project, and make sure the names
#  stay the same. You can provide your own Audio files, but they must be called
#  "Tom-1","Tom-2","Tom-3","Hi-Hat" and "Bassdrum" respectively
# -Copy the picture files in Graphics/Pictures to your own project, making sure
#  the names stay the same. You can easily change the color of the "lighting"
#  effect by changing the color of the objects in "DrumsLights"
# -Import the picture files into your game, making white transparant in both
#  files, clearing the semi-transparant color for "Rock Band Drums" and making
#  the color of the main objects in "DrumsLights" semi-transparant
# -Insert this script above Main and under the standard scripts
#
#------------------------------------------------------------------------------
#Using the script
#------------------------------------------------------------------------------
#To call the script, use the "script" command within any event.
#In the script write "$scene = Scene_Drums.new", without the quotes
#==============================================================================
#==============================================================================

#==============================================================================
#**Scene_Drums
#------------------------------------------------------------------------------
#This class handles processing for the drums screen
#==============================================================================
class Scene_Drums
 
  #----------------------------------------------------------------------------
  #*Main processing
  #----------------------------------------------------------------------------
  def main
    #Memorize Map/Menu BGM
    $game_system.bgm_memorize
    #Fade out BGM
    $game_system.bgm_fade(2)
    #Memorize Map/Menu BGS
    $game_system.bgs_memorize
    #Fade out BGS
    $game_system.bgs_fade(2)
    #This keeps track of the animation frames for the drum's lighting effects
    @animation = []
    #create a value for @animation for each drum
    for i in 0...5
      @animation.push(-1)
    end
    #Create spritesets
    @spriteset = Spriteset_Map.new
    @drums = Spriteset_Drums.new
    #Create windows
    @help_window = Window_Drumshelp.new
    @drumdummy = Drum_Dummy.new
    Graphics.transition
    loop do
      Graphics.update
      Input.update
      update
      if $scene != self
        break
      end
    end
    Graphics.freeze
    @help_window.dispose
    @spriteset.dispose
    @drums.dispose
    @drumdummy.dispose
    #Restore Map/Menu BGM
    $game_system.bgm_restore
    #Restore Map/Menu BGS
    $game_system.bgs_restore
  end
 
  #----------------------------------------------------------------------------
  #*Frame update
  #----------------------------------------------------------------------------
  def update
    if Input.trigger?(Input::B)
      $scene = Scene_Map.new
    end
    if Input.trigger?(Input::F5)
      Audio.se_play("Audio/SE/Tom-1",100,100)
      @animation[0] = 0
      @drumdummy.refresh(0)
    end
    if Input.trigger?(Input::F6)
      Audio.se_play("Audio/SE/Tom-2",100,100)
      @animation[1] = 0
      @drumdummy.refresh(1)
    end
    if Input.trigger?(Input::F7)
      Audio.se_play("Audio/SE/Tom-3",100,100)
      @animation[2] = 0
      @drumdummy.refresh(2)
    end
    if Input.trigger?(Input::F8)
      Audio.se_play("Audio/SE/Hi-Hat",100,100)
      @animation[3] = 0
      @drumdummy.refresh(3)
    end
    if Input.trigger?(Input::C)
      Audio.se_play("Audio/SE/Bassdrum",100,100)
      @animation[4] = 0
      @drumdummy.refresh(4)
    end
    #update lighting effects
    animation
  end
 
  #----------------------------------------------------------------------------
  #*animation
  #----------------------------------------------------------------------------
  #Takes care of animating the drum's lighting effects
  #----------------------------------------------------------------------------
  def animation
    for i in 0...@animation.size
      if @animation[i] == 0
        #Create lighting effect for the drum
        @drumdummy.refresh(i)
      end
      unless @animation[i] == -1
        #Progress a frame
        @animation[i] += 1
        if @animation[i] == 10
          #Remove lighting effect
          @drumdummy.clear(i)
          @animation[i] = -1
        end
      end
    end
  end
end


#==============================================================================
#**Window_Drumshelp
#------------------------------------------------------------------------------
#Help window displaying the different input possibilities
#==============================================================================

class Window_Drumshelp < Window_Base
 
  #----------------------------------------------------------------------------
  #*Object initialization
  #----------------------------------------------------------------------------
  def initialize
    super(0,0,640,64)
    self.contents = Bitmap.new(width - 32, height - 32)
    text = ["F5: Drum 1", "F6: Drum 2", "F7: Drum 3", "F8: Hi-Hat", "Enter: Bass"]
    w = self.contents.width/text.size
    for i in 0...text.size
      self.contents.draw_text(i * w,0,w,32,text[i],1)
    end
  end
end


#==============================================================================
#**Spriteset_Drums
#------------------------------------------------------------------------------
#This class takes care of drawing the drum's graphics onscreen
#==============================================================================

class Spriteset_Drums
 
  #----------------------------------------------------------------------------
  #*Object initialization
  #----------------------------------------------------------------------------
  def initialize
    @viewport = Viewport.new(35,95,640,480)
    @viewport.z = 5000
    @sprite = Sprite.new(@viewport)
    @drums = RPG::Cache.picture('Rock Band Drums.png')
    @sprite.bitmap = @drums
  end
 
  #----------------------------------------------------------------------------
  #*Dispose
  #----------------------------------------------------------------------------
  def dispose
    @viewport.dispose
    @sprite.dispose
  end
end


#==============================================================================
#**Drum_Dummy
#------------------------------------------------------------------------------
#This class draws the drum's lighting effects
#==============================================================================

class Drum_Dummy
 
  #----------------------------------------------------------------------------
  #*Object initialization
  #----------------------------------------------------------------------------
  def initialize
    @sprite = []
    @lights = RPG::Cache.picture('DrumsLights')
    #Create a rect for the drums and pedal
    @rect = Rect.new(1,1,130,130)
    @rect2 = Rect.new(1,134,130,130)
    #create a new bitmap for each drum's lighting effect
    for i in 0...5
      @sprite[i] = Sprite.new
      @sprite[i].bitmap = Bitmap.new(640,480)
      @sprite[i].z = 9999
      @sprite[i].visible = false
    end
  end
 
  #----------------------------------------------------------------------------
  #*Refresh
  #----------------------------------------------------------------------------
  def refresh(drum)
    #Clear lighting effect to avoid overlap
    @sprite[drum].bitmap.clear
    case drum
    #Get coordinates based on drum
    when 0
      x = 43
      y = 198
    when 1
      x = 170
      y = 99
    when 2
      x = 335
      y = 99
    when 3
      x = 462
      y = 198
    when 4
      x = 255
      y = 371
    end
    #Create correct effect in the given bitmap
    if drum == 4 ? @sprite[drum].bitmap.blt(x,y,@lights,@rect2) :
                   @sprite[drum].bitmap.blt(x,y,@lights,@rect)
    end
    #Make lighting effect visible             
    @sprite[drum].visible = true
  end
 
  #----------------------------------------------------------------------------
  #*Dispose
  #----------------------------------------------------------------------------
  def dispose
    for i in 0...@sprite.size
      @sprite[i].dispose
    end
  end
 
  #----------------------------------------------------------------------------
  #*clear
  #----------------------------------------------------------------------------
  #Removes the specified drum's lighting effect when called
  #----------------------------------------------------------------------------
  def clear(drum)
    @sprite[drum].bitmap.clear
  end
end
Paste this script above main and under the other standard scripts.

Instructions

Instructions in script.
NOTE: Audiofiles and images can be obtained in the demo, this script won't function properly without them

Compatibility
This script does not rewrite any standard methods and does not make use of its own global variables. It should be compatible with anything out there, including the SDK

Credits and Thanks

  • Berans - Making the script
  • Sniper308 - Inspiring the script and providing the graphics

Author's Notes

Please credit me and sniper308 if you use this in your game. Other than that, have fun with it!
I'm always open for feedback.
Also, there are two ways to access the scene in the demo, both of which are hidden ;)
you'll be able to see them easily in the editor though :p

********
Resource Artist
Rep:
Level 94
\\\\\
Project of the Month winner for June 2009
Hahaha, almost pointless but fun as hell!  :lol:

**
Rep: +0/-0Level 85
ALMOST pointless? Sir, I am insulted but your severe underestimations :P
Seriously though, this was a 1-hour job based one someone's idea. Positioning and getting the graphics to animate right took by far the longest.
I'm glad you like it :P

*
? ? ? ? ? ? ? ? ? The nice kind of alien~
Rep:
Level 92
Martian - Occasionally kind
What a lovely novel idea.
I love it ^_^

Excellent work Berans

*
Rep:
Level 97
2014 Most Unsung Member2014 Best RPG Maker User - Engine2013 Best RPG Maker User (Scripting)2012 Most Mature Member2012 Favorite Staff Member2012 Best RPG Maker User (Scripting)2012 Best MemberSecret Santa 2012 ParticipantProject of the Month winner for July 20092011 Best Use of Avatar and Signature Space2011 Best RPG Maker User (Scripting)2011 Most Mature Member2011 Favourite Staff Member2011 Best Veteran2010 Best RPG Maker User (Scripting)2010 Most Mature Member
Yeah, it is a fun idea. Nice work.

**
Rep: +0/-0Level 85
I'm currently working on making a Piano script too for the less rythmically inclined (on request by a few people)
I can't completely use the same system though, since I created a bitmap for each lighting effect. Doing that for 4 octaves(48 keys including the black ones) creates some pretty big issues with lag. I'll probably have to create them only when called for
EDIT: Here's a link to my piano script. This one allows for input codes to give the system some use.
http://forum.chaos-project.com/index.php?topic=1661.msg34547
« Last Edit: August 24, 2008, 04:08:57 AM by Berans »

**
Rep: +0/-0Level 84
well to reduce lag couldn't you use 1 or 2 octaves making it  12 or 24 keys?
LOLZERSMATICITICION

*
Rep: +0/-0Level 0
RMRK Junior
Hypovolaemia bxn.noyj.rmrk.net.ocz.ka ascending costing low cost levitra 20 mg levitra generic levitra 20mg information cheapest rumalaya forte real viagra online canada cheap betoptic tadalafil cialis generic cialis canada pharmacy cialis generic cialis irrelevant acalculous <a href="http://gaiaenergysystems.com/levitra-20-mg/">levitra 20mg information</a> <a href="http://sallyrjohnson.com/levitra-20-mg/">generic levitra</a> <a href="http://myquickrecipes.com/levitra-generic/">purchase levitra</a> <a href="http://thearkrealmproject.com/rumalaya-forte/">online rumalaya forte</a> <a href="http://vintagepowderpuff.com/viagra-pills/">viagra</a> <a href="http://theatreghost.com/betoptic/">discount betoptic</a> <a href="http://myquickrecipes.com/tadalafil/">generic cialis 20 mg tablets</a> <a href="http://circulateindia.com/cialis-generic/">www.cialis.com</a> modest epiphyseal http://gaiaenergysystems.com/levitra-20-mg/ levitra canada free shipping http://sallyrjohnson.com/levitra-20-mg/ levitra buy levitra online http://myquickrecipes.com/levitra-generic/ generic levitra vardenafil 20mg http://thearkrealmproject.com/rumalaya-forte/ cheapest rumalaya forte http://vintagepowderpuff.com/viagra-pills/ viagra http://theatreghost.com/betoptic/ betoptic http://myquickrecipes.com/tadalafil/ generic cialis 20 mg tablets http://circulateindia.com/cialis-generic/ cialis generic intoxication together, aqueous.