[Solved]Help: How to generating random values for position.

Status
Not open for further replies.

Lo0bo0

Villager
Member
Joined
May 11, 2020
Messages
10
Reaction score
2
First Language
spanish
Primarily Uses
VNM
Hi,
I want to make a mini game where the scene displays an image (with Hotspot) for a limited time, the player has to clic it in order get point and proceed in the story.

So far I have that covered, however I´d like the object to appear in a random position everytime.
Any idea how can I achieve this?
How can I modify the values from Direct position or other position values, so it returns a random number, and therefoe a random position for the object.

Thank you so much in advance, any help is appreciated.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,355
Reaction score
1,512
First Language
English
Primarily Uses
RMMV
Can it appear anywhere on the screen or does it need to take obstacles into account?
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,355
Reaction score
1,512
First Language
English
Primarily Uses
RMMV
How are you currently displaying it?
 

Lo0bo0

Villager
Member
Joined
May 11, 2020
Messages
10
Reaction score
2
First Language
spanish
Primarily Uses
VNM
Using a wait and jump to label command, then erasing the hotspot and making a new one appear.
I based this from a steam code from user Nikki, where the objects appeared in fixed position, but I want to make it more dynamic and make them appear in random positions.
 

Attachments

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,355
Reaction score
1,512
First Language
English
Primarily Uses
RMMV
Ah sorry, I never noticed this was for Visual Novel Maker. I don't think I'm gonna be much help on that one.
 

Lo0bo0

Villager
Member
Joined
May 11, 2020
Messages
10
Reaction score
2
First Language
spanish
Primarily Uses
VNM
Any idea how to solve it in rpg, then?
Maybe I can apply the same logic, to adapt the process for VNM.
 

Trihan

Speedy Scripter
Veteran
Joined
Apr 12, 2012
Messages
2,355
Reaction score
1,512
First Language
English
Primarily Uses
RMMV
In MV, I'd just set the X and Y coordinate of the hotspot sprite to a random integer between 0 + width/height and screen width/height - width/height (to make sure it doesn't go off the screen).
 

Lo0bo0

Villager
Member
Joined
May 11, 2020
Messages
10
Reaction score
2
First Language
spanish
Primarily Uses
VNM
I got it! Thanks for your answer, @Trihan I started to searched for the random value for position x and y, and found out a similar post : Is randomizing scenes/events possible?

I mixed them both and got a working randomized position for Hotspot.

Here is how it looks.
Hope this comes handy to others!

1.PNG
 

slimmmeiske2

Little Red Riding Hood
Global Mod
Joined
Sep 6, 2012
Messages
6,988
Reaction score
4,736
First Language
Dutch
Primarily Uses
RMXP

This thread is being closed, due to being solved. If for some reason you would like this thread re-opened, please report this post and leave a message why. Thank you.

 
Status
Not open for further replies.

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Besides my Might and Magic inspired project, I have always wanted to make a Fire Emblem-like game. Time is the culprit... Between life, composing music packs, and working on a game can it be done!? The tactical plugins for MV work quite well based on what I have tested.
Yaaay! My second public script is out and approved! A VX Ace Final Fantasy IX styled Throw Script!

I look forward to all the constructive feedback I get but most importantly I hope everyone who ends up using it enjoys!

Yaaaay! Making scripts is fun lol. :D
When you're lost out therrrrre and you're alllll alone, ahwahwah waitin, to carry you hooooommmme, uhhheverywhere you look! (someone hit me with those backing vocals)
X.X cant focus... too many thing want do... help!
Day 2 of teaching MV, student can move cat across the map.

Forum statistics

Threads
100,525
Messages
976,813
Members
132,080
Latest member
nwr
Top