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


Messages In This Thread
Defining a random x - by Damascus - 04-23-2012, 06:07 AM
RE: Defining a random x - by Your Computer - 04-23-2012, 07:08 AM
RE: Defining a random x - by Damascus - 04-23-2012, 07:23 AM
RE: Defining a random x - by Your Computer - 04-23-2012, 08:03 AM
RE: Defining a random x - by Knittel - 04-23-2012, 01:19 PM
RE: Defining a random x - by Damascus - 04-23-2012, 08:01 PM
RE: Defining a random x - by Cranky Old Man - 04-23-2012, 08:07 PM
RE: Defining a random x - by overscore - 04-23-2012, 08:10 PM
RE: Defining a random x - by palistov - 04-23-2012, 08:40 PM
RE: Defining a random x - by Damascus - 04-23-2012, 10:53 PM
RE: Defining a random x - by palistov - 04-24-2012, 01:06 AM
RE: Defining a random x - by Damascus - 04-24-2012, 01:19 AM
RE: Defining a random x - by palistov - 04-24-2012, 02:25 AM



Users browsing this thread: 1 Guest(s)