# Idea Rhythm game trainer?

Discussion in 'Game Design, Development And Publishing' started by Emanuel de Jong, Apr 6, 2019.

Tags:
1. ### Emanuel de JongMember

Joined:
Apr 6, 2019
Posts:
1
I'm thinking of making a combination trainer for the standard notes fall down rhythm game, because I've been trying to learn to play with 10 fingers and I'ts really hard to get down.

terms, so non rhythm game players can understand:
• column - vertical line
• key - keyboard key connected to a column
• note - point on a column
A note is always on a column but a column doesn't always have a note.
Moving on...

My ideal is to have random combinations of notes for a selected amount of columns (In my case I'd choose 10) that disappear only when you press the matching keys.
This way you will learn all possible combinations instead of the commonly used ones and will not have the stress of clicking on time which reduces bad habits and giving up.
The loop would basically be:
1. randomize which columns get a note
2. wait until only the keys matching these columns are pressed
3. repeat
Features I'd like to have are:
• choosing the amount of columns
• choosing the amount of random notes ( 1 - the amount of columns given (e.g. 4), or random (e.g. something between 1-10 changing every loop)

Emanuel

Edit: I haven't coded much in Game Maker but I am studying as a software engineer (To give you an ideal of what would be appropriate for me...)

Last edited: Apr 6, 2019
SnotWaffle Studios likes this.
2. ### dannyjennMember

Joined:
Jul 29, 2017
Posts:
572
I don't know if this is the best way, but I'd probably do something using bit flags and the bitwise operators. (You could also use strings, but in my example I will be using bit flags.) Since you want ten columns, each horizontal row could be represented by a 10-bit number. A bit value of 1 would signify that there's a note in the corresponding column in that row, whereas a value of 0 would signify no note in that column in that row.

"choosing the amount of columns"
I'm a little confused on what you're asking. I thought you said you always want 10? Or was that just an example? In either case, I'd keep track of this in a macro (or in a variable if you want to be able to change it during the game)
Code:
```// create event:
#macro total_columns 10 // macro
// or
// total_columns = 10; // variable```

"choosing the amount of random notes"

"1 - the amount of columns given (e.g. 4)"
I'd run a loop until all the notes have been placed in the row, and use an if statement to place them in the right column:
Code:
```// script generate_row(argument0)
// argument0 - the number of columns you want notes in (e.g. 4)
var amount_of_notes_remaining = argument0;
notes = 0; // <-- begins as %0000000000 since no notes are in it yet
while(amount_of_notes_remaining>0){ // run the loop until we have no notes remaining
var column = irandom(total_columns-1); // choose a random column
if(!((notes>>column)&1)){ // if that column doesn't already have a note in it, then
notes |= (1<<column); // put the note in it
amount_of_notes_remaining -= 1; // one less note remaining
}
}
return notes;```
"or random (e.g. something between 1-10 changing every loop)"
This is just a special case of the above script, in which argument0 is 10.

So, your main loop (step event) would something like this:
Code:
```// step:
keyboard_input = 0; // <-- begins as %0000000000
if(keyboard_check(key_1){
keyboard_input |= 512; // %1000000000
}
if(keyboard_check(key_2){
keyboard_input |= 156; // %0100000000
}
if(keyboard_check(key_3){
keyboard_input |= 128; // %0010000000
}
if(keyboard_check(key_4){
keyboard_input |= 64; // %0001000000
}
if(keyboard_check(key_5){
keyboard_input |= 32; // %0000100000
}
if(keyboard_check(key_6){
keyboard_input |= 16; // %0000010000
}
if(keyboard_check(key_7){
keyboard_input |= 8; // %0000001000
}
if(keyboard_check(key_8){
keyboard_input |= 4; // %0000000100
}
if(keyboard_check(key_9){
keyboard_input |= 2; // %0000000010
}
if(keyboard_check(key_10){
keyboard_input |= 1; // %0000000001
}

if(keyboard_input==key){ // wait until only the keys matching these columns are pressed
key = generate_row(4); // randomize which columns get a note; repeat
}
// Note: you might want to improve that if statement to make sure that all the keys were pressed at roughly the same time. The way I have it, the game doesn't know whether the key was just pressed or whether the player has been holding it down for a while.```

You'll also need to initialize the notes variable to generate_row() in the create event. And also all the key_1, key_2, etc. ... I'd set them to ord("A"), ord("S"), ord ("D"), etc., though you should probably let the player edit these.