The Daily Click ::. Forums ::. Klik Coding Help ::. Spreading alterable values?
 

Post Reply  Post Oekaki 
 

Posted By Message

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
9th December, 2010 at 21:25:35 -

Ive been wondering this for quite some time, what does spreading an alterable value do, and how can it be used in game design? im just curious cuz ive never used it before.

 
[Game design makes my brain feel like its gonna explode.]

Fifth

Quadruped

Registered
  07/05/2003
Points
  5815

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
9th December, 2010 at 21:43:22 -

Spreading an alterable value is a really useful thing to learn. It gives each instance of the object a unique, sequential value starting at the value you say to spread. So, say, 5 objects set to spread value 0 would end up with the values 0, 1, 2, 3, and 4.

This is useful because it lets you refer to a single one of those objects based on the value it ends up getting. You can start a loop to run for as many times as there are objects, and then in each loop you only choose the object whose value is equal to the current loop number. Loop number 0 would pick object value 0 to act on, loop 1 would pick object 1, and so on.

It's handy for directing a whole bunch of the same objects at once, and aligning pairs of different objects together.
Among other things.

 
Go Moon!

OMC

What a goofball

Registered
  21/05/2007
Points
  3516

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
9th December, 2010 at 21:51:01 -

Spread a value "counts" an object.

If you have ten of the same active object and you spread Value 0 into its alterable value A, each one will have a different value. The first will have 0 (Since you passed in 0), the next will have 1, the next 2, and so on.

You can use it for a lot of things! Especially iteration. Here's an example: http://jollycrouton.com/Uploads/chain.zip

The expression: ((320-XMouse)*Alterable Value A( "Chain" ))/NObjects( "Chain" )+XMouse

Uses the chain link's alterable Value A to make each chain link's distance from the origin farther than the last's.

EDIT: Beat to the punch.

Edited by OMC

 

  		
  		

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
9th December, 2010 at 21:54:41 -

There's an article on the subject:
http://www.create-games.com/article.asp?id=1798

 
n/a

siven

I EAT ROCKS

Registered
  03/11/2008
Points
  604

Wii OwnerVIP Member
9th December, 2010 at 23:18:30 -

Ooooh i see, thats easy lol. Thanks a ton for the help, i didnt know thats how you made a chain like that, thanks! ill use this info to the best of my ability.

 
[Game design makes my brain feel like its gonna explode.]

Fifth

Quadruped

Registered
  07/05/2003
Points
  5815

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
9th December, 2010 at 23:51:04 -

See that you do!
Now that you have been inducted into the Order of the Alterable Value Spreaders, we will require great feats of Clickwork from you.

 
Go Moon!

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
10th December, 2010 at 01:24:08 -

BUT, you should also learn to take advantage of the way MMF2 matches objects automatically.
The spread value & fastloop combination tends to be over-used, but it should really be more of a last resort, as it can affect performance on slower computers if you have a lot of objects.
Spread value is still useful for lots of other things though.

eg.
My current project is a turn-based strategy.
I use spread value to give each unit a unique ID number.
When the player clicks on a unit (to select it), I set a global value ("SelectedUnit") to the ID number of the unit they clicked on.
Now, to make an event specific to only the selected unit, I can just add the condition:
Unit: ID = SelectedUnit

 
n/a

Silveraura

God's God

Registered
  08/08/2002
Points
  6747

Game of the Week WinnerKlikCast StarAlien In Training!VIP Member360 OwnerWii OwnerSonic SpeedThe Cake is a LieComputerChristmas Tree!
I am an April Fool
10th December, 2010 at 02:54:52 -

I know very well how MMF2 matches objects but unfortunately spread values is the only way I know to effectively assign sensors to a bunch of non-player controlled objects that all need to be able to properly interact with their environment and each other so they can tell the difference between one another and each interact differently depending on whose doing what and so on.
Very tricky stuff, and the performance issue does hurt a lot. I wish there was a more efficient way to do it, but I don't know of any. Especially without using an extension. Anyone? Ideas?

 
http://www.facebook.com/truediamondgame

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
10th December, 2010 at 13:40:08 -

Depends, im making a turn based game, and i can use a lot of loops without affecting performance at all, which i do. Whilst an rts or a shooter should resort to using only one active loop. Most people start loop based on number of objects in question, but you can gain a lot of performance by using only one set loop that is always running.
Always start loop "all" 200 times. So you can test anything with only one loop, with some grouped conditions aswell, as long as it doesn't go over the limit.

 
Code me a sausage!

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
10th December, 2010 at 15:19:37 -


Originally Posted by SiLVERFIRE
I know very well how MMF2 matches objects but unfortunately spread values is the only way I know to effectively assign sensors to a bunch of non-player controlled objects that all need to be able to properly interact with their environment and each other so they can tell the difference between one another and each interact differently depending on whose doing what and so on.
Very tricky stuff, and the performance issue does hurt a lot. I wish there was a more efficient way to do it, but I don't know of any. Especially without using an extension. Anyone? Ideas?



You need spread values, but maybe not the fastloops. Often you have no choice, but there are also people who use them for anything and everything involving multiple instances, and that's not good.

Embedded collision detectors can be useful - you don't need to worry about which detector belongs to which object, as they're both the same thing.
For testing background collisions, you could use the "collision mask".
As I said, automatic object matching is also very powerful if you use it well.
The ForEach extension should be more efficient than fastloops, but apparently it still has bugs.

 
n/a
   

Post Reply



 



Advertisement

Worth A Click