Facebook Twitter YouTube Frictional Games | Forum | Privacy Policy | Dev Blog | Dev Wiki | Support | Gametee


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Defining a random x
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#11
RE: Defining a random x

Just be aware that if you plan on spawning an orb piece at random until all pieces are activated, there's an increasing chance that the RandInt() call will return a orb piece number which has already been used. This might cause player frustration.

The easiest way to do this is create a global variable string and use AddGlobalVarString with the string to add being ""+RandomOrbNumberVariable. This way it just concatenates the most recent orb piece set active to the string. As an example:

GVar "OrbPiecesActivated"
"1"
"15"
"152"
"1523"
"15234"

Before you want to spawn an orb, do a check to see if StringContains(GlobalVariableHere, ""+NewOrbPieceNumberHere) evaluates as true, and if it does, re-generate a new random orb number. This is a great example of why hard-coding is bad Smile You'll need a variable to store the randomly generated number temporarily so you can run the check, and if it passes you can then use that variable when spawning the piece.

In some other languages you have to cast the number a string, but luckily AngelCode supports string concatenation with the + operator. But don't try adding a string on to an integer variable. That won't work. You can however, add integers on to strings. It will just stick that integer on to the end of it.

(This post was last modified: 04-24-2012, 01:08 AM by palistov.)
04-24-2012, 01:06 AM
Find
Damascus Offline
Senior Member

Posts: 646
Threads: 118
Joined: Mar 2012
Reputation: 29
#12
RE: Defining a random x

No, no you misunderstand. They all represent the same orb piece. There's only going to be one available, it's just going to be in a random place when you start the level. That way if you're doing a second playthrough, or have watched a Let's Play, you're not guaranteed to find the item in the same place as you thought it was.

04-24-2012, 01:19 AM
Find
palistov Offline
Posting Freak

Posts: 1,208
Threads: 67
Joined: Mar 2011
Reputation: 57
#13
RE: Defining a random x

Ahhh I gotcha.

04-24-2012, 02:25 AM
Find




Users browsing this thread: 1 Guest(s)