Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Test Your Might / Smash Button / Carnival Strenth Test

*NOTE: had to make edits to my posts so this thread would be less confusing...

@EVERYONE! - dug these out the script archives,
I want to modify these scripts so there's no need for all of SDK, and MACL.

o test your might (works! currently working on showing sprite timer)
o smash button
o carnival strength test (works! need support on vertical option)
o button masher

CHALLENGE #1 'TEST YOUR MIGHT' (no longer requires SDK or MACL and has switch and play audio feature!)
==========================
Code:
#===============================================================================

#                Modified Script "MIGHT BUTTON" By: GameFace101

#                                Version : 1.1

#                               Date :11-9-2009

#===============================================================================

#                Original Script "TEST YOUR MIGHT" By: Chaosg1 

#                               Version : 1.0

#                              Date :13-09-2006

#===============================================================================

#                  New Version:

#                  - no longer requires SDK or MACL 

#                  - music settings

#                  - switch settings

#                  - 

#

#         small thanks to Glitch Finder and Brewmeister for Script Support.

#            http://www.arpgmaker.com/viewtopic.php?p=672553#p672553

#

#                   to call script, create event and use: 

#

#                        $scene = Test_Might.new(4,2,3)

#                         

#                      (4=seconds 2=increase 3=decrease)

#===============================================================================

#

# default MIGHT switch = 101 (victory!)

# default WEAK switch = 102 (defeat!)

# default might music - "Audio/BGM/006-Boss02"

# 

#

#

#===============================================================================

class Test_Might

#-------------------------------------------------------------------------------

# * Main - Handles drawing/disposing windows and the main loop

#-------------------------------------------------------------------------------

 

def initialize(time,increase,decrease)

Audio.bgm_play("Audio/BGM/006-Boss02",100,100)#-------------------=[might music]

$test_passed = false

@might = $game_switches[101]#----------------------------------=[victory switch]

@weak = $game_switches[102]#------------------------------------=[defeat switch]

@window_status = Window_Base.new(230,200 ,196,60)# window's  position / size

@time = time

@increase = (increase*5) * $game_party.actors[0].str/100 + $game_party.actors[0].int/100

@decrease = decrease

@might_value = 0

@window_status.contents = Bitmap.new(@window_status.width - 32, @window_status.height - 32)

@window_status.opacity = 100

end

#--------------------------------------------------------------------------

# * Main

#--------------------------------------------------------------------------

def main

@spriteset_map = Spriteset_Map.new

Graphics.transition

# Main loop

loop do

# Update game screen

Graphics.update

# Update input information

Input.update

# Frame update

update

#refresh

refresh

# Abort loop if screen is changed

if $scene != self

break

end

end

# Prepare for transition

Graphics.freeze

# Dispose of windows

@window_status.dispose

@spriteset_map.dispose

 

end

#-------------------------------------------------------------------------------

# * Refresh

#-------------------------------------------------------------------------------

def refresh  

@might = $game_switches[101]#----------------------------------=[victory switch]

@weak = $game_switches[102]#------------------------------------=[defeat switch]

@total_sec = Graphics.frame_count / Graphics.frame_rate

@window_status.contents.clear

@window_status.contents.draw_text(-34,-2, 180, 42, "PRESS MIGHT!", 2)

@window_status.draw_gradient_bar(0, 0, @might_value, 1000, "might", width = nil, height = nil, hue = 0, back = "Back", back2 = "Back2")

end

#-------------------------------------------------------------------------------

# * Update

#-------------------------------------------------------------------------------

def update

if @time <= 0 and @might_value < 999

@memorized_bgm = @playing_bgm#

$scene = Scene_Map.new

$game_system.se_play($data_system.buzzer_se)#--------------------=[defeat sound]

$test_passed = false #-------------------------------------------------=[defeat]

$game_switches[102] = true #------------------------------------=[defeat switch]

Audio.bgm_play("Audio/BGM/menu01", 100, 100)#---------=[defeat background music]

$game_map.need_refresh = true#----------------------------------------=[refresh]

elsif @might_value > 999 and @time > 0

@memorized_bgm = @playing_bgm#

$scene = Scene_Map.new

$game_system.se_play($data_system.decision_se)#-----------------=[victory sound]

$test_passed = true#--------------------------------------------------=[victory]

$game_switches[101] = true#------------------------------------=[victory switch]

Audio.bgm_play("Audio/BGM/menu01", 100, 100)#--------=[victory background music]

$game_map.need_refresh = true#----------------------------------------=[refresh]

 

return

end

@might_value -= @decrease if @might_value > 0 and @might_value < 999

if Input.trigger?(Input::X)

@might_value += @increase

end

@spriteset_map.update

if Graphics.frame_count / Graphics.frame_rate != @total_sec

refresh

@time -=1

end

end

end

#########################################[MODULE: Load Gradient from RPG::Cache]

module RPG

  module Cache

    def self.gradient(filename, hue = 0)

      self.load_bitmap("Graphics/Gradients/", filename, hue)

    end

  end

end

class Window_Base < Window

  OUTLINE = 1

  BORDER = 1

#####################################################[METHOD: Draw Gradient Bar]

  def draw_gradient_bar(x, y, min, max, file, width = nil, height = nil, hue = 0, back = "Back", back2 = "Back2")

    bar = RPG::Cache.gradient(file, hue)

    back = RPG::Cache.gradient(back)

    back2 = RPG::Cache.gradient(back2)

    cx = BORDER

    cy = BORDER

    dx = OUTLINE

    dy = OUTLINE

    zoom_x = width != nil ? width : back.width

    zoom_y = height != nil ? height : back.height

    percent = min / max.to_f if max != 0

    percent = 0 if max == 0

    back_dest_rect = Rect.new(x,y,zoom_x,zoom_y)

    back2_dest_rect = Rect.new(x+dx,y+dy,zoom_x -dx*2,zoom_y-dy*2)

    bar_dest_rect = Rect.new(x+cx,y+cy,zoom_x * percent-cx*2,zoom_y-cy*2)

    back_source_rect = Rect.new(0,0,back.width,back.height)

    back2_source_rect = Rect.new(0,0,back2.width,back2.height)

    bar_source_rect = Rect.new(0,0,bar.width* percent,bar.height)

    self.contents.stretch_blt(back_dest_rect, back, back_source_rect)

    self.contents.stretch_blt(back2_dest_rect, back2, back2_source_rect)

    self.contents.stretch_blt(bar_dest_rect, bar, bar_source_rect)

  end  

####################################################[working on verticle option] 

  def draw_vertical_gradient_bar(x, y, min, max, file, width = nil, height = nil, hue = 0, back = "Back", back2 = "Back2")

    bar = RPG::Cache.gradient(file, hue)

    back = RPG::Cache.gradient(back)

    back2 = RPG::Cache.gradient(back2)

    cx = BORDER

    cy = BORDER

    dx = OUTLINE

    dy = OUTLINE

    zoom_x = width != nil ? width : back.width

    zoom_y = height != nil ? height : back.height

    percent = min / max.to_f if max != 0

    percent = 0 if max == 0

    bar_y = (zoom_y - zoom_y * percent).ceil

    source_y = bar.height - bar.height * percent

    back_dest_rect = Rect.new(x,y,zoom_x,zoom_y)

    back2_dest_rect = Rect.new(x+dx,y+dy,zoom_x -dx*2,zoom_y-dy*2)

    bar_dest_rect = Rect.new(x+cx,y+bar_y+cy,zoom_x-cx*2,(zoom_y * percent).to_i-cy*2)

    back_source_rect = Rect.new(0,0,back.width,back.height)

    back2_source_rect = Rect.new(0,0,back2.width,back2.height)

    bar_source_rect = Rect.new(0,source_y,bar.width,bar.height * percent)

    self.contents.stretch_blt(back_dest_rect, back, back_source_rect)

    self.contents.stretch_blt(back2_dest_rect, back2, back2_source_rect)

    self.contents.stretch_blt(bar_dest_rect, bar, bar_source_rect)

  end

end

#######################################################[working on timer sprite]

 

#==============================================================================

# ** Might_Timer

#------------------------------------------------------------------------------

#  This sprite is used to display the timer.

#==============================================================================

class Might_Timer < Sprite

 

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    super

    self.bitmap = Bitmap.new( 88, 48 )

    self.bitmap.font.name = "Arial"

    self.bitmap.font.size = 32

    self.x = 640 - self.bitmap.width

    self.y = 0

    self.z = 500

    update

  end

 

  #--------------------------------------------------------------------------

  # * Dispose

  #--------------------------------------------------------------------------

  def dispose

    if self.bitmap != nil

      self.bitmap.dispose

    end

    super

  end

 

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

   

    super

    # If timer needs to be redrawn

    if $scene.update_count / Graphics.frame_rate != @total_sec

      # Clear window contents

      self.bitmap.clear

      # Calculate total number of seconds

      @total_sec = $scene.update_count / Graphics.frame_rate

      # Make a string for displaying the timer

      min = @total_sec / 60

      sec = @total_sec % 60

      text = sprintf( "%02d:%02d", min, sec )

      # Draw timer

      self.bitmap.font.color.set( 255, 255, 255 )

      self.bitmap.draw_text( self.bitmap.rect, text, 1 )

    end

  end

end

 
CHALLENGE #2 'SMASH BUTTON' (want to modify into one script so that it doesn't require SDK and MACL)
========================
Code:
#==============================================================================

# ** Smashing Button System

#script&#058; to call use: $scene = Scene_SmashButton.new(1, 1, 'A')

#------------------------------------------------------------------------------

# MephistoX

# Version 1.0

# 01/03/09

# SDK : Version 2.4+

#------------------------------------------------------------------------------

# * Version History :

 

#   Version 1 ---------------------------------------------------- (01/03/09)

#     - Log : First Version Released

#------------------------------------------------------------------------------

# * Requirements :

#

#   Method & Class Library (2.3 +)

#------------------------------------------------------------------------------

# * Description :

#

#   This Script let you to call a Scene with a Bar with a X number of filled,

#   you need to smash a button to fill the bar, if you fill the bar, a Local

#   switch will be active, else, you return to the Map.

#   

#   This System is similar to the MK1 Bonus Games, or other Similars like

#   Defeat the Bull, MK Shaoling Monks, o Resident Evil Open Doors Engine.

#------------------------------------------------------------------------------

# * Instructions :

#

#   Place The Script Below the SDK and Above Main.

#   Refer to Syntax to call the Smashing Scene

#------------------------------------------------------------------------------

# * Syntax :

#

#   Calling Scene :

#    - Script : Scene_SmashButton.new(map_id, event_id, switch_key, options = {})

#

#   Parameters(Must be Defined)

#   

#   - map_id = Event Map ID, this is to active the Local Switch

#   - event_id = Event ID, see above

#   - switch_key = Local Switch Key('A', 'B', 'C', 'D')

#

#

#               |Options(Optional Use)|                    |Defaults/Examples|

#

#    - 'Gradient' => Gradient Graphic for the Window     = 'MP_001-Oranges01'

#    - 'Button' => Button to smash to fill the Bar       = Input::C

#    - 'Resistance' => Resistance of the Bar             = 1

#    - 'Power' => Smash Button Power                     = 1

#    - 'Filled' => Bar Initial Filled                    = rand_between(20, 50)

#    - 'Max' => Bar Max Filled                           = 100

#

#==============================================================================

 

#------------------------------------------------------------------------------

# * SDK Log Script

#------------------------------------------------------------------------------

SDK.log('Smashing Button System', 'MephistoX', 1.0, '01/03/09')

SDK.check_requirements(2.4, [], {'Method & Class Library' => 2.2})

 

#------------------------------------------------------------------------------

# * Begin SDK Enable Test

#------------------------------------------------------------------------------

if SDK.enabled?('Smashing Button System')

 

#==============================================================================

# ** Scene_SmashButton

#------------------------------------------------------------------------------

#  This class performs Smashing Button Screen Processing.

#==============================================================================

  

class Scene_SmashButton < SDK::Scene_Base

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize(map, event, key, options = {})

    # Sets Default Parameters (If Undefined)

    gradient = options.member?('Gradient') ? options['Gradient'] : 'MP_001-Oranges01'

    button = options.member?('Button') ? options['Button']  : Input::C

    resistance = options.member?('Resistance') ? options['Resistance'] : 1

    power = options.member?('Power') ? options['Power'] : 1

    filled = options.member?('Filled') ? options['Filled'] : rand_between(20, 50)

    max = options.member?('Max') ? options['Max'] : 300

    # Saves Parameters

    @map        = map              # Event Map ID

    @event      = event            # Event ID

    @key        = key              # Local Switch Key

    @gradient   = gradient         # Window's Bar Gradient

    @button     = button           # Button to Trigger

    @resistance = resistance       # Bar Resistance

    @power      = power            # Smash Power

    @filled     = filled           # Initial Filled

    @max        = max              # Maximum Fill

  end

  #--------------------------------------------------------------------------

  # * Main Sprite_Set

  #--------------------------------------------------------------------------

  def main_spriteset

    # Sets Up Spriteset

    @spriteset = Spriteset_Map.new

  end

  #--------------------------------------------------------------------------

  # * Main Processing : Window Initialization

  #--------------------------------------------------------------------------

  def main_window

    super

    @bar_window = Window_Bar.new(@gradient, @filled, @max)

    @bar_window.active = true

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    super

    # Every Frame substrac Resistance to Bar Filling if Self > 0

    @bar_window.filling -= @resistance if @bar_window.filling > 0

    # Refresh Window

    @bar_window.refresh

    # If B button was pressed

    if Input.trigger?(Input::B)

      # Play cancel SE

      $game_system.se_play($data_system.cancel_se)

      # Switch to menu screen

      $scene = Scene_Map.new

      return

    end

    # If Defined Button was pressed

    if Input.trigger?(@button)

      # Play decision SE

      $game_system.se_play($data_system.decision_se)

      # Add XNumber to the Bar Filling if self is > Maximum Filling

      @bar_window.filling += (@power *10) if @bar_window.filling < @max

      return

    end

    # If Bar Filling < 1

    if @bar_window.filling < 1

      # Play wrong SE

      Audio.se_play('Audio/SE/058-Wrong02', 80)

      # Return to Map

      $scene = Scene_Map.new

      return

    end

    # If Bar Filling is Full

    if @bar_window.filling >= @max

      # Active Self Switch

      key = [@map, @event, @key]

      $game_self_switches[key] = true

      $game_map.need_refresh = true

      # Return to Map

      $scene = Scene_Map.new

      return

    end

  end

end

 

 

#==============================================================================

# ** Window_Bar

#------------------------------------------------------------------------------

#  This window displays a Gradient Bar

#==============================================================================

 

class Window_Bar < Window_Base

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_accessor :filling         # Bar Initial Filling

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize(gradient, filling, max)

    super(0, 0, 160, 64)

    self.contents = Bitmap.new(width - 32, height - 32)

    self.back_opacity = 160

    @gradient = gradient

    @filling = filling

    @max = max

    refresh

  end

  #--------------------------------------------------------------------------

  # * Refresh

  #--------------------------------------------------------------------------

  def refresh

    self.contents.clear

    # Draw Gradient Bara

    self.contents.draw_trick_gradient_bar(0, 0, @filling, @max, 

    @gradient, self.width - 32, 8, 'MP_001-Back01','MP_001-Back02')

  end

end

 

#--------------------------------------------------------------------------

# * End SDK Enable Test

#--------------------------------------------------------------------------

end
CHALLENGE #3: 'CARNIVAL STRENGTH TEST' (works! doesn't require graphic files, SDK or MACL, want to modify into verticle)
=================================
Code:
#==============================================================================

# ** Carnival Strength Test

#------------------------------------------------------------------------------

#  Author  :  Paradox

#  Version :  1.2

#  Support :  Trickster & Yeyinde

=begin

 - Instructions:

   - This script is simple enough. Refer to the topic if need be.

-to call use:

# Which switch to flag

$game_temp.switch_id = 378

# How hard

#$game_temp.carnival_strength = 100

# Call the game

#str_test = StrengthTest.new

=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

  #--------------------------------------------------------------------------

  # * Public Instance Variables

  #--------------------------------------------------------------------------

  attr_accessor :carnival_running           #  Whether or not it is running.

  attr_accessor :carnival_strength          #  The required strength to pass.

  attr_reader   :carnival_score             #  The current score.

  attr_accessor :switch_id                  #  The switch to flag.

  #--------------------------------------------------------------------------

  # * Object Initialization (aliased)

  #--------------------------------------------------------------------------

  alias new_initialize initialize

  #--------------------------------------------------------------------------

  def initialize

    new_initialize

    @carnival_running = false

    @carnival_strength = 100

    @carnival_score = 0

    @switch_id = 25#1

  end

  def carnival_score=(score)

    @carnival_score = [[score, 0].max, 160].min

  end

end

#==============================================================================

# ** Window_StrengthTest

#------------------------------------------------------------------------------

#  This class brings up the StrengthTest window.

#==============================================================================

class Window_StrengthTest < Window_Base

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    super(0, 100, 200, 200)#0,280,100,200 = x,y win position - x/y=win size

    self.contents = Bitmap.new(width - 32, height - 32)

    self.opacity = 255#test replace 0

    @bg = true

    refresh

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def refresh

    @score = $game_temp.carnival_score

    self.contents.clear

    # Fill the background.

    if !@bg

      self.contents.fill_rect(4, 0, 12, 160, Color.new(0, 0, 0))#4,0,12,160

    else

      @background_img = RPG::Cache.picture("power_bar")

      self.contents.blt(1, 2, @background_img, Rect.new(0, 0, 200, 300))#0,0,20,60

    end

    # Store the height

    height = (@score / 100.0) * 100#100.0) *150

    if height >= 280#143 how tall

      height = 280#143 how tall

    end

    # Draw the bar.

    for i in 6..19#? 4..16??? 4=left stretch 16 right stretch 

      color = Color.new(30 * i, 20 * i, 10 * i)#orange 20,10,5#gold 10,10,3

      self.contents.fill_rect(i, (170 - height), 1, height, color)#bottom stretch

    end

  end

  def update

    super

    refresh if @score != $game_temp.carnival_score

  end

end

#==============================================================================

# ** Game_Carnival

#------------------------------------------------------------------------------

#  This class deals with everything related to the Carnival mini-game.

#==============================================================================

class StrengthTest

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    # Set the presses to 0

    $game_temp.carnival_score = 0

    # Create the required window.

    @carnival_window = Window_StrengthTest.new

    # Tell the game that the carnival is running.

    $game_temp.carnival_running = true

    # Disable the menu

    $game_system.menu_disabled = false#true

    update while $game_temp.carnival_running

    end_game

  end

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    Graphics.update

    Input.update

    if $game_temp.carnival_score <= 0

      $game_temp.carnival_score = 0

    end

    @carnival_window.update

    @pressed = false

    # If the Space-Bar/Enter button is pressed.

    if Input.trigger?(Input::C)

      # Increment the number of presses.

      $game_temp.carnival_score += 10

      @pressed = true

    end

    # If the Escape/X button is pressed.

    if Input.trigger?(Input::X)

      $game_temp.carnival_running = false

    end

    unless @pressed

      $game_temp.carnival_score -= 1

    end

  end

  #--------------------------------------------------------------------------

  # * End Game

  #--------------------------------------------------------------------------

  def end_game

    # Disable and dispose the Carnival.

    $game_temp.carnival_running = false

    @carnival_window.dispose

    $game_switches[$game_temp.switch_id] = $game_temp.carnival_score >= 

      $game_temp.carnival_strength

    $game_map.need_refresh = true

  end

end

#==============================================================================

# ** Interpreter (part 1)

#------------------------------------------------------------------------------

#  This interpreter runs event commands. This class is used within the

#  Game_System class and the Game_Event class.

#==============================================================================

class Interpreter

  #--------------------------------------------------------------------------

  # * Frame Update (aliased)

  #--------------------------------------------------------------------------

  alias new_update update

  def update

    # If the game is running, prevent the interpreter from updating.

    unless $game_temp.carnival_running

      new_update

    end

  end

end
CHALLENGE #4 'BUTTON MASHER' (modify into one script so that it doesn't require SDK and MACL)
=========================
Code:
#==============================================================================

# ** Button Masher Minigame

#------------------------------------------------------------------------------

# Author      : Eilei

# Version     : 1.0

# Date        : September 14, 2007

# SDK Version : Version 2.3, Part I

#==============================================================================

 

=begin                    Installation Instructions

 

0.) Get SDK and MACL if you don't have them

 

1.) Paste Button Masher Minigame script just above Main

 

                          Usage Instructions

 

1.) Call a script command in the event you want to use to trigger a button-

    mashing minigame, and put in

    

    temp = Scene_ButtonMasher_Minigame( @event_id, 'X' )

    

    where X is replaced with the self-switch you want set to ON when the game

    is won.  You can leave 'X' out and it will default to self-switch A.

    

2.) Put in lines for any of the following if you don't want to use the default:

 

      temp.loss_rate  = ?, the amount of bar lost when no button is pushed

      temp.gain_rate  = ?, the amount of bat gained when the button is pushed

      temp.mash_key   = Input::?, the button you want to the player to mash

      temp.max_fill   = ?, the total amount needed to fill the bar

      temp.bar_width  = ? the bar width in pixels

      temp.bar_height = ?, the bar height in pixels

      temp.gradient   = '?', the name of the gradient file to use for the bar

      temp.back       = the frst background for the gradient bar

      temp.back2      = the second background for the gradient bar

      temp.bar_border = the width of the background border around the bar

      temp.max_time   = the duration of the game, in seconds

      temp.game_music = '?', the name of the song file you want playing

                        can also take volume and pitch parameters

                        

3.) Finally, set

      

    $scene = temp

 

    The game will exit with the switch specified unchanged if the game wasn't

    won, or set to ON if the game was won.

 

4.) See the events in the demo for a better idea of how to do this!

 

                          Legal Notices

                          

    This script is Copyright © 2007 C. Schrupp

 

    This script is free software; you can redistribute it and/or modify

    it under the terms of the GNU General Public License as published by

    the Free Software Foundation; either version 3 of the License, or

    (at your option) any later version.

 

    This script is distributed in the hope that it will be useful,

    but WITHOUT ANY WARRANTY; without even the implied warranty of

    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the

    GNU General Public License for more details.

 

    A copy of the GNU General Public License is in gpl.txt in the main

    directory.  If not, see <http://www.gnu.org/licenses/>.

=end

 

#--------------------------------------------------------------------------

# * Begin SDK Log

#--------------------------------------------------------------------------

SDK.log( 'Button Masher Minigame', 'Eilei', '1.0', '2007-09-14')

 

#--------------------------------------------------------------------------

# * Begin SDK Requirement Check

#--------------------------------------------------------------------------

SDK.check_requirements( 2.3, [ 1 ] )

 

#--------------------------------------------------------------------------

# * Begin SDK Enable Test

#--------------------------------------------------------------------------

if SDK.enabled?( 'Button Masher Minigame' )

 

class Scene_ButtonMasher < SDK::Scene_Base

  

  #--------------------------------------------------------------------------

  #  Scene default values

  #--------------------------------------------------------------------------

  # default gameplay values A loss/gain ratio under 1/5 is very, very difficult.

  DEFAULT_LOSS_RATE            = 1

  DEFAULT_GAIN_RATE            = 6

  DEFAULT_GAME_TIME            = 30

  DEFAULT_MAX_BAR_FILL         = 100

  DEFAULT_MASH_KEY             = Input::A

  

  # default gradient bar

  DEFAULT_BAR_WIDTH            = 60

  DEFAULT_BAR_HEIGHT           = 12

  DEFAULT_GRADIENT             = '001-Primary01'

  DEFAULT_GRADIENT_BACKGROUND1 = 'back'

  DEFAULT_GRADIENT_BACKGROUND2 = 'back2'

  DEFAULT_BAR_BORDER_WIDTH     = 1

  

  # default music 

  DEFAULT_GAME_MUSIC           = RPG::AudioFile.new( 'marblem4' )

  

  #--------------------------------------------------------------------------

  #  Externally accessible variables

  #--------------------------------------------------------------------------

  attr_reader :update_count

  

  # methods for overwriting the defaults

  attr_writer :loss_rate

  attr_writer :gain_rate

  attr_writer :mash_key

  attr_writer :max_fill

  attr_writer :bar_width

  attr_writer :bar_height

  attr_writer :gradient

  attr_writer :back

  attr_writer :back2

  attr_writer :bar_border

  

  #--------------------------------------------------------------------------

  #  Methods

  #--------------------------------------------------------------------------

  #--------------------------------------------------------------------------

  # * max_time is settable in seconds, but we want frames

  #--------------------------------------------------------------------------

  def max_time=( seconds )

    @max_time = seconds * Graphics.frame_rate

  end

  

  #--------------------------------------------------------------------------

  # * game_music takes a string and makes an AudioFile for the minigame

  #--------------------------------------------------------------------------

  def game_music=( music_name, volume = 100, pitch = 100 )

    @game_music = RPG::AudioFile.new( music_name, volume, pitch )

  end

  

  #--------------------------------------------------------------------------

  # * initialize sets up the parameters for the minigame

  #

  #   id     : event_id of the event to place the bar over

  #   switch : names the event's self-switch to set to true or false

  #            depending on successful completion of the minigame

  #--------------------------------------------------------------------------

  def initialize( id = 1, switch = 'A' )

 

    @over_event    = id

    @result_switch = switch

 

    @loss_rate     = DEFAULT_LOSS_RATE

    @gain_rate     = DEFAULT_GAIN_RATE

    @mash_key      = DEFAULT_MASH_KEY

    @max_fill      = DEFAULT_MAX_BAR_FILL

    @max_time      = DEFAULT_GAME_TIME * Graphics.frame_rate

 

    @bar_width     = DEFAULT_BAR_WIDTH

    @bar_height    = DEFAULT_BAR_HEIGHT

    @gradient      = DEFAULT_GRADIENT

    @back          = DEFAULT_GRADIENT_BACKGROUND1

    @back2         = DEFAULT_GRADIENT_BACKGROUND2

    @bar_border    = DEFAULT_BAR_BORDER_WIDTH

    

    @game_music    = DEFAULT_GAME_MUSIC

  end

 

  

  #--------------------------------------------------------------------------

  # * Main Processing : Variable Initialization

  #--------------------------------------------------------------------------

  def main_variable

    @current_fill = 0          # current bar fill value

    @update_count = @max_time  # frames spent in the minigame

  end

 

  #--------------------------------------------------------------------------

  # * Main Processing : Spriteset Initialization

  #--------------------------------------------------------------------------

  def main_spriteset

    @spriteset = Spriteset_Map.new

  end

 

  #--------------------------------------------------------------------------

  # * Main Processing : Sprite Initialization

  #--------------------------------------------------------------------------

  def main_sprite

    # set up the gradient bar

    @bar_sprite = Sprite.new

    @bar_sprite.bitmap = Bitmap.new( @bar_width, @bar_height )

 

    # Set the gradient bar over someone

    @bar_sprite.x = $game_map.events[ @over_event ].screen_x - @bar_width / 2

    @bar_sprite.y = $game_map.events[ @over_event ].screen_y - 50 - @bar_height

    

    # amazingly complicated gradient bar drawing call; THANKS TRICKSTER

    @bar_sprite.bitmap.draw_trick_gradient_bar( 0, 0, @current_fill, @max_fill,

      @gradient, @bar_width, @bar_height, @back, @back2, @bar_border,

      @bar_border, @bar_border, @bar_border )

 

    # make a timer sprite if there's a time limit on the game

    # once created it takes care of itself

    if @max_time > 0

      @timer_sprite = Sprite_ButtonMasher_Timer.new

    end

  end

 

  #--------------------------------------------------------------------------

  # * Main Processing : Window Initialization

  #--------------------------------------------------------------------------

  def main_window

  end

  

  #--------------------------------------------------------------------------

  # * Main Processing : Audio Initialization

  #--------------------------------------------------------------------------

  def main_audio

    $game_system.bgm_play( @game_music )

  end

 

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    

    if @update_count == 0 and @max_time > 0

      # Time's up

      $game_self_switches[ [ $game_map.map_id, @over_event,

        @result_switch ] ] = false

      $game_map.need_refresh = true

      $scene = Scene_Map.new

    elsif @current_fill >= @max_fill

      # Minigame won!

      $game_self_switches[ [ $game_map.map_id, @over_event,

        @result_switch ] ] = true

      $game_map.need_refresh = true

      $scene = Scene_Map.new

    else

      # Normal processing

      @update_count -= 1

      

      if Input.trigger?( @mash_key )

        @current_fill += @gain_rate

      else

        @current_fill = [ @current_fill - @loss_rate, 0 ].max

      end

    end

      

    # update the amazingly complicated gradient sprite values; THANKS TRICKSTER

    @bar_sprite.bitmap.draw_trick_gradient_bar( 0, 0, @current_fill, @max_fill,

      @gradient, @bar_width, @bar_height, @back, @back2, @bar_border,

      @bar_border, @bar_border, @bar_border )

  end

  

  #--------------------------------------------------------------------------

  # * Main Processing : Ending

  #--------------------------------------------------------------------------

  def main_end

    $game_system.bgm_stop

  end

 

end # class Scene_ButtonMasher

 

#==============================================================================

# ** Sprite_ButtonMasher_Timer

#------------------------------------------------------------------------------

#  This sprite is used to display the timer.

#==============================================================================

class Sprite_ButtonMasher_Timer < Sprite

  

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    super

    self.bitmap = Bitmap.new( 88, 48 )

    self.bitmap.font.name = "Arial"

    self.bitmap.font.size = 32

    self.x = 640 - self.bitmap.width

    self.y = 0

    self.z = 500

    update

  end

  

  #--------------------------------------------------------------------------

  # * Dispose

  #--------------------------------------------------------------------------

  def dispose

    if self.bitmap != nil

      self.bitmap.dispose

    end

    super

  end

  

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

    

    super

    # If timer needs to be redrawn

    if $scene.update_count / Graphics.frame_rate != @total_sec

      # Clear window contents

      self.bitmap.clear

      # Calculate total number of seconds

      @total_sec = $scene.update_count / Graphics.frame_rate

      # Make a string for displaying the timer

      min = @total_sec / 60

      sec = @total_sec % 60

      text = sprintf( "%02d:%02d", min, sec )

      # Draw timer

      self.bitmap.font.color.set( 255, 255, 255 )

      self.bitmap.draw_text( self.bitmap.rect, text, 1 )

    end

  end

end

 

end # SDK.enabled? check

 

In the beginning...

I'm going to start with the "test your might" script

I'm getting this *Error:
################################
# NameError occurred while running script.
# uninitialized constant Interpreter::Increase
################################

I am calling this script by using:

$scene = Test_Might.new(Time,Increase,Decrease)

need a little help here...(scratch'n my head, turnin' bald)

~g/A\/\/\|E|F/A\(C|=
 
All right. Your problem is fairly simple. What you have to do is use numbers, or variables set up as numbers, instead of Time, Increase, and Decrease. Right now, it thinks you're trying to use a constant for each of those. (A constant is a variable that starts with a capital letter)
 
@glitch - right on gLiTcH! I understand now thank you.

I'm having a different error now, I believe it's searching for another script...
one that handles gradient bars. there's a reference to a trickster's @_@

~g/A\/\/\|E|F/A\(C|=
 
Ok, Now I've been mentally upgraded in how the "gradient bars" work.
after studying MACL.

Some scripts are able to draw the bar with no graphic files,
I understand now that this first script "Test Your Might"
uses the gradient method which requires a new folder
in your graphics directory along with the graphic files.
(if you need them here they are)
http://www.filefront.com/14515581/Gradients.rar

In this process, I've come to learn a little more about "arguments"
which makes it easier to understand and adjust window size and position
as well as the size of your source rectangle...

still looking in MACL for the right pieces for this script...


~g/A\/\/\|E|F/A\(C|=
 
OK! so here's the latest edit on the first challenge "TEST YOUR MIGHT" working without MACL or SDK!
Code:
#===============================================================================

#                Modified Script "MIGHT BUTTON" By: GameFace101

#                                Version : 1.1

#                               Date :11-9-2009

#===============================================================================

#                Original Script "TEST YOUR MIGHT" By: Chaosg1 

#                               Version : 1.0

#                              Date :13-09-2006

#===============================================================================

#                  New Version:

#                  - no longer requires SDK or MACL 

#                  - music settings

#                  - switch settings

#                  - 

#

#         small thanks to Glitch Finder and Brewmeister for Script Support.

#            http://www.arpgmaker.com/viewtopic.php?p=672553#p672553

#

#                   to call script, create event and use: 

#

#                        $scene = Test_Might.new(10,15,3)

#                         

#                      (10=time 15=power 3=resistance)

#===============================================================================

#

# default MIGHT switch = 101 (victory!)

# default WEAK switch = 102 (defeat!)

# default might music - "Audio/BGM/006-Boss02"

# 

#

#

#===============================================================================

class Test_Might

#-------------------------------------------------------------------------------

# * Main - Handles drawing/disposing windows and the main loop

#-------------------------------------------------------------------------------

 

def initialize(time,increase,decrease)

Audio.bgm_play("Audio/BGM/006-Boss02",100,100)#-------------------=[might music]

$test_passed = false

@might = $game_switches[101]#----------------------------------=[victory switch]

@weak = $game_switches[102]#------------------------------------=[defeat switch]

@window_status = Window_Base.new(230,200 ,196,60)# window's  position / size

@time = time

@increase = (increase*5) * $game_party.actors[0].str/100 + $game_party.actors[0].int/100

@decrease = decrease

@might_value = 0

@window_status.contents = Bitmap.new(@window_status.width - 32, @window_status.height - 32)

@window_status.opacity = 100

end

#--------------------------------------------------------------------------

# * Main

#--------------------------------------------------------------------------

def main

@spriteset_map = Spriteset_Map.new

Graphics.transition

# Main loop

loop do

# Update game screen

Graphics.update

# Update input information

Input.update

# Frame update

update

#refresh

refresh

# Abort loop if screen is changed

if $scene != self

break

end

end

# Prepare for transition

Graphics.freeze

# Dispose of windows

@window_status.dispose

@spriteset_map.dispose

 

end

#-------------------------------------------------------------------------------

# * Refresh

#-------------------------------------------------------------------------------

def refresh  

@might = $game_switches[101]#----------------------------------=[victory switch]

@weak = $game_switches[102]#------------------------------------=[defeat switch]

@total_sec = Graphics.frame_count / Graphics.frame_rate

@window_status.contents.clear

@window_status.contents.draw_text(-34,-2, 180, 42, "PRESS MIGHT!", 2)

@window_status.draw_gradient_bar(0, 0, @might_value, 1000, "might", width = nil, height = nil, hue = 0, back = "Back", back2 = "Back2")

end

#-------------------------------------------------------------------------------

# * Update

#-------------------------------------------------------------------------------

def update

if @time <= 0 and @might_value < 999

@memorized_bgm = @playing_bgm#

$scene = Scene_Map.new

$game_system.se_play($data_system.buzzer_se)#--------------------=[defeat sound]

$test_passed = false #-------------------------------------------------=[defeat]

$game_switches[102] = true #------------------------------------=[defeat switch]

Audio.bgm_play("Audio/BGM/menu01", 100, 100)#---------=[defeat background music]

$game_map.need_refresh = true#----------------------------------------=[refresh]

elsif @might_value > 999 and @time > 0

@memorized_bgm = @playing_bgm#

$scene = Scene_Map.new

$game_system.se_play($data_system.decision_se)#-----------------=[victory sound]

$test_passed = true#--------------------------------------------------=[victory]

$game_switches[101] = true#------------------------------------=[victory switch]

Audio.bgm_play("Audio/BGM/menu01", 100, 100)#--------=[victory background music]

$game_map.need_refresh = true#----------------------------------------=[refresh]

 

return

end

@might_value -= @decrease if @might_value > 0 and @might_value < 999

if Input.trigger?(Input::X)

@might_value += @increase

end

@spriteset_map.update

if Graphics.frame_count / Graphics.frame_rate != @total_sec

refresh

@time -=1

end

end

end

#########################################[MODULE: Load Gradient from RPG::Cache]

module RPG

  module Cache

    def self.gradient(filename, hue = 0)

      self.load_bitmap("Graphics/Gradients/", filename, hue)

    end

  end

end

class Window_Base < Window

  OUTLINE = 1

  BORDER = 1

#####################################################[METHOD: Draw Gradient Bar]

  def draw_gradient_bar(x, y, min, max, file, width = nil, height = nil, hue = 0, back = "Back", back2 = "Back2")

    bar = RPG::Cache.gradient(file, hue)

    back = RPG::Cache.gradient(back)

    back2 = RPG::Cache.gradient(back2)

    cx = BORDER

    cy = BORDER

    dx = OUTLINE

    dy = OUTLINE

    zoom_x = width != nil ? width : back.width

    zoom_y = height != nil ? height : back.height

    percent = min / max.to_f if max != 0

    percent = 0 if max == 0

    back_dest_rect = Rect.new(x,y,zoom_x,zoom_y)

    back2_dest_rect = Rect.new(x+dx,y+dy,zoom_x -dx*2,zoom_y-dy*2)

    bar_dest_rect = Rect.new(x+cx,y+cy,zoom_x * percent-cx*2,zoom_y-cy*2)

    back_source_rect = Rect.new(0,0,back.width,back.height)

    back2_source_rect = Rect.new(0,0,back2.width,back2.height)

    bar_source_rect = Rect.new(0,0,bar.width* percent,bar.height)

    self.contents.stretch_blt(back_dest_rect, back, back_source_rect)

    self.contents.stretch_blt(back2_dest_rect, back2, back2_source_rect)

    self.contents.stretch_blt(bar_dest_rect, bar, bar_source_rect)

  end  

####################################################[working on verticle option] 

  def draw_vertical_gradient_bar(x, y, min, max, file, width = nil, height = nil, hue = 0, back = "Back", back2 = "Back2")

    bar = RPG::Cache.gradient(file, hue)

    back = RPG::Cache.gradient(back)

    back2 = RPG::Cache.gradient(back2)

    cx = BORDER

    cy = BORDER

    dx = OUTLINE

    dy = OUTLINE

    zoom_x = width != nil ? width : back.width

    zoom_y = height != nil ? height : back.height

    percent = min / max.to_f if max != 0

    percent = 0 if max == 0

    bar_y = (zoom_y - zoom_y * percent).ceil

    source_y = bar.height - bar.height * percent

    back_dest_rect = Rect.new(x,y,zoom_x,zoom_y)

    back2_dest_rect = Rect.new(x+dx,y+dy,zoom_x -dx*2,zoom_y-dy*2)

    bar_dest_rect = Rect.new(x+cx,y+bar_y+cy,zoom_x-cx*2,(zoom_y * percent).to_i-cy*2)

    back_source_rect = Rect.new(0,0,back.width,back.height)

    back2_source_rect = Rect.new(0,0,back2.width,back2.height)

    bar_source_rect = Rect.new(0,source_y,bar.width,bar.height * percent)

    self.contents.stretch_blt(back_dest_rect, back, back_source_rect)

    self.contents.stretch_blt(back2_dest_rect, back2, back2_source_rect)

    self.contents.stretch_blt(bar_dest_rect, bar, bar_source_rect)

  end

end

#######################################################[working on timer sprite]

 

#==============================================================================

# ** Might_Timer

#------------------------------------------------------------------------------

#  This sprite is used to display the timer.

#==============================================================================

class Might_Timer < Sprite

 

  #--------------------------------------------------------------------------

  # * Object Initialization

  #--------------------------------------------------------------------------

  def initialize

    super

    self.bitmap = Bitmap.new( 88, 48 )

    self.bitmap.font.name = "Arial"

    self.bitmap.font.size = 32

    self.x = 640 - self.bitmap.width

    self.y = 0

    self.z = 500

    update

  end

 

  #--------------------------------------------------------------------------

  # * Dispose

  #--------------------------------------------------------------------------

  def dispose

    if self.bitmap != nil

      self.bitmap.dispose

    end

    super

  end

 

  #--------------------------------------------------------------------------

  # * Frame Update

  #--------------------------------------------------------------------------

  def update

   

    super

    # If timer needs to be redrawn

    if $scene.update_count / Graphics.frame_rate != @total_sec

      # Clear window contents

      self.bitmap.clear

      # Calculate total number of seconds

      @total_sec = $scene.update_count / Graphics.frame_rate

      # Make a string for displaying the timer

      min = @total_sec / 60

      sec = @total_sec % 60

      text = sprintf( "%02d:%02d", min, sec )

      # Draw timer

      self.bitmap.font.color.set( 255, 255, 255 )

      self.bitmap.draw_text( self.bitmap.rect, text, 1 )

    end

  end

end

 
with a courteous screen shot!

i1lgut.jpg


got it working with switches now!!!
I'm currently working on showing a timer and restore bgm...

*2 down two to go...

~g/A\/\/\|E|F/A\(C|=
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top