Started by Zeriab, January 08, 2008, 06:45:58 am
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 9The 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 = 0For 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.newThis will gather information from $letter_minigameYou might have an interest in changed the results screen accordingly to your needs. Feel free to do so
Quote from: long answerThe 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:QuoteX0X0X0X0P0P0P0X0X0X0X0P0S0P0X0X0X0X0P0P0P0X0X0X0XIt will continue to spread outwards like that.Symbol Explination:S: Starting pointP: 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... ANY of the X-squares.If you do not have a rim around the maze you can however not be sure of a way from one X to another.Something like this might do the trick:Maze_Generator::Maze.new(49,49,0,,48)The 48 tells the script to use the tile graphic with id 48. Before 0 was used.48 is generally water.I don't know the system for this. I just found out with trial and error.If you are creating a wall rather than a path you can also encase an area or the maze itself by putting the title with id-48 on the P's.There will be a walkable path around the P.You have to something like because I haven't scripting in the possibility to have just one and no more than one of a certain event places somewhere in the maze.I or you could try to simply put the event on the last square touched by the crawler. (Script edit)I hope you will find my answer satisfying.
Quote@Fantasist: Remember that rand() is a rather expensive method.
Quote from: winkioI do not speak to bricks, either as individuals or in wall form.
Quote from: Barney StinsonWhen I get sad, I stop being sad and be awesome instead. True story.
k = 10000000print 'Test 1 go't = Time.nows = 0for i in 0...k s += rand(5)endt = Time.now - tprint 'Test 2 go't2 = Time.nows2 = 0for i in 0...k s2 += 1endt2 = Time.now - t2print 'Fin'p s,t,'',t2, s2