Help with eventing a minigame

Hi there! I am trying to create a minigame using an event and I am running into some trouble. I want a simple minigame where a player has to move a nose away from bees that are coming out of some flowers. Basically, a bee will shake back and forth and then fly upwards from one of three flowers, and the player will use the arrow keys to move the nose left and right to try and dodge the bee.

I have a basic version of this minigame made using an event, but it has two problems. The first problem is that it starts to lag the game when it runs, dropping me from 60 fps to 40fps. The second problem is that it only works with the bee in the center, and not the bee's on the left and right. Here is an example of what I want the minigame to do.

Poorly Illustrated Example.png

This is the event I have so far:
UNTOLD - RPG Maker MV 9_8_2023 1_55_42 AM.png

The variable MG Flower Bee Settings is set to 1, which activates a loop. In that loop, a conditional branch is activated that shows a picture of a bee above the center flower and shakes it back and forth. It then sets the variable MG Flower Bee Center to 1 to show that the center bee is active, then it sets the bee picture's Y coordinate variable as 372, and it's X coordinate variable as 408. Finally, it sets the variable MG Flower Center Bee Loop to 1 to move the bee upwards.

When MG Flower Center Bee Loop = 1 it activates a conditional branch that spawns a picture of the center bee using variables for it's X and Y coordinates. It then waits 1 frame and subtracts 7 from the Y coordinate variable every loop in order to make the center bee move upwards. I then repeated this process, but this time the bee comes out of the flower on the left instead of the center.
UNTOLD - RPG Maker MV 9_8_2023 1_56_17 AM.png
UNTOLD - RPG Maker MV 9_8_2023 1_56_33 AM.png

I then added a conditional branch for if the player failed to dodge the center bee. If the variable MG Flower Bee Center = 1, and the center bee's Y coordinate variable = 272 or lower (meaning the bee has hit the nose) , and the variable MG Flower Nose Center = 1 (meaning the nose is above the center flower) and the switch MG Flower Center Bee Miss Trigger is off (meaning the bee hasn't already passed the nose), then it erases the center bee's picture and flashes the screen red before shutting off all variables relating to the center bee. This whole sequence of events works as intended, although it does cause the game to lag which is a problem.

The second problem happens when I try to repeat this process for the left bee.
UNTOLD - RPG Maker MV 9_8_2023 1_57_03 AM.png

As you can see I'm using the same process and just switching the variables to match the variables for the left bee instead of the center bee, but for some reason when the nose fails to dodge the left bee nothing happens, and the bee just phases right through it without flashing red or doing anything.

The rest of my event is just a trigger that says if either bee has gone higher past the nose, and if so to erase the bees
UNTOLD - RPG Maker MV 9_8_2023 1_57_29 AM.png


and controls for the nose so that the player can move it left and right using the arrow keys.
UNTOLD - RPG Maker MV 9_8_2023 1_57_46 AM.png
UNTOLD - RPG Maker MV 9_8_2023 1_58_00 AM.png
UNTOLD - RPG Maker MV 9_8_2023 1_58_08 AM.png


I'm looking for a better way to event this minigame, or for someone to help point out the problems that are making it lag the game and not work properly. Any help would be extremely appreciated, thanks 🙂
Looping events need a wait somewhere or they cause lag by repeating too quickly. Try adding a wait of 1 frame right before Repeat Above at the end.
there are serveral problems from 1 page, as well that you erase picture #8
and than add picture #8 which is not needed, so "erase picture" can be put away.

another issue is probably a pre-load of the pictures to avoid flickering.

the 3rd issue is the looping event, this can cause ALOT of problems including lags
if using it incorrectly, I would rather remove it as a parallel = a basic looping part,
so you use twice for looping.
That logic structure has several problems, but I don't have time to work out details for you.
so here are several hints for this:

1) parallels are already looping, and placing a loop inside a parallel has additional problems of their own. It would be much better to split the game into using multiple parallel events interacting.

2) in any form of loop, a wait effectively reduces lag by skipping processing time - unless you use too many lags, then it slows down.
That are two different effects that are both experienced as lag unless you really know what to look for.

If you have no wait, the event is processed sixty times per second - that requires a lot of CPU power and can cause true lag by reducing computer power.
a wait basically says "skip processing this event for x frames" - which reduces the drain on the CPU.
However too many waits and the event is slow to react to input, because it is not processed often enough - that looks like lag as well but is waited processing instead of slowed processing.

and the correct number of waits for best effect is a compromise and different depending on the event, so you always have to experiment to find the best number of waits.

3) in a parallel, the game engine handles the updates and automatically interrupts the parallel for other important processings.
In a loop, that security is ignored by the engine and has to be handled manually. That is what the tip for the wait above is about, it gives the engine a skip point to handle other tasks

Contrary to the tip above a wait is not always needed - it depends on what the loop does.
And that is the reason why the loop command exists at all: to allow the developer to gain manual control of the looping and to allow him to decide if the loop needs the full process to be handled fast (which may stop everything else and cause lag if too much), or if the loop needs skip points to allow for the rest of the engine to catch up.
In addition to what is said above about not using the loops, your event seems kind of too complex. For the nose movement, you can just have something like:

variable 'nose position' (1 left, 2 center, 3 right)
If left is pressed: subtract 1
If variables < 1 -> set it to 1
If right is pressed: add 1
If variables > 3 -> set it to 3

Then show your nose picture at an noseX coordinate that's like (nose position * 200), or something.

Also, you don't need all these centre bee Y, left bee Y, right bee Y. Just one X+Y is enough. You just change the beeX-coordinate depending on what flower it appears (a random roll). The x-coordinates can match the possible noseX coordinates. Then your parallel subtracts from the beeY-coordinate and If noseX==beeX and beeY<whatever, then you register a hit.
Thank you everyone, this advice is exactly what I was looking for! 🙂

Original thread: https://forums.rpgmakerweb.com/threads/help-with-eventing-a-minigame.161011/