genemm

Villager
Member
Joined
Aug 17, 2018
Messages
16
Reaction score
0
First Language
Filipino
Primarily Uses
RMMV
Hi everyone,

Great day! I am trying to make a diamond grid nested loop but I have a problem with it. There are excessive events created that are more than the desired diamond grid. Kindly check the attached files for the picture. Here are my event commands and scripts:

Control Variables : #0003 map.start = Map ID
Control Variables : #0001 player.start.x = 1
Control Variables : #0002 player.start.y = 1
Control Variables : #0006 player.walk.min = Random 0..7
Control Variables : #0007 player.walk.max = $gameVariables.value(6)+Math.randomInt(7-$gameVariables.value(6)+1);

Transfer Player : {map.start}({player.start.x},{player.start.y})

Script : Galv.SPAWN.overlap = 'chars';
Control Variables : #0014 player.walk.tilex = 0
Control Variables : #0015 player.walk.tiley = 0
Control Variables : #0014 player.walk.tilex += player.walk.min
Control Variables : #0015 player.walk.tiley = 0
Loop
If : player.walk.tiley <= player.walk.max
Loop
If : Script : $gameVariables.value(14)<=$gameVariables.value(7);
Script : Galv.SPAWN.event(3,$gameVariables.value(1)+$gameVariables.value(14)-$gameVariables.value(15),
$gameVariables.value(2)+$gameVariables.value(15));
Script : Galv.SPAWN.event(3,$gameVariables.value(1)-$gameVariables.value(14)+$gameVariables.value(15),
$gameVariables.value(2)-$gameVariables.value(15));
Script : Galv.SPAWN.event(3,$gameVariables.value(1)+$gameVariables.value(14)-$gameVariables.value(15),
$gameVariables.value(2)-$gameVariables.value(15));
Script : Galv.SPAWN.event(3,$gameVariables.value(1)-$gameVariables.value(14)+$gameVariables.value(15),
$gameVariables.value(2)+$gameVariables.value(15));
: Else
Break Loop
Jump to Label : After Loop X
: End
Control Variables : #0014 player.walk.tilex += 1
: Repeat Above
Label : After Loop X
Control Variables : #0014 player.walk.tilex = player.walk.min
: Else
Break Loop
Jump to Label : After Loop Y
: End
Control Variables : #0015 player.walk.tiley += 1
: Repeat Above

The image I used for the diamond grid is the dog. Please help me remove the excessive dog events created.
 

Attachments

  • RMMV.PNG
    RMMV.PNG
    245.6 KB · Views: 12
  • RMMV2.PNG
    RMMV2.PNG
    114 KB · Views: 11
  • RMMV3.PNG
    RMMV3.PNG
    49.7 KB · Views: 9
  • RMMV4.PNG
    RMMV4.PNG
    64.9 KB · Views: 9

standardplayer

Keeper of Kitties
Veteran
Joined
Apr 6, 2016
Messages
700
Reaction score
3,468
First Language
English
Primarily Uses
N/A
I'm not familiar with the plugin you've shown, but in the above image, if you wanted only a diamond shape made out of dogs, try adding this to your code. (I'll have to describe)

There is a function called $gameMap.distance
It accepts the following arguments
x1, y1, x2, y2

In the above image, if all excess was removed (dogs), it would be only the dogs that had a distance of 3 from the Player.

So when generating the dogs, if you add this condition (we'll called the dog event position being examined 'dog')

if($gameMap.distance($gamePlayer.x, $gamePlayer.y, dog.x, dog.y) == 3)

The above condition requires that if the process is attempting to draw a dog, it must be a total (x and y) of 3 tiles from the player. If that rule
was followed in the image you've shown, it would leave a nice, even diamond shape.

I hope this helps.

*Also, There is a possibility that $gameMap.distance is a function added in by a Yanfly Core plugin, I'm not 100% sure. I just checked and it doesn't seem to be.
 

genemm

Villager
Member
Joined
Aug 17, 2018
Messages
16
Reaction score
0
First Language
Filipino
Primarily Uses
RMMV
Hi standardplayer,

Thank you for your reply. As for your if($gameMap.distance($gamePlayer.x, $gamePlayer.y, dog.x, dog.y) == 3) formula, can you please provide me the full code to create the diamond grid dogs perfectly like this representation:

if($gameMap.distance($gamePlayer.x, $gamePlayer.y, dog.x, dog.y) == 3) {
//generate dogs in diamond grid pattern <- please finish the code
}
 

Attachments

  • RMMV6.PNG
    RMMV6.PNG
    2 KB · Views: 1
  • RMMV7.PNG
    RMMV7.PNG
    1.7 KB · Views: 1

Latest Threads

Latest Posts

Latest Profile Posts

ScreenShot_10_5_2022_4_44_8.png
Mad O' Malley... a stick figure that's afraid of it's existence being erased. so they always start battle in an anxious state.
Before, I was drawing all the sprite work, super big and shrinking it down. Which was really time consuming if thing's changed. So instead I'm drawing the characters sketch, and then remaking it with pixel art instead.
Why are job interviews so terrifying. :kaodes:

Forum statistics

Threads
125,799
Messages
1,173,638
Members
164,963
Latest member
ervll
Top