#==============================================================================
# ** Scene_Menu
#------------------------------------------------------------------------------
# This class performs menu screen processing.
#==============================================================================
class Letter_Result_Menu
#--------------------------------------------------------------------------
# * Object Initialization
# menu_index : command cursor's initial position
#--------------------------------------------------------------------------
def initialize
@menu_index = 0
end
#--------------------------------------------------------------------------
# * Main Processing
#--------------------------------------------------------------------------
def main
# Make command window
s1 = "Okay"
@command_window = Window_Command.new(160, [s1])
@command_window.index = @menu_index
# Make letter window
@letters_window = Window_Letters.new
@letters_window.x = 0
@letters_window.y = 64
# Make letter amount window
@amount_window = Window_Letter_Amount.new
@amount_window.x = 0
@amount_window.y = 416
# Make results window
@results_window = Window_Letter_Results.new
@results_window.x = 160
@results_window.y = 64
# Make level window
@level_window = Window_Letter_Level.new
@level_window.x = 160
@level_window.y = 0
# Execute transition
Graphics.transition
# Main loop
loop do
# Update game screen
Graphics.update
# Update input information
Input.update
# Frame update
update
if $letter_minigame != nil
$letter_minigame.update
end
# Abort loop if screen is changed
if $scene != self
break
end
end
# Prepare for transition
Graphics.freeze
# Dispose of windows
@command_window.dispose
@letters_window.dispose
@amount_window.dispose
@results_window.dispose
@level_window.dispose
end
#--------------------------------------------------------------------------
# * Frame Update
#--------------------------------------------------------------------------
def update
# Update windows
@command_window.update
@letters_window.update
@results_window.update
@results_window.update
@level_window.update
# If command window is active: call update_command
if @command_window.active
update_command
return
end
# If status window is active: call update_status
if @status_window.active
update_status
return
end
end
#--------------------------------------------------------------------------
# * Frame Update (when command window is active)
#--------------------------------------------------------------------------
def update_command
# If B or C button was pressed
if Input.trigger?(Input::B)
# Play cancel SE
$game_system.se_play($data_system.cancel_se)
# Dispose of $letter_minigame
$letter_minigame.dispose
# Switch to map screen
$scene = Scene_Map.new
return
end
# If C button was pressed
if Input.trigger?(Input::C)
# Play decision SE
$game_system.se_play($data_system.decision_se)
# Dispose of $letter_minigame
$letter_minigame.dispose
# Switch to map screen
$scene = Scene_Map.new
return
end
end
end
#==============================================================================
# ** Window_Letters
#------------------------------------------------------------------------------
# This window displays amount of each Letter.
#==============================================================================
class Window_Letters < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 352)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
if $letter_minigame != nil
counter = 0
for sprite in $letter_minigame.array_of_sprites
self.contents.blt(0,-22+32*counter,sprite.bitmap,sprite.src_rect)
counter += 1
end
end
end
end
#==============================================================================
# ** Window_Letter_Amount
#------------------------------------------------------------------------------
# This window displays the total amount of letters.
#==============================================================================
class Window_Letter_Amount < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 160, 64)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
word = $data_system.words.gold
if $game_party.gold == 1 then
word = word.chop
end
amount = 0
for element in $letter_minigame.array_count
amount += element
end
cx = contents.text_size(word).width
self.contents.font.color = normal_color
self.contents.draw_text(4, 0, 120-cx-2, 32, amount.to_s, 2)
self.contents.font.color = system_color
self.contents.draw_text(124-cx, 0, cx, 32, word, 2)
end
end
#==============================================================================
# ** Window_Letter_Results
#------------------------------------------------------------------------------
# This window displays the score of the level and how it is computed.
#==============================================================================
class Window_Letter_Results < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 480, 416)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
self.contents.clear
if $letter_minigame != nil
array_count = $letter_minigame.array_count
array_of_points = $letter_minigame.array_of_points
array_of_sprites = $letter_minigame.array_of_sprites
counter = 0
sum = 0
for sprite in array_of_sprites
firstpart = (array_count[counter].to_s.length + 1) * 11 + 36
secondpart = (array_of_points[counter].to_s.length + 1) * 11
value = array_of_points[counter]
result = value * array_count[counter]
sum += result
y = 32*counter
if y > 351 then
y = 550
end
self.contents.blt(0,-22+y,sprite.bitmap,sprite.src_rect)
self.contents.draw_text(firstpart,-10+y,
480,64,'x ' + value.to_s)
self.contents.draw_text(firstpart + secondpart + 7,-10+y,
480,64,'= ' + result.to_s)
counter += 1
end
self.contents.draw_text(0,336,480,64, 'Total Score: ' + sum.to_s)
end
end
end
#==============================================================================
# ** Window_Letter_Level
#------------------------------------------------------------------------------
# This window displays some level information
#==============================================================================
class Window_Letter_Level < Window_Base
#--------------------------------------------------------------------------
# * Object Initialization
#--------------------------------------------------------------------------
def initialize
super(0, 0, 480, 64)
self.contents = Bitmap.new(width - 32, height - 32)
refresh
end
#--------------------------------------------------------------------------
# * Refresh
#--------------------------------------------------------------------------
def refresh
text = $game_map.width.to_s + 'x' + $game_map.height.to_s + ' at speed ' +
$game_variables[2].to_s
self.contents.font.color = system_color
self.contents.draw_text(0,-16,480,64,text)
end
end
I have collected them all in 1 file which can be downloaded here:
http://www28.websamba.com/Vobbys/Letter_Minigame_All.txtI don't recommend it, but I acknowledge the fact that some people don't want to copy each class into a separate place in the script editor.
Note that I haven't tested using that file.
InstructionsHere I will try to explain how the scripts is used.
I have split this section in two.
One for the Maze Generator. This generates the maze and places the events.
This is not linked with the Letter Minigame.
One for the Letter Minigame. This controls the letters collected and the visual effects.
This is not linked with the Maze Generator. A normally made level could be used.
You can look at the scripts in the end of the scripts editor.
I have also edited some of the normal scripts in the demo. These has been marked by having a * in front of its name in the script chooser.
This is the Maze_Generator module.
To call it use this syntax:
Maze_Generator::Maze.new(x, y, max_chance, array_of_events, value=0, layer=1)
x : x-coordinate for starting point
y : y-coordinate for starting point
max_chance : The total chance used for choosing among the events
array_of_events : Numbers on events paired with their chance value
value : value of the tileset assigned to the maze (default=0)
layer : the layer that will be crawled (default=1)
An example could be:
Maze_Generator::Maze.new(49,49,300,[[2,22],[3,19],[5,17],
[6,14],[7,10],[9,2]],0,1)
Notice the how you should write the array_of_events.
The first number is the number on the event you want.
In this example the script will start in 49,49 and spread out from there.
It will change the tiles on layer 1 to 0 if it's not already 0.
You can encapsulate the maze by making a border of tiles with 0 as value.
Otherwise it will be restricted by the map borders.
In dead ends it might place an event.
The second value you see in each pair shows the change that the corresponding event is spawn. It is compared to the total probability.
There is a 22/300 chance of event number 2 being spawned in a dead-end.
There is a 19/300 chance of event number 3 being spawned in a dead-end and so on.
The originally placed events WILL be deleted.
Don't let the user save the game in a map where you have used the Maze_Generator as the changes will not be saved.
This is the letter minigame itself.
Managing how many of which letters are collect and showing the stats.
To call it use this syntax:
$letter_minigame = Letter_Minigame.new(array_of_events, array_of_points)
array_of_events : Numbers on the events used.
array_of_points : The amount of points for the corresponding event in
array_of_events. Linked by placement.
$letter_minigame is the reference used by the results screen.
An example could be:
$letter_minigame = Letter_Minigame.new([2,3,5,6,7,9],[10,15,20,25,30,100])
This will take and use the graphics from event number 2,3,5,6,7 and 9
The latter shows the amount of points each element is worth.
The first element will have the graphic from event number 2 and be worth 10.
The second element will have the graphic from event number 3 and be worth 15 and so on.
The events you should collect must contain this line as a script:
$letter_minigame.add(position)
position : Position of the element in the array. First position = 0
For example the syntax
$letter_minigame.add(0)
Should be put in the events which has the graphic of event number 2 and are 10 points worth.
$letter_minigame.add(1)
Should be put in the events which has the graphic of event number 3 and are 15 points worth and so on.
Now when the minigame is finished used this syntax to call the results screen.
$scene = Letter_Result_Menu.new
This will gather information from $letter_minigame
You might have an interest in changed the results screen accordingly to your needs. Feel free to do so
The command $letter_minigame.score returns the score.
This works even after the $letter_minigame.dispose command is used.
That is because .dispose leaves the little information needed for calculation the score.
You can for example use this for giving prizes afterwards.
FAQHow could I make a maze that has no timer on it with this script? Cause I wanna make a maze, and put a boss in it, but I want the maze to be randomized, and I don't want the timer either. The other thing is, how can I set this up so that I can have just the 1 boss event in it in a specific spot, and not have to worry about that spot being in a wall, or unreachable because the maze wasn't made right.The timer part is easily solved because the event in the top-left corner is controlling the timer.
For what you want you don't need the Letter Minigame, just the Maze_Generator module.
You don't need the $letter_minigame = Letter_Minigame.new([2,3,5,6,7,9],[10,15,20,25,30,100])
You would only need something like this: Maze_Generator::Maze.new(49,49,0,[],0)
This will create a maze where no events are spawned.
Now can you find a plaze where there with certainty is no wall?
Yes. The starting point you give.
Considering the above example the square at 49, 49 will be empty.
There might be more certain squares, but I'm not sure.
I do however know that there is a pattern linked with the probability of a square being a wall.
If S is the starting point then the pattern will look like this:
X0X0X0X
0P0P0P0
X0X0X0X
0P0S0P0
X0X0X0X
0P0P0P0
X0X0X0X
It will continue to spread outwards like that.
Symbol Explination:
S: Starting point
P: Very high possibility of being a passable square (non-wall), above 90% I'd say. Probability decreases near edges.
O: Might be a wall, might not. No significant difference is probability.
X: Is most certainly a wall.
So you can put your boss on the starting point for certainty or on one of the P's for a very good chance of not being in a wall. (Don't put the boss near an edge in this case)
There might also be another solution you can use.
You see the X's are most certainly a wall.
What now if the wall was passable and the other wasn't?
That way the script would create the wall.
As the script create an acyclic graph (you don't have to understand this term) you be certain that there is a way from outside into any, yes