[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
1,869
Reaction score
1,219
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
1,869
Reaction score
1,219
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
1,869
Reaction score
1,219
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
1,869
Reaction score
1,219
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,806
Reaction score
4,617
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

Automatic level scaling without an option to turn it off can be a very bad choice for a game. The worst I've ever seen was in Nightmare of Druaga, where if a power outage made your system turn off, the game detects it as an attempted cheat and overwrites your save while taking away your best gear, leaving you unable to progress at the late stages of the game, and unable to recover.
Problem with sequels: Heroes getting rid of all their items and forgets all of their skills within the span of a year without explanation. :kaomad3:
I can see the end of my prologue. Perfect time to decide to pull everything over into MZ, right? Right?!
Excited to be nearing the end of setting up my own custom Point-And-Click system template! Just need to iron out some kinks, get an input text system going, add animations to buttons, and then finalize my button-mashing event system and it'll be complete >:3c
AlcTheHero wrote on Mystic_Enigma's profile.
hi.

Forum statistics

Threads
99,643
Messages
967,612
Members
131,312
Latest member
jacob_rev
Top