jorio / OttoMatic

Pangea Software’s Otto Matic 🤖
https://pangeasoft.net/otto
Other
141 stars 13 forks source link

Create a random level option in the level menu? #8

Closed foote-darrell closed 1 year ago

foote-darrell commented 2 years ago

I am new to this stuff, but what would it take to make a "Random" option in the level cheat menu? Just make it set LEVEL_NUM to a random integer between 1 and 10? It ought to be a simple and trivial thing to make.

foote-darrell commented 1 year ago

I got to know how to do this.

foote-darrell commented 1 year ago

I still need to find out how

foote-darrell commented 1 year ago

Seemingly in the LevelCheat.c file, there seem to be macros that define the names of the strings. Where are the macros from? The only search results that return are from this list. The strings seem to be in here. Where are the actual macros defined?

Is there a way to trype in a string literal directly the .c file? Does the project have any way to create a random integer for levels 1 thorugh 10? There seem to be many results of RandomFloat, but none for an integer.

foote-darrell commented 1 year ago

@jorio to date, still no answer.

jorio commented 1 year ago

Merry Christmas:

int DoLevelCheatDialog(void (*backgroundDrawRoutine)(void))
{
    static const MenuItem kLevelCheatMenu[] =
    {
        {.type=kMenuItem_Title,     .text=STR_LEVEL_CHEAT},
        {.type=kMenuItem_Spacer},
        {.type=kMenuItem_Pick,      .text=STR_LEVEL_1,      .pick=0},
        {.type=kMenuItem_Pick,      .text=STR_LEVEL_2,      .pick=1},
        {.type=kMenuItem_Pick,      .text=STR_LEVEL_3,      .pick=2},
        {.type=kMenuItem_Pick,      .text=STR_LEVEL_4,      .pick=3},
        {.type=kMenuItem_Pick,      .text=STR_LEVEL_5,      .pick=4},
        {.type=kMenuItem_Pick,      .text=STR_LEVEL_6,      .pick=5},
        {.type=kMenuItem_Pick,      .text=STR_LEVEL_7,      .pick=6},
        {.type=kMenuItem_Pick,      .text=STR_LEVEL_8,      .pick=7},
        {.type=kMenuItem_Pick,      .text=STR_LEVEL_9,      .pick=8},
        {.type=kMenuItem_Pick,      .text=STR_LEVEL_10,     .pick=9},
        {.type=kMenuItem_Pick,      .rawText="* RANDOM *",  .pick=10},
        {.type=kMenuItem_END_SENTINEL},
    };

    int pick = StartMenu(kLevelCheatMenu, nil, nil, backgroundDrawRoutine);

    if (pick == 10)
    {
        pick = MyRandomLong() % 10;   // random number in range [0...9]
    }

    return pick;
}
foote-darrell commented 1 year ago

Why not the Random level option in the 4.0.1 update? This a feature is a great improvement.