Chaos Project

RPG Maker => RPG Maker Scripts => RMXP Script Database => Topic started by: Zeriab on January 08, 2008, 06:43:33 am

Title: [XP] SLOLS
Post by: Zeriab on January 08, 2008, 06:43:33 am
Snake Look-alike on Load Script
Authors: Zeriab
Version: 1.0
Type: Snake game
Key Term: Minigame



Introduction

The SLOLS has been made by Zeriab.
Thanks goes to RMXP for making this possible
Credits should be given.


Features

The purpose of SLOLS is to provide the player an opportunity to interact with something during loading sequences. I think the loading time will not seem as long as normally if the player as something to do while the program is loading.
They don't experience the time it takes to load as bad even though the script reduced the loading speed.
In the game itself the principle is to collect dots by moving a bigger dot into them. There is no time limit. There is no way to die or get stuck or etc.  Steering is done by the arrow keys.
When the loading is finished a sound will be played and visual aids will be used to let the player know that the loading is finished.
The player can then continue by pressing a trigger key (fx. ENTER)
There is no need to press enter. The player can play the game as long as he or she wants unless  the script loaded does something that changes this.


Screenshots

(http://img206.imageshack.us/img206/5505/screenbq7.th.png) (http://img206.imageshack.us/img206/5505/screenbq7.png)


Demo

The demo has been combined with my Letter Ninigame to show a example of use.
If the Letter Minigame is used credits mentionen in the Letter Minigame should be given.

http://zeriab.plesk3.freepgs.com/root/scripts/SLOLS.rar


Script

I have collected them all in 1 file which can be downloaded here: http://zeriab.plesk3.freepgs.com/root/scripts/SLOLS.txt (mirror (http://zeriab.plesk3.freepgs.com/root/scripts/SLOLS.txt))


Instructions

You must have these pictures in your graphics\pictures folder or the arrow keys shown on the picture will be missing:
(http://www28.websamba.com/Vobbys/SLOLS/Down_Arrow.png) (http://www28.websamba.com/Vobbys/SLOLS/Left_Arrow.png) (http://www28.websamba.com/Vobbys/SLOLS/Up_Arrow.png) (http://www28.websamba.com/Vobbys/SLOLS/Right_Arrow.png)

The Script:
This script used the global variable $loader.
It can run without $loader being initialized in which case the script considers the loading as done.
To use $loader you must set it to a Thread. The syntax is:
Thread.new( [arg]* ) {| args | block } ->  aThread  (Reference (http://www.rubycentral.com/ref/ref_c_thread.html))

An example:
$loader = Thread.new { MyClass.new }

To get the SLOLS scene use this syntax:
$scene = Scene_SLOLS.new(scene=Scene_Map.new)
scene will be used to set the scene that comes after Scene_SLOLS. The scene to be used after finished loading and player pressing trigger.

An example; syntax for standard scene: (Scene_Map)
$scene = Scene_SLOLS.new
# or
$scene = Scene_SLOLS.new(Scene_Map.new)


The script will store the amount of dots in the variable number specified by Cheese_Variable in Scene_SLOLS. (Near top)
There also are the Margin (in pixels) and the Border_Thickness (in pixels).
Changing these may break the design. The info bar with the instructions is a bit fragile.


Compatibility

Should be independent which increases compatibility.


Credits and Thanks

I would like to thank everyone using their time to try and use SLOLS.
I would like to thank everyone reading this topic.
Thanks.


Author's Notes

I don't recommend letting the script being 'loaded' change the $scene as makes the SLOLS stop rather suddenly from my point of view (Players position).

And finally: ENJOY!

- Zeriab
Title: Re: SLOLS
Post by: Fantasist on January 11, 2008, 02:50:34 pm
The script which intrigued me :)
I still love it, maybe I'll make it a bit more colorful.
Title: Re: [XP] SLOLS
Post by: nathmatt on April 02, 2008, 12:26:51 am
all ur links are out
Title: Re: [XP] SLOLS
Post by: Zeriab on April 06, 2008, 04:40:10 pm
Thanks for notifying me, it has been fixed ^^
For some reasons the links to the picture of the arrows works while the link to the text file on the same server does not work -_-
Anyway, it should work now
Title: Re: [XP] SLOLS
Post by: Blizzard on April 07, 2008, 06:34:31 am
How about you apply the template on the topic? ^_^
Title: Re: [XP] SLOLS
Post by: Zeriab on April 07, 2008, 07:18:29 am
Quote from: Blizzard on April 07, 2008, 06:34:31 am
How about you apply the template on the topic? ^_^

Good idea, problem is that I am too lazy >_>
Title: Re: [XP] SLOLS
Post by: Blizzard on April 07, 2008, 08:02:16 am
OH NOEZ, ME, TOO! D:
Title: Re: [XP] SLOLS
Post by: Reno-s--Joker on January 29, 2009, 04:48:17 am
:D This looks awesome! I will definitely credit you in my game if I use it. ^-^
<3
Title: Re: [XP] SLOLS
Post by: Zeriab on January 29, 2009, 06:42:26 am
I am glad you like it ^_^
Do ask if you have any problems with using it.

*hugs*
- Zeriab
Title: Re: [XP] SLOLS
Post by: Reno-s--Joker on January 31, 2009, 07:46:25 pm
Noooo I can't dl it for some reason. The first time it seemed o work but I guess my internet just failed at the very end. :(
I get a 404 Error with the link. D:

Squee~ I really want to use this... :D
Title: Re: [XP] SLOLS
Post by: Starrodkirby86 on January 31, 2009, 07:50:35 pm
http://www.rmxp.org/forums/viewtopic.php?t=10474
http://rmrk.net/index.php?topic=7403.0
http://rmrk.net/index.php?action=dlattach;topic=7403.0;attach=293

It seems Zeriab's webspace is down for the moment. Depressing really...
I hope this will help you. I can't find a working link for the demo, so hopefully Zeriab will come and save the day with that. :)
Title: Re: [XP] SLOLS
Post by: Juan on January 31, 2009, 07:53:56 pm
I uploaded a temp demo of this.
http://www.sendspace.com/file/8yb9ha
Title: Re: [XP] SLOLS
Post by: Calintz on January 31, 2009, 08:08:34 pm
Good job Juan...
Title: Re: [XP] SLOLS
Post by: Reno-s--Joker on January 31, 2009, 09:22:51 pm
^-^ Aww, thanks to the both of you! :haha:

EDIT: I checked Juan's temp demo out, and it's awesome! Thanks Zeriab!  :D
Is it possible to make the 'snake' grow longer? (or would that lead to gameover...  :O.o:)

:haha:
Title: Re: [XP] SLOLS
Post by: mcgluszak on February 09, 2011, 03:58:21 pm
Quote from: nathmatt on April 02, 2008, 12:26:51 am
all ur links are out


AGAIN!
Title: Re: [XP] SLOLS
Post by: LiTTleDRAgo on May 14, 2017, 08:42:32 am
Edited this script so it will load windowskin arrows if no arrow images in Graphics/Pictures.

(http://i.imgur.com/lilERLXs.png) (http://i.imgur.com/lilERLX.png)
http://i.imgur.com/lilERLX.png

XP Version :

Spoiler: ShowHide
#==============================================================================
# ** Snake Look-alike on Loading Script
#------------------------------------------------------------------------------
# Zeriab
# v 1.0
# 28-09-2006
#==============================================================================

class Scene_SLOLS
  # The variable the number of dots collected will be stored
  Cheese_Variable = 25
  # The size of the margin in pixels
  Margin = 10
  # The thickness of the border in pixels
  Border_Thickness = 3
 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(scene=Scene_Map.new)
    @next_scene = scene
  end
 
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Creates Bar Window (Loading bar)
    @bar_window = Window_SLOLS_Bar.new
    # Creates Info Window
    info = [Margin, Border_Thickness, Cheese_Variable]
    @info_window = Window_SLOLS_Info.new(*info)
    # Creates Game Window
    @game_window = Window_SLOLS_Game.new(*info)
    # Execute transition
    Graphics.transition
    # Scene Objects
    @scene_objects = [@bar_window, @info_window, @game_window]
    # Main loop
    while $scene == self
      # Sleeps a short while to let the other thread work.
      sleep(0.01)
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      ## Frame update
      update
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose Scene Objects
    @scene_objects.each { |x| x.dispose }
  end 
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
      # Updates Scene Objects
      @scene_objects.each { |x| x.update }
      # If B or C Button Is Pressed
      if Input.trigger?(Input::B) || Input.trigger?(Input::C)
        # If the loading thread is finished (not alive)
        if !$loader.is_a?(Thread) || !$loader.alive?
          # Play Decision SE
          $game_system.se_play($data_system.decision_se)
          # Switch to map screen
          $scene = @next_scene
          return
        else
          # Play Buzzer SE
          $game_system.se_play($data_system.buzzer_se)
          return
        end
      end
  end
end

#==============================================================================
# ** Window_SLOLS_Info
#==============================================================================

class Window_SLOLS_Info
  # Instructions
  Instructs = [
                'Navigate using the','arrow keys.',
                'Collect green dots.',
                'This is done by','going into them.',
                'A sound will play','when the loading','is finished',
                '','Enter to continue'
             ]
 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(margin, border_thickness, cheese_variable)
    # The name of the arrow images
    @arrow_file_names = ["Down_Arrow.png", "Left_Arrow.png",
                         "Right_Arrow.png", "Up_Arrow.png"]
    # The windowskin images
    @windowskin = RPG::Cache.windowskin($game_system.windowskin_name)
    # The arrow images
    @arrow_images = []
    for i in 0..3
      # Makes sure that the program keeps running if one or more of the files
      # given don't exists. (read: wrong filename or missing file)
      begin
        # Reads the bitmap
        bitmap = Bitmap.new('Graphics\\Pictures\\'+@arrow_file_names[i])
      rescue
        # Creates a blank 32x32 bitmap and Blt windowskin arrows if the
        # reading fails
        bitmap = Bitmap.new(32,32)
        # Arrow down
        bitmap.blt(0,0,@windowskin,Rect.new(128,128,32,-32))if [0,1].include?(i)
        # Arrow up
        bitmap.blt(0,0,@windowskin,Rect.new(128,96,32,32))  if [3,2].include?(i)
        # Arrow left or Arrow right
        if [1,2].include?(i)
          # Clone the Arrow
          copy = bitmap.clone       
          # Rotate 90 degrees clockwise
          32.times do |j|
            32.times {|k| bitmap.set_pixel(32-j-1,k, copy.get_pixel(k, j))}
          end
          # Dispose clone
          copy.dispose
        end
      rescue Exception => ex
        # Creates a blank 32x32 bitmap if the reading fails
        bitmap = Bitmap.new(32,32)
        # Prints the exception if in Debug mode.
        if $DEBUG
          p ex
        end
      end
      # Pushes the resulting bitmap into the array
      @arrow_images.push(bitmap)
    end
    # Dispose windowskin
    @windowskin.dispose
    # The margin and border thickness
    @margin = margin
    @border_thickness = border_thickness
    @cheese_variable = cheese_variable
   
    # Height with border excluding margin
    @height = 416-@margin
   
    # The instructions Sprite
    @instru = Sprite.new(Viewport.new(480 + @border_thickness,
                        48 + @border_thickness,
                        159 - @margin - @border_thickness*2,
                        282 - @margin*4 + 4))
    @instru.bitmap = Bitmap.new(159 - @margin - @border_thickness*2,
                               282 - @margin*4 + 4)
    @instru.bitmap.font.color = Color.new(225, 225, 225, 255)
    @instru.bitmap.font.size = 20
   
   
    # The main Sprite
    @contents = Sprite.new(Viewport.new(480, 0, 160, @height))
    @contents.bitmap = Bitmap.new(160, @height)
    @contents.bitmap.font.color = Color.new(225, 225, 225, 255)
    @contents.bitmap.font.size = 22
    refresh
  end
 
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Simplifying the variables used
    border = @border_thickness
    spacing = @margin + border
   
    # Removes any old contents, garbage and so on.
    @contents.bitmap.clear
    # Draws the white block used for the border of the score
    @contents.bitmap.fill_rect(0,@margin,159-@margin,22+border*2,
                                Color.new(225, 225, 225, 255))
    # Draws the white block used for the border of the instructions
    @contents.bitmap.fill_rect(0,48,159-@margin,282+border*2-@margin*4+4,
                                Color.new(225, 225, 225, 255))
    # Draws a black block on the white block creating the border.
    @contents.bitmap.fill_rect(border, 48+border,159-spacing-border,
                               282-@margin*4+4, Color.new(0, 0, 0, 0))
   
    # Draws the left arrow
    @contents.bitmap.blt(0,373-@margin,@arrow_images[1],Rect.new(0,0,43,43))
    # Draws the down arrow
    @contents.bitmap.blt(43+@margin,373-@margin,@arrow_images[0],
                         Rect.new(0,0,43,43))
    # Draws the right arrow
    @contents.bitmap.blt(43*2+@margin*2,373-@margin,@arrow_images[2],
                         Rect.new(0,0,43,43))
    # Draws the up arrow
    @contents.bitmap.blt(43+@margin,330-@margin*2,@arrow_images[3],
                         Rect.new(0,0,43,43))
   
    # Draws the text 'Instructions:'
    @contents.bitmap.draw_text(border, 48, 150-border*2, 22, 'Instructions',1)
   
    # Draws the intructions
    for i in 0...Instructs.size
      # Gets the string
      str = Instructs[i]
      # Draws the string
      @instru.bitmap.draw_text(2, 22*(i+1), 150-border*2, 20, str,1)
    end
  end

  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    # Simplifying the variables used
    border = @border_thickness
    spacing = @margin + border
    # Updates the sprite
    @contents.update
    # Removes old contents
    @contents.bitmap.fill_rect(border, spacing, 159-spacing-border, 22,
                               Color.new(0, 0, 0, 0))
    # Draws the amount of dots collected
    @contents.bitmap.draw_text(border, spacing, 153-spacing, 22,
                               $game_variables[@cheese_variable].to_s, 2)
    # Draws the text 'Dots:'
    @contents.bitmap.draw_text(border+2, spacing, 157-spacing, 22, 'Dots:')
  end
 
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    @contents.bitmap.dispose
    @contents.dispose
  end
end

#==============================================================================
# ** Window_SLOLS_Game
#==============================================================================

class Window_SLOLS_Game
  #Player Settings
  Size = 5
  Default_Speed = 3
  Trail_Length = 19
 
  #Cheese Settings
  Cheese_Size = 3
  Cheese_Colors = [Color.new(10,200,20,255)]
  Max_Cheese_Amount = 200
 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(margin, border_thickness, cheese_variable)
    # The margin and border thickness
    @margin = margin
    @border_thickness = border_thickness
    @cheese_variable = cheese_variable
   
    # Width of the playing field
    @width = 480-(@margin*2) - (@border_thickness*2)
    # Height of the playing field
    @height = 416-(@margin*2) - (@border_thickness*2)
   
    # Player info
    @player_x = 200
    @player_y = 208
    @player_trail = []
    @player_dir = 6   #2 - up, 4 - left, 6 - right, 8 - down
    @speed = Default_Speed
   
    # The cheese array
    @cheese = []
    @cheese.push(make_cheese)
    # The amount of cheese caught during this season.
    @cheese_amount = 0
   
    # Create the Sprite for viewing the border
    view = @margin, @margin, 480-@margin, 416-@margin
    @border = Sprite.new(Viewport.new(*view))
    @border.bitmap = Bitmap.new(480-(@margin*2),416-(@margin*2))
   
    # Creates the main Sprite
    @contents = Sprite.new(Viewport.new(@margin + @border_thickness,
                                @margin + @border_thickness, @width, @height))
    @contents.bitmap = Bitmap.new(@width,@height)
    # Refreshes
    refresh
    # Updates
    update
  end
 
  #--------------------------------------------------------------------------
  # * Make Cheese
  # ---------------------
  # Generates a pointer to a place where a cheese will be at least 3 pixels
  # away from the player
  #--------------------------------------------------------------------------
  def make_cheese
    result = []
    # Total size. (Sum of player size and cheese size)
    size = Size + Cheese_Size
   
    loop do
      # Generating the x and y coordinates
      x = rand(@width - (size + 5)*2)
      y = rand(@height - (size + 5)*2)
     
      # Adjusts the x and y coordinates so the cheese will not be
      # placed in the player
      x += 2*(Size + 5) if x > @width / 2 - (size + 5)
      y += 2*(Size + 5) if y > @height / 2 - (size + 5)
     
      # Makes sure that no cheese exists in that exact same place
      # Does not consider the size of the cheese.
      if !@cheese.include?([x,y])
        result = [x,y]
        break
      end
    end
   
    return result
  end
 
  #--------------------------------------------------------------------------
  # * Check Player
  # --------------------
  # Checks if the player have caught a cheese. (Is touching one)
  # Returns the indices of the cheese in an array
  #--------------------------------------------------------------------------
  def check_player
    result = []
    # Checks every cheese
    for i in 0...@cheese.size
      # Distance in the x-plane
      d = (@cheese[i][0] - @player_x).abs
      # Distance in the y-plane
      d_y = (@cheese[i][1] - @player_y).abs
      # Makes 'd' contain the largest distance
      d = d_y if d < d_y
     
      # If the largest distance is less than the size of the player and the
      # cheese the player must be touching the cheese.
      result.push(i) if d < (Size + Cheese_Size - 1)
    end
    return result
  end
 
  #--------------------------------------------------------------------------
  # * Draw Cheese
  #     i     : The index on the cheese
  #     color : The color wanted for the cheese
  # --------------------
  # Draws the designated cheese with the given color
  #--------------------------------------------------------------------------
  def draw_cheese(i, color)
    cheese = @cheese[i]
    size = Cheese_Size
    # Draws the cheese
    @contents.bitmap.fill_rect(cheese[0]-(size-1),cheese[1]-(size-1),
                            (size*2)-1, (size*2)-1, color)
  end
 
  #--------------------------------------------------------------------------
  # * Delete Cheese
  #     i : The index on the cheese
  # --------------------
  # Deletes the cheese by first drawing it black and then removing the cheese
  # from @cheese.
  #--------------------------------------------------------------------------
  def delete_cheese(i)
    draw_cheese(i, Color.new(0,0,0,0))
    @cheese.delete_at(i)
  end
 
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    @border.bitmap.clear
    # Draws a white block
    @border.bitmap.fill_rect(0,0,480-@margin, 416-@margin,
                  Color.new(225, 225, 225, 255))
    # Draws a smaller black block to give the border
    @border.bitmap.fill_rect(@border_thickness, @border_thickness,
                  @width, @height, Color.new(0, 0, 0, 0))
  end

  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    @contents.update

    # Checks if the player gets any cheese
    array = check_player
    if array.size > 0
      # Removes all the cheese
      for i in array
        # Cheese counters
        $game_variables[@cheese_variable] += 1
        @cheese_amount += 1
        # Deletes the old cheese
        delete_cheese(i)
        # Creates a new one
        @cheese.push(make_cheese)
       
        # Might create another one
        if @cheese.size < Max_Cheese_Amount
          # Creates an extra cheese if enough cheese have been caught
          if @cheese_amount > @cheese.size * @cheese.size + 1
            # Creates a new one
            @cheese.push(make_cheese)
          end
        end
      end
    end
   
    # Draws the cheese
    for i in 0...@cheese.size
      draw_cheese(i, Color.new(10,200,20,255))
    end
   
    # Makes sure the trail isn't too short
    while @player_trail.size < Trail_Length
      # Adds the player positions into the trail
      @player_trail.push([@player_x,@player_y])
    end
   
    coords = @player_trail.shift
    # Draws the trail
    @contents.bitmap.fill_rect(coords[0]-(Size-1),coords[1]-(Size-1),
                          (Size*2)-1, (Size*2)-1, Color.new(0,0,0,255))
    #Calculates the steps per shade
    step = 200 / (Trail_Length)
    for i in 0...Trail_Length-1
      # Calculations
      coords = @player_trail[i]
      s = step*(Trail_Length-i)
      # Draws the trail
      @contents.bitmap.fill_rect(coords[0]-(Size-1),coords[1]-(Size-1),
                          (Size*2)-1, (Size*2)-1,
                          Color.new(200-s,200-s,100-(s/2),255))
    end
                         
    # Draws the player
    @contents.bitmap.fill_rect(@player_x-(Size-1),@player_y-(Size-1),
                            (Size*2)-1, (Size*2)-1, Color.new(200,200,100,255))
   
    # If UP Is Pressed
    if Input.trigger?(Input::UP)
      @player_dir = 8 unless @player_dir == 2
    end
    # If DOWN Is Pressed
    if Input.trigger?(Input::DOWN)
      @player_dir = 2 unless @player_dir == 8
    end
    # If LEFT Is Pressed
    if Input.trigger?(Input::LEFT)
      @player_dir = 4 unless @player_dir == 6
    end
    # If RIGHT Is Pressed
    if Input.trigger?(Input::RIGHT)
      @player_dir = 6 unless @player_dir == 4
    end
   
    # Moves the player accordingly to the directions
    case @player_dir
    when 8 then @player_y -= @speed # Down
    when 2 then @player_y += @speed # Up
    when 4 then @player_x -= @speed # Left
    when 6 then @player_x += @speed # Right
    end
    # Warping the player
    @player_x = (@player_x) % @width
    @player_y = (@player_y) % @height
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    @contents.bitmap.dispose
    @contents.dispose
  end
end

#==============================================================================
# ** Window_SLOLS_Bar
#==============================================================================

class Window_SLOLS_Bar
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @contents = Sprite.new(Viewport.new(0, 416, 640, 64))
    @contents.bitmap = Bitmap.new(640, 64)
    @left_block = Sprite.new(Viewport.new(540-48, 424, 48, 48))
    @left_block.bitmap = Bitmap.new(64, 64)
    @right_block = Sprite.new(Viewport.new(100, 424, 48, 48))
    @right_block.bitmap = Bitmap.new(640, 64)
    @blocks = [@left_block, @right_block]
    @bar = Sprite.new(Viewport.new(270, 446, 100, 4))
    @bar.bitmap = Bitmap.new(200, 4)
    @bar_f = Sprite.new(Viewport.new(270, 446, 100, 4))
    @bar_f.bitmap = Bitmap.new(100, 4)
    @bar_fx = 0
    # The sprites used
    @sprites = [@contents,@bar,@bar_f]
    refresh
  end
 
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    @contents.bitmap.clear
    bar_color = Color.new(225,225,225,255)
    fin_color = Color.new(255,255,0,0)
    @bar.bitmap.fill_rect(0,0,25,4,bar_color)
    @bar.bitmap.fill_rect(50,0,25,4,bar_color)
    @bar.bitmap.fill_rect(100,0,25,4,bar_color)
    @bar.bitmap.fill_rect(150,0,25,4,bar_color)
    @bar_f.bitmap.fill_rect(0,0,100,4,fin_color)
    @blocks.each {|x| x.bitmap.fill_rect(0,0,64,64,fin_color)}
  end

  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    @bar.ox -= 1
    @bar.ox = @bar.ox % 100
    @bar.update
    if @bar_fx == 0 && (!$loader.is_a?(Thread) || !$loader.alive?)
      @bar_fx = 1
      @count = 3
      $game_system.se_play($data_system.load_se)
    end
    if @bar_fx > 0 && @bar_fx < 255
      @bar_fx += @count
      @bar_f.bitmap.fill_rect(0,0,100,4,Color.new(255,255,0,@bar_fx))
      @blocks.each do |x|
        x.bitmap.fill_rect(0,0,48,48,Color.new(255,255,0,@bar_fx))
      end
      case @bar_fx
      when 10..20   then @count = 50
      when 180..230 then @count = 5
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    @sprites.each { |x| x.bitmap.dispose}
    @sprites.each { |x| x.dispose}
  end
end


VX Ace Version :

Spoiler: ShowHide
#==============================================================================
# ** Snake Look-alike on Loading Script (VXAce Ver)
# -  Original  by Zeriab (v 1.0) - 28-09-2006
# -  VXAce ver by LiTTleDRAgo (v 1.0ace) - 15-05-2017
#------------------------------------------------------------------------------
#
# EXAMPLE :
#    SceneManager.SLOLS
#    - or -
#    SceneManager.SLOLS(Scene_Map.new)
#
#==============================================================================

class Scene_SLOLS
  # The variable the number of dots collected will be stored
  Cheese_Variable = 25
  # The size of the margin in pixels
  Margin = 10
  # The thickness of the border in pixels
  Border_Thickness = 3
 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(scene=Scene_Map.new)
    # Sorry, this minigame only for resolution 640 x 480
    @resolution = [Graphics.width,Graphics.height]
    Graphics.resize_screen(640,480) if @resolution != [640,480]
    @next_scene = scene
  end
 
  #--------------------------------------------------------------------------
  # * Main Processing
  #--------------------------------------------------------------------------
  def main
    # Creates Bar Window (Loading bar)
    @bar_window = Window_SLOLS_Bar.new
    # Creates Info Window
    info = [Margin, Border_Thickness, Cheese_Variable]
    @info_window = Window_SLOLS_Info.new(*info)
    # Creates Game Window
    @game_window = Window_SLOLS_Game.new(*info)
    # Execute transition
    Graphics.transition
    # Scene Objects
    @scene_objects = [@bar_window, @info_window, @game_window]
    # Main loop
    while SceneManager.scene == self
      # Sleeps a short while to let the other thread work.
      sleep(0.01)
      # Update game screen
      Graphics.update
      # Update input information
      Input.update
      ## Frame update
      update
    end
    # Prepare for transition
    Graphics.freeze
    # Dispose Scene Objects
    @scene_objects.each { |x| x.dispose }
  end 
  #--------------------------------------------------------------------------
  # * Frame Update
  #--------------------------------------------------------------------------
  def update
      # Updates Scene Objects
      @scene_objects.each { |x| x.update }
      # If B or C Button Is Pressed
      if Input.trigger?(Input::B) || Input.trigger?(Input::C)
        # If the loading thread is finished (not alive)
        if !$loader.is_a?(Thread) || !$loader.alive?
          # Play Decision SE
          Sound.play_ok
          # Switch to map screen
          SceneManager.send(:instance_variable_set,:@scene,@next_scene)
          # Camouflage the screen
          @sprite_black = Sprite.new
          @sprite_black.bitmap = (s = Graphics.snap_to_bitmap)
          @sprite_black.bitmap.fill_rect(s.rect,Color.new(0,0,0))
          @scene_objects << @sprite_black.bitmap << @sprite_black
          # Revert resolution
          Graphics.resize_screen(*@resolution) if @resolution != [640,480]
          return
        else
          # Play Buzzer SE
          Sound.play_buzzer
          return
        end
      end
  end
end
#==============================================================================
# ** SceneManager
#------------------------------------------------------------------------------
#  This module manages scene transitions. For example, it can handle
# hierarchical structures such as calling the item screen from the main menu
# or returning from the item screen to the main menu.
#==============================================================================

module SceneManager
  #--------------------------------------------------------------------------
  # * Direct Transition
  #--------------------------------------------------------------------------
  def self.SLOLS(scene_class = nil)
    @stack.push(@scene) if scene_class
    temp = @scene
    @scene = Scene_SLOLS.new(scene_class ? scene_class : temp)
  end
end

#==============================================================================
# ** Window_SLOLS_Info
#==============================================================================

class Window_SLOLS_Info
  # Instructions
  Instructs = [
                'Navigate using the','arrow keys.',
                'Collect green dots.',
                'This is done by','going into them.',
                'A sound will play','when the loading','is finished',
                '','Enter to continue'
             ]
 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(margin, border_thickness, cheese_variable)
    # The name of the arrow images
    @arrow_file_names = ["Down_Arrow.png", "Left_Arrow.png",
                         "Right_Arrow.png", "Up_Arrow.png"]
    # The windowskin images
    @windowskin = Cache.tileset("Inside_B")
    # The arrow images
    @arrow_images = []
    for i in 0..3
      # Makes sure that the program keeps running if one or more of the files
      # given don't exists. (read: wrong filename or missing file)
      begin
        # Reads the bitmap
        bitmap = Bitmap.new('Graphics\\Pictures\\'+@arrow_file_names[i])
      rescue
        # Creates a blank 32x32 bitmap and Blt windowskin arrows if the
        # reading fails
        bitmap = Bitmap.new(32,32)
        # Arrow down
        bitmap.blt(0,0,@windowskin,Rect.new(128,96,32,-32))if [0,1].include?(i)
        # Arrow up
        bitmap.blt(0,0,@windowskin,Rect.new(128,64,32,32))  if [3,2].include?(i)
        # Arrow left or Arrow right
        if [1,2].include?(i)
          # Clone the Arrow
          copy = bitmap.clone       
          # Rotate 90 degrees clockwise
          32.times do |j|
            32.times {|k| bitmap.set_pixel(32-j-1,k, copy.get_pixel(k, j))}
          end
          # Dispose clone
          copy.dispose
        end
      rescue Exception => ex
        # Creates a blank 32x32 bitmap if the reading fails
        bitmap = Bitmap.new(32,32)
        # Prints the exception if in Debug mode.
        if $DEBUG
          p ex
        end
      end
      # Pushes the resulting bitmap into the array
      @arrow_images.push(bitmap)
    end
    # Dispose windowskin
    @windowskin.dispose
    # The margin and border thickness
    @margin = margin
    @border_thickness = border_thickness
    @cheese_variable = cheese_variable
   
    # Height with border excluding margin
    @height = 416-@margin
   
    # The instructions Sprite
    @instru = Sprite.new(Viewport.new(480 + @border_thickness,
                        48 + @border_thickness,
                        159 - @margin - @border_thickness*2,
                        282 - @margin*4 + 4))
    @instru.bitmap = Bitmap.new(159 - @margin - @border_thickness*2,
                               282 - @margin*4 + 4)
    @instru.bitmap.font.color = Color.new(225, 225, 225, 255)
    @instru.bitmap.font.size = 20
   
   
    # The main Sprite
    @contents = Sprite.new(Viewport.new(480, 0, 160, @height))
    @contents.bitmap = Bitmap.new(160, @height)
    @contents.bitmap.font.color = Color.new(225, 225, 225, 255)
    @contents.bitmap.font.size = 22
    refresh
  end
 
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    # Simplifying the variables used
    border = @border_thickness
    spacing = @margin + border
   
    # Removes any old contents, garbage and so on.
    @contents.bitmap.clear
    # Draws the white block used for the border of the score
    @contents.bitmap.fill_rect(0,@margin,159-@margin,22+border*2,
                                Color.new(225, 225, 225, 255))
    # Draws the white block used for the border of the instructions
    @contents.bitmap.fill_rect(0,48,159-@margin,282+border*2-@margin*4+4,
                                Color.new(225, 225, 225, 255))
    # Draws a black block on the white block creating the border.
    @contents.bitmap.fill_rect(border, 48+border,159-spacing-border,
                               282-@margin*4+4, Color.new(0, 0, 0, 0))
   
    # Draws the left arrow
    @contents.bitmap.blt(0,373-@margin,@arrow_images[1],Rect.new(0,0,43,43))
    # Draws the down arrow
    @contents.bitmap.blt(43+@margin,373-@margin,@arrow_images[0],
                         Rect.new(0,0,43,43))
    # Draws the right arrow
    @contents.bitmap.blt(43*2+@margin*2,373-@margin,@arrow_images[2],
                         Rect.new(0,0,43,43))
    # Draws the up arrow
    @contents.bitmap.blt(43+@margin,330-@margin*2,@arrow_images[3],
                         Rect.new(0,0,43,43))
   
    # Draws the text 'Instructions:'
    @contents.bitmap.draw_text(border, 48, 150-border*2, 22, 'Instructions',1)
   
    # Draws the intructions
    for i in 0...Instructs.size
      # Gets the string
      str = Instructs[i]
      # Draws the string
      @instru.bitmap.draw_text(2, 22*(i+1), 150-border*2, 20, str,1)
    end
  end

  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    # Simplifying the variables used
    border = @border_thickness
    spacing = @margin + border
    # Updates the sprite
    @contents.update
    # Removes old contents
    @contents.bitmap.fill_rect(border, spacing, 159-spacing-border, 22,
                               Color.new(0, 0, 0, 0))
    # Draws the amount of dots collected
    @contents.bitmap.draw_text(border, spacing, 153-spacing, 22,
                               $game_variables[@cheese_variable].to_s, 2)
    # Draws the text 'Dots:'
    @contents.bitmap.draw_text(border+2, spacing, 157-spacing, 22, 'Dots:')
  end
 
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    @contents.bitmap.dispose
    @contents.dispose
  end
end

#==============================================================================
# ** Window_SLOLS_Game
#==============================================================================

class Window_SLOLS_Game
  #Player Settings
  Size = 5
  Default_Speed = 3
  Trail_Length = 19
 
  #Cheese Settings
  Cheese_Size = 3
  Cheese_Colors = [Color.new(10,200,20,255)]
  Max_Cheese_Amount = 200
 
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize(margin, border_thickness, cheese_variable)
    # The margin and border thickness
    @margin = margin
    @border_thickness = border_thickness
    @cheese_variable = cheese_variable
   
    # Width of the playing field
    @width = 480-(@margin*2) - (@border_thickness*2)
    # Height of the playing field
    @height = 416-(@margin*2) - (@border_thickness*2)
   
    # Player info
    @player_x = 200
    @player_y = 208
    @player_trail = []
    @player_dir = 6   #2 - up, 4 - left, 6 - right, 8 - down
    @speed = Default_Speed
   
    # The cheese array
    @cheese = []
    @cheese.push(make_cheese)
    # The amount of cheese caught during this season.
    @cheese_amount = 0
   
    # Create the Sprite for viewing the border
    view = @margin, @margin, 480-@margin, 416-@margin
    @border = Sprite.new(Viewport.new(*view))
    @border.bitmap = Bitmap.new(480-(@margin*2),416-(@margin*2))
   
    # Creates the main Sprite
    @contents = Sprite.new(Viewport.new(@margin + @border_thickness,
                                @margin + @border_thickness, @width, @height))
    @contents.bitmap = Bitmap.new(@width,@height)
    # Refreshes
    refresh
    # Updates
    update
  end
 
  #--------------------------------------------------------------------------
  # * Make Cheese
  # ---------------------
  # Generates a pointer to a place where a cheese will be at least 3 pixels
  # away from the player
  #--------------------------------------------------------------------------
  def make_cheese
    result = []
    # Total size. (Sum of player size and cheese size)
    size = Size + Cheese_Size
   
    loop do
      # Generating the x and y coordinates
      x = rand(@width - (size + 5)*2)
      y = rand(@height - (size + 5)*2)
     
      # Adjusts the x and y coordinates so the cheese will not be
      # placed in the player
      x += 2*(Size + 5) if x > @width / 2 - (size + 5)
      y += 2*(Size + 5) if y > @height / 2 - (size + 5)
     
      # Makes sure that no cheese exists in that exact same place
      # Does not consider the size of the cheese.
      if !@cheese.include?([x,y])
        result = [x,y]
        break
      end
    end
   
    return result
  end
 
  #--------------------------------------------------------------------------
  # * Check Player
  # --------------------
  # Checks if the player have caught a cheese. (Is touching one)
  # Returns the indices of the cheese in an array
  #--------------------------------------------------------------------------
  def check_player
    result = []
    # Checks every cheese
    for i in 0...@cheese.size
      # Distance in the x-plane
      d = (@cheese[i][0] - @player_x).abs
      # Distance in the y-plane
      d_y = (@cheese[i][1] - @player_y).abs
      # Makes 'd' contain the largest distance
      d = d_y if d < d_y
     
      # If the largest distance is less than the size of the player and the
      # cheese the player must be touching the cheese.
      result.push(i) if d < (Size + Cheese_Size - 1)
    end
    return result
  end
 
  #--------------------------------------------------------------------------
  # * Draw Cheese
  #     i     : The index on the cheese
  #     color : The color wanted for the cheese
  # --------------------
  # Draws the designated cheese with the given color
  #--------------------------------------------------------------------------
  def draw_cheese(i, color)
    cheese = @cheese[i]
    size = Cheese_Size
    # Draws the cheese
    @contents.bitmap.fill_rect(cheese[0]-(size-1),cheese[1]-(size-1),
                            (size*2)-1, (size*2)-1, color)
  end
 
  #--------------------------------------------------------------------------
  # * Delete Cheese
  #     i : The index on the cheese
  # --------------------
  # Deletes the cheese by first drawing it black and then removing the cheese
  # from @cheese.
  #--------------------------------------------------------------------------
  def delete_cheese(i)
    draw_cheese(i, Color.new(0,0,0,0))
    @cheese.delete_at(i)
  end
 
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    @border.bitmap.clear
    # Draws a white block
    @border.bitmap.fill_rect(0,0,480-@margin, 416-@margin,
                  Color.new(225, 225, 225, 255))
    # Draws a smaller black block to give the border
    @border.bitmap.fill_rect(@border_thickness, @border_thickness,
                  @width, @height, Color.new(0, 0, 0, 0))
  end

  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    @contents.update

    # Checks if the player gets any cheese
    array = check_player
    if array.size > 0
      # Removes all the cheese
      for i in array
        # Cheese counters
        $game_variables[@cheese_variable] += 1
        @cheese_amount += 1
        # Deletes the old cheese
        delete_cheese(i)
        # Creates a new one
        @cheese.push(make_cheese)
       
        # Might create another one
        if @cheese.size < Max_Cheese_Amount
          # Creates an extra cheese if enough cheese have been caught
          if @cheese_amount > @cheese.size * @cheese.size + 1
            # Creates a new one
            @cheese.push(make_cheese)
          end
        end
      end
    end
   
    # Draws the cheese
    for i in 0...@cheese.size
      draw_cheese(i, Color.new(10,200,20,255))
    end
   
    # Makes sure the trail isn't too short
    while @player_trail.size < Trail_Length
      # Adds the player positions into the trail
      @player_trail.push([@player_x,@player_y])
    end
   
    coords = @player_trail.shift
    # Draws the trail
    @contents.bitmap.fill_rect(coords[0]-(Size-1),coords[1]-(Size-1),
                          (Size*2)-1, (Size*2)-1, Color.new(0,0,0,255))
    #Calculates the steps per shade
    step = 200 / (Trail_Length)
    for i in 0...Trail_Length-1
      # Calculations
      coords = @player_trail[i]
      s = step*(Trail_Length-i)
      # Draws the trail
      @contents.bitmap.fill_rect(coords[0]-(Size-1),coords[1]-(Size-1),
                          (Size*2)-1, (Size*2)-1,
                          Color.new(200-s,200-s,100-(s/2),255))
    end
                         
    # Draws the player
    @contents.bitmap.fill_rect(@player_x-(Size-1),@player_y-(Size-1),
                            (Size*2)-1, (Size*2)-1, Color.new(200,200,100,255))
   
    # If UP Is Pressed
    if Input.trigger?(Input::UP)
      @player_dir = 8 unless @player_dir == 2
    end
    # If DOWN Is Pressed
    if Input.trigger?(Input::DOWN)
      @player_dir = 2 unless @player_dir == 8
    end
    # If LEFT Is Pressed
    if Input.trigger?(Input::LEFT)
      @player_dir = 4 unless @player_dir == 6
    end
    # If RIGHT Is Pressed
    if Input.trigger?(Input::RIGHT)
      @player_dir = 6 unless @player_dir == 4
    end
   
    # Moves the player accordingly to the directions
    case @player_dir
    when 8 then @player_y -= @speed # Down
    when 2 then @player_y += @speed # Up
    when 4 then @player_x -= @speed # Left
    when 6 then @player_x += @speed # Right
    end
    # Warping the player
    @player_x = (@player_x) % @width
    @player_y = (@player_y) % @height
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    @contents.bitmap.dispose
    @contents.dispose
  end
end

#==============================================================================
# ** Window_SLOLS_Bar
#==============================================================================

class Window_SLOLS_Bar
  #--------------------------------------------------------------------------
  # * Object Initialization
  #--------------------------------------------------------------------------
  def initialize
    @contents = Sprite.new(Viewport.new(0, 416, 640, 64))
    @contents.bitmap = Bitmap.new(640, 64)
    @left_block = Sprite.new(Viewport.new(540-48, 424, 48, 48))
    @left_block.bitmap = Bitmap.new(64, 64)
    @right_block = Sprite.new(Viewport.new(100, 424, 48, 48))
    @right_block.bitmap = Bitmap.new(640, 64)
    @blocks = [@left_block, @right_block]
    @bar = Sprite.new(Viewport.new(270, 446, 100, 4))
    @bar.bitmap = Bitmap.new(200, 4)
    @bar_f = Sprite.new(Viewport.new(270, 446, 100, 4))
    @bar_f.bitmap = Bitmap.new(100, 4)
    @bar_fx = 0
    # The sprites used
    @sprites = [@contents,@bar,@bar_f]
    refresh
  end
 
  #--------------------------------------------------------------------------
  # * Refresh
  #--------------------------------------------------------------------------
  def refresh
    @contents.bitmap.clear
    bar_color = Color.new(225,225,225,255)
    fin_color = Color.new(255,255,0,0)
    @bar.bitmap.fill_rect(0,0,25,4,bar_color)
    @bar.bitmap.fill_rect(50,0,25,4,bar_color)
    @bar.bitmap.fill_rect(100,0,25,4,bar_color)
    @bar.bitmap.fill_rect(150,0,25,4,bar_color)
    @bar_f.bitmap.fill_rect(0,0,100,4,fin_color)
    @blocks.each {|x| x.bitmap.fill_rect(0,0,64,64,fin_color)}
  end

  #--------------------------------------------------------------------------
  # * Update
  #--------------------------------------------------------------------------
  def update
    @bar.ox -= 1
    @bar.ox = @bar.ox % 100
    @bar.update
    if @bar_fx == 0 && (!$loader.is_a?(Thread) || !$loader.alive?)
      @bar_fx = 1
      @count = 3
      Sound.play_load
    end
    if @bar_fx > 0 && @bar_fx < 255
      @bar_fx += @count
      @bar_f.bitmap.fill_rect(0,0,100,4,Color.new(255,255,0,@bar_fx))
      @blocks.each do |x|
        x.bitmap.fill_rect(0,0,48,48,Color.new(255,255,0,@bar_fx))
      end
      case @bar_fx
      when 10..20   then @count = 50
      when 180..230 then @count = 5
      end
    end
  end
  #--------------------------------------------------------------------------
  # * Dispose
  #--------------------------------------------------------------------------
  def dispose
    @sprites.each { |x| x.bitmap.dispose}
    @sprites.each { |x| x.dispose}
  end
end