[XP] Letter minigame

Started by Zeriab, January 08, 2008, 06:45:58 am

Previous topic - Next topic

Zeriab

January 08, 2008, 06:45:58 am Last Edit: August 18, 2011, 02:33:46 pm by Zeriab
Letter Minigame
Authors: Zeriab
Version: 1.2
Type: Logical Minigame
Key Term: Minigame



Introduction

The Letter Minigame has been made by Zeriab.
Thanks goes to RMXP for making this possible and Near Fantastica for the Anti Event Lag Script.
Credits should be given.

The purpose in the Letter Minigame is to get a good score by collecting as many letters in the maze as possible within the time limit.
Different letters give different amount of points.

You can see how much each letter gives by looking at the letters on this island.
The more points the rarer the letter.

A yellow letter = 10 points
A green letter  = 15 points
A azure letter  = 20 points
A red letter    = 25 points
A purple letter = 30 points
A black letter  = 100 points


Version History
Version 1.2:
Fixed an issue which might cause immense amounts of memory to be used.

Version 1.1:
Adds $letter_minigame.score - works also after $letter_minigame.dispose.
Gives a solution to the F12 issue present in the earlier demo.


Screenshots





Demo

You download my demo from: http://www.mediafire.com/?mjqe21okk4c


Script

The script is too big to put it in here so I have place it in a text file which can be downloaded here: http://www.mediafire.com/?ynqbzmmjjmd


Instructions

Here 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.


FAQ

How 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.

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:
Quote
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... 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.


How do I set up item prizes?
For example, if I had 250 points, I win a potion or something like that.


Using this command will return the score: $letter_minigame.score
For non-scripters you can use the Call Script command with $game_variables[10] = $letter_minigame.score, where the 10 is the variable number. Just set it to the number of the variable you want to use.
Now that you have the score in a variable I assume that you can do the rest.


Compatibility

Is not compatible with saving and loading. The map will reset if loaded.
Might be SDK compliant.


Credits and Thanks

I would like to thank RMXP - Underground personal for creating a scripting contest which inspired me to create this work.
I would like to thank everyone using their time to try this and finally I would like to thank everyone reading this topic.
Thanks.


Author's Notes

I suggest using Near Fantastica's anti event lag script due to the often high amount events.
This script can create more than 1000 events. I suggest however that you refrain from designing level where this is an eminent possibility.
Using the event command Erase Event will not entirely delete the event.
The event still exists in the $game_map.events and lags about as much as a blank events.

And finally: ENJOY!

- Zeriab

Fantasist

Ah, my inspiration :)
I'll rip off info from this now w00t
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




Zeriab

Your inspiration? What has this old script inspired you to do? (Yup, this is my 2nd and 3rd script bundled together)
Anyway, feel free to rip off any info you can.

Fantasist

January 11, 2008, 06:09:59 pm #3 Last Edit: January 11, 2008, 06:11:40 pm by Fantasist
Well, for one thing, determining the positions of the letters and I didn't know about rand() back then.

And I always rip apart a good script when I see one :)
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




Slammin


Zeriab

Aww, thanks
I appreciate it  :3

@Fantasist: Remember that rand() is a rather expensive method.

Fantasist

Quote@Fantasist: Remember that rand() is a rather expensive method.

I really didn't know this *makes mental note*
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




Blizzard

Wait, what?! O_O I don't know Ruby's implementation of rand(), but isn't it just like translating and scaling after obtaining the number like in C?
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


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.

Zeriab

March 04, 2008, 11:19:24 am #8 Last Edit: March 05, 2008, 10:56:17 am by Zeriab
Whoops, I made a flawed test. (I didn't make a pure test on rand alone... In the test I made the arrays iterated over were on average bigger when the rand() method was used)
After another test I found that using the rand() method in Ruby has an insignificant effect.
k = 10000000
print 'Test 1 go'
t = Time.now
s = 0
for i in 0...k
  s += rand(5)
end
t = Time.now - t
print 'Test 2 go'
t2 = Time.now
s2 = 0
for i in 0...k
  s2 += 1
end
t2 = Time.now - t2
print 'Fin'
p s,t,'',t2, s2


The reason there is no significant different in this case is simple because Ruby is so slow. I just considered how it is if you for example program in C++ -_-
Thanks Blizzy <3

Blizzard

Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


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.

Fantasist

me too. (rewrites mental note)
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




Zeriab

I scared you? Then I should have waited a few days with my response :=

Fantasist

You're too sweet a martian to do that :P
Do you like ambient/electronic music? Then you should promote a talented artist! Help out here. (I'm serious. Just listen to his work at least!)


The best of freeware reviews: Gizmo's Freeware Reviews




Blizzard

You scared the hell out of me. That was just for one moment. If you waited longer, this wouldn't have changed anything.
Check out Daygames and our games:

King of Booze 2      King of Booze: Never Ever
Drinking Game for Android      Never have I ever for Android
Drinking Game for iOS      Never have I ever for iOS


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.

Zeriab

Yeah, you are right Fantasist ;_;

@Blizzy:
There's nothing like a moments scare every now and then >:3
Even if it was due to a stupid test case it was worth it

cheos

im having troble getting script/demo can u put a megaupload or somethin just bout anything will do 4 me
[Insert Mind Blowing Signature]

GamerGeeks


its a shame that the download link is broken :(

Zeriab

I have replaced them with some working ones. Thanks for reporting the issue ^_^

GamerGeeks

woooow this game is sooo fun!!!! would it be possible to make it for RMX-OS and then add highscore? that would be epic! overall nice work!

Zeriab

I am glad you like it :3
I don't know RMX-OS well enough to tell you whether there will be any particular problems or not.

You can retrieve the score with $letter_minigame.score and then use it for whatever.
Unfortunately you will have to find another scripter as I haven't had time to script lately and I probably won't have for a long time.

*hugs*