Randomizing layout jump-to's with probability %'s

This forum is currently in read-only mode.
From the Asset Store
Jump on candies, collect candies and earn score!!!
  • 1. So I'm trying to do something where when my QB throws a pass to one of the receivers (indicated by the 5 White boxes in the diagram), and then the game would jump randomly to one of the layouts indicated by the blue and gold boxes.

    <img src="http://farm3.static.flickr.com/2633/4214371322_93833137cb_o.jpg">

    Now, what I wanna do is assign percentages of probability to each jump-to outcome. For example, "Caught" would have a 56% probability meaning that 56% of the time the game would jump-to the "Caught" layout while, say, 1% of the time the game would jump-to the "intercepted" layout.

    2. Also, I wanna be able to assign different timing to each jump-to. For example, when jumping-to the "Overthrown" layout it may stay in the QB layout for 2 seconds after the pass, while jumping-to the "Dropped" layout, it may be 1 second flat.

    How would I do this in construct?

    If assigning percentages of probability aren't possible, then I'd be okay for now with just being able to have the game jump-to layouts randomly when the QB throws a pass.

  • random(1) would give you a 50/50 chance of either getting a 0, or a 1.

  • Here's one approach:

    1. First, you just set a value (global, anything) to random(100).

    2. Then you just do lots of events like this:

    Is value between 0 and 56 (System expression) -> Jump to layout X

    Is value between 57 and 57 -> Jump to layout Y

    Is value between 58 and 99 -> Jump to layout Z

    Of course there's multiple other ways to achieve this and you could even do some sort of loop to check things via private variables making it more easily customizable.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • Hey guys, thanks for the info. Do you think you can give me a short direction of where to start these operations you've described? I'm still new to this program so I'm not familiar yet with where everything is.

    All I see right now that even resembles where to start, would be the project folder that says "global variables" but beyond that I'm not sure what to do. So, just a small point-to to get me jumpstarted would be appreciated.

  • Hey guys, thanks for the info. Do you think you can give me a short direction of where to start these operations you've described? I'm still new to this program so I'm not familiar yet with where everything is.

    All I see right now that even resembles where to start, would be the project folder that says "global variables" but beyond that I'm not sure what to do. So, just a small point-to to get me jumpstarted would be appreciated.

    Create an event, for example a Start of Layout event. Then use a system action, then set value under global variables, and create the global variable from there, it can be either numerical or a string.

    You should probably get more familiar with the program and where things are before attempting to make anything but simple tests. The wiki has some info on what each part does and the majority of options and features.

  • Yeah, actually simple testing is all I'm doing at the moment...

    I learn better in directions and steps, so the Wiki's don't really help me (a number of the links are broken, too). They define different functions, but most of it is not relevant to my prototype or it's a lot more complicated than what I'm trying to do... what I'm doing is a bit unconventional to the standard games made with this type of program, and I think it's more efficient to express what I'm trying to do and have someone with experience with the program impart their best methods. I'd imagine some other new users will have similar questions so the information may be beneficial beyond my own project.

  • Did you check out the ghost shooter tutorial it will explain a lot of things.

    but to do what you want go into the Globalvariables manager and add a new GV called whatever you want.

    then make a new event that will trigger when the QB throws the ball. so a button press or something will do (us the mouse and Keyboard object to register button presses.)

    now in that event go to System>Set global var to Random(99)+1 (this will return a number between 1 and 100)

    now add the function object and create a new function called what ever you want. and in sub events under that function us the system compare global variable to what ever percent you want and then in that action have the go to layout system command.

    Now go back up to your trigger and add a call function UNDER the set random num.

    **Fake edit**

    You could also pass the function the randome(99)+1 and check function.param(1) in the compare condition.

  • Hey Aeal, that's some good info! Thanks. I've been going to work on it.

    I've posted a link to the .cap so you can get a full view of what I'm doing here:

    http://www.box.net/shared/c3xnl89vz4

    I've got a bit of this except I'm unclear on some things:

    now add the function object and create a new function called what ever you want.

    1. Do I add this as a new event?

    2. I'm not sure what function it's supposed to perform in regards to the process, so I'm not even sure what I would name it, but here is what I'm thinking... I see "on function", so my guess would be that in laymans relevant to the topic, it means "In regards to the function of: randomizing the jump-to's..."

    My global variable is named "Jump-To". So my "on function" would be "Jump-To", correct?

    and in sub events under that function us the system compare global variable to what ever percent you want

    In the pull-down menu under variable should I select my Global variable called "Jump-To"?

    Under "Comparison" should I select "Different to"?

    Under "Compare to", is this where I would input the percentage? if so, what would the equation look like?

    You could also pass the function the randome(99)+1 and check function.param(1) in the compare condition.

    Please forgive me... I honestly did not understand a word of that.

  • Hmmmm... here is something weird:

    I tried to set an event where pushing up on the right stick of the XBOX 360 controller would trigger a "go-to layout". But instead, it doesn't recognize the right stick, and when I move the left stick up and down it eventually jumps to another layout. lol. The left stick is taking over the command of the right stick. That's very odd.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)