OttoMatic icon indicating copy to clipboard operation
OttoMatic copied to clipboard

Create a random level option in the level menu?

Open foote-darrell opened this issue 4 years ago • 2 comments

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 avatar Oct 02 '21 07:10 foote-darrell

I got to know how to do this.

foote-darrell avatar Aug 04 '22 06:08 foote-darrell

I still need to find out how

foote-darrell avatar Aug 04 '22 06:08 foote-darrell

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 avatar Dec 25 '22 04:12 foote-darrell

@jorio to date, still no answer.

foote-darrell avatar Jan 02 '23 01:01 foote-darrell

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;
}

jorio avatar Jan 31 '23 22:01 jorio

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

foote-darrell avatar Feb 25 '23 05:02 foote-darrell