The Daily Click ::. Forums ::. Klik Coding Help ::. How do i make a duplicate follow a duplicate?
 

Post Reply  Post Oekaki 
 

Posted By Message

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
25th March, 2007 at 19:29:59 -

I want to make a tank, with a cannon. two objects...
I set cannon position 0,0 from tank.

But what if i have 10 tanks and 10 cannons.
How do i make a duplicate follow a duplicate?

 
Code me a sausage!

Radix

hot for teacher

Registered
  01/10/2003
Points
  3139

Has Donated, Thank You!VIP MemberGOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!
25th March, 2007 at 21:33:45 -

One method is a fastloop with spread values.

But I think this is one of those things MMF can surprisingly handle automatically if you create a bunch of them and have a single 'set position' event. I wouldn't really trust it though.

 
n/a

JFrudy



Registered
  30/11/2006
Points
  103
26th March, 2007 at 00:36:36 -

yep, i'd do something with spread values

 
n/a

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
26th March, 2007 at 02:03:46 -

I think it goes something like this:

* Always
- Tank: Spread value 0 in alterable value A
- Cannon: Spread value 0 in alterable value A


Then, you make sure there are never too many or too few cannons:

* NObjects("Tank") <> NObjects("Cannon")
- Start loop "foo" NObjects("Tank") times

* On loop "foo"
* NObjects("Tank") > NObjects("Cannon")
- Create Cannon at (0,0)

* On loop "foo"
* NObjects("Tank") < NObjects("Cannon")
* Pick one of Cannon
- Cannon: Destroy


And then you do something like this, to position the cannons over their respective tanks:

* Always
- Start loop "bar" NObjects("Cannon") times

* On loop "bar"
* Tank: Alterable value A == LoopIndex("bar")
* Cannon: Alterable value A == LoopIndex("bar")
- Cannon: Set position to (0,0) from Tank


 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
26th March, 2007 at 02:04:02 -

If you have 10 cannons and 10 tanks then if you use the event:
Always set cannon to tank, it will work and it will put each cannon on each tank seperately. However if you don't have even numbers then odd things happen, which is why it is reccommended that you assign ID values to each cannon and tank object and then run a loop saying if their IDs are equal then set that cannon to its corresponding tank body.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
26th March, 2007 at 02:06:52 -

Or alternatively, you can also replace the last part with this:

* Always
- Cannon: Set position to (0,0) from Tank


But the spread a value/fastloop part helps if you're planning on having the cannons automatically fire at nearby targets and all that.

Edit: Agh, Andy beat me to it

Image Edited by the Author.

 
n/a

Don Luciano

Heavy combat pancake

Registered
  25/10/2006
Points
  380

VIP Member
26th March, 2007 at 08:10:16 -

Thx guys...

 
Code me a sausage!

WillWill

Give me stuff

Registered
  24/07/2006
Points
  552
26th March, 2007 at 13:12:30 -

In simple words, make each tank and cannon unique by giving them values that don't belong to the rest of them. The lazy way would be writing random(100000), but I guess you could do it differently.. As long as they stay unique.

 
http://www.morphboy.newgrounds.com/
^ Free tunes, as long as you contact me.

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
26th March, 2007 at 14:28:48 -

Ever heard of spread a value?

 
n/a

WillWill

Give me stuff

Registered
  24/07/2006
Points
  552
26th March, 2007 at 17:44:50 -

No, I am self-learned. Ever heard of giving me the opportunity to learn instead of throwing that comment?

Image Edited by the Author.

 
http://www.morphboy.newgrounds.com/
^ Free tunes, as long as you contact me.

AndyUK

Mascot Maniac

Registered
  01/08/2002
Points
  14586

Game of the Week WinnerSecond GOTW AwardHas Donated, Thank You!VIP Member
26th March, 2007 at 21:30:11 -

Well you've got the idea Willx2 but spreading value is a better way of doing it. It basically increments upward 1 from the number you choose to start with, with each object.
Thus giving each object something unique.

 
.

WillWill

Give me stuff

Registered
  24/07/2006
Points
  552
27th March, 2007 at 01:36:03 -

Yeh but they were talking bout giving an object the value from the total amount of objects, but when alot of objects are deleted there are gonna be duplicates?

I use a global value in my queue engine however that works like that.. It's a kind of engine that stores every recieved message and their parameters from clients in a MooGame network and executes them one by one with a String Parser.

 
http://www.morphboy.newgrounds.com/
^ Free tunes, as long as you contact me.

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
27th March, 2007 at 06:24:19 -

* Always
- Object: Spread value 0 in alterable value X

That makes sure all objects/instances/duplicates always have their own, unique ID. End of discussion?

 
n/a

Lazernaut



Registered
  08/09/2002
Points
  1103

VIP MemberThe Cake is a LieIt's-a me, Mario!Wii OwnerPokemon Ball!
27th March, 2007 at 07:14:05 -

wouldn't it be enough to spread the values once? it seems sort of wasteful to do it always..i mean, what's gonna chance the values once they're set?

 
n/a

alastair john jack

BANNED

Registered
  01/10/2004
Points
  294

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!VIP MemberMushroomI am an April Fool
27th March, 2007 at 07:56:35 -

Well once they're set, what will happen if some objects are destroyed! or new ones are created! well I guess you could just re-spread them when something like that happens instead of always spreading. but meh.. it seems safer to having them always spreading.

 
lol
   

Post Reply



 



Advertisement

Worth A Click