The Daily Click ::. Forums ::. Klik Coding Help ::. Object specificness...
 

Post Reply  Post Oekaki 
 

Posted By Message

Lobot



Registered
  8/4/2010
Points
  465

WINNER GOTW AUGUST 2010ARGH SignEvil kliker
31st December, 2010 at 1:28:07 AM -

Hello. I've always had a problem which bugs me on almost every game I make-
How can you make loads of the same object on a level but have each one react to something individually? For instance, There is five of the same object, when the user clicks on one, a set of events occur- How do you make it only happen to that one?
Any advise would be very much appreciated.


 
n/a

OMC

What a goofball

Registered
  5/21/2007
Points
  3039

KlikCast Musician! Guy with a HatSomewhat CrazyARGH SignLikes TDCHas Donated, Thank You!Retired Admin
31st December, 2010 at 1:48:18 AM -

It depends on what you want to do.

The simplest of systems (assuming these events include more than one condition) would set a flag or alterable value. Then, if the flag is on, do stuff to it by comparing whether the object's flag is on for each condition. For example:

"Bob" flag 0 is on (Making it the first condition is a good idea)
+ Step counter = 0
>> Do stuff

"Bob" flag 0 is on
+ Step counter = 1
>> Do stuff

Each sets the object of focus to the right Bob before comparing other things. But for more complicated things, like if multiple objects have to be acted upon simultaneously, you may have to use spread values or something else. What exactly do you want to do?

 

  		
  		

Lobot



Registered
  8/4/2010
Points
  465

WINNER GOTW AUGUST 2010ARGH SignEvil kliker
31st December, 2010 at 2:11:13 AM -

So 'flags' are specific to each specific incarnation of an object?
What I want to do is- I have blocks that can be moved around with the mouse. They snap to a grid and are limited to 'free spaces' and can only move one space at a time. These limitations are made with a set of events. I want there to be many of these movable objects. The problem is when I have a 'set x/y position to x/y of "block" +-value' event, it doesn't know which block I'm on about...

What do you reckon?
Thanks for the help

 
n/a

Sketchy

Cornwall UK

Registered
  11/6/2004
Points
  2483

VIP Member
31st December, 2010 at 2:12:51 AM -

I'm going to post the same link I always post...
http://www.create-games.com/article.asp?id=1975


My top 3 quick tips:

1.) The order of events matters. The order of conditions matters. The order of values being compared matters.
X("ObjectA") > X("ObjectB") is NOT the same as X("ObjectB") < X("ObjectA")
Don't use "compare two general values" if you have multiple instances of an object.

2.) Store all object-specific information in alterable values/strings - not global values or counters (or flags - they're too hard to keep track of because they can't be renamed). Use lots of them. If an object is jumping, use an alterable value called "Jumping" and set it to 1 - then if you want to apply an action to only those objects that are jumping, you start by checking the value of "Jumping".

3.) Use fixed values or the spread value function to give each object a unique id#. Don't use the "spread value + fastloop" method unless you really have to.

Edited by Sketchy

 
n/a

Lobot



Registered
  8/4/2010
Points
  465

WINNER GOTW AUGUST 2010ARGH SignEvil kliker
31st December, 2010 at 2:34:19 AM -

Ah!
That article is awesome- of great help.
The event editor is more logic-orientated than I thought. I'll try again, speaking more nicely to it. hehe

Thanks Sketcky

 
n/a

Mark McCauley



Registered
  2/18/2009
Points
  263

Has Donated, Thank You!VIP Member
5th January, 2011 at 11:48:38 AM -

using a counter u can do this

-------CONDITION--------------------------------------------------ACTION--------------------------------

-----------------------------------------Activeobject1(Block)---------------------Counter---------------

if counter < number of blocks------------------------------------------------------------------------
+ pick block at random------------set value a of block to counter+1-------add 1 to counter---------
+ flag(0)block is off---------------set flag(0) of block on----------------------------------------



this would number all the blocks from 1 upwards

helpful?

Edited by Mark McCauley

 
http://www.reddwarf.co.uk/forum/messages.cfm?threadid=44227736-C46F-AC56-02EBA05285818C14

Sketchy

Cornwall UK

Registered
  11/6/2004
Points
  2483

VIP Member
5th January, 2011 at 3:01:15 PM -

Just so you know, the formatting in that post gets all messed up on small screens.
I'm reading it on a netbook (1024x600), and everything is too long to fit, so it wraps onto the next line. It's really hard to make sense of.

 
n/a

Mark McCauley



Registered
  2/18/2009
Points
  263

Has Donated, Thank You!VIP Member
5th January, 2011 at 3:44:51 PM -

Oh Ok , thanks for pointing that out.

(Block)=Activeobject1
(Countup)=Counter1

if (Countup) < number of (Block)
+ pick (Block) at random
+ flag(0)(Block) is off

then
set flag(0) of (Block) on
set value a of (Block) to (Countup)+1
add 1 to (Countup)

Edited by Mark McCauley

 
http://www.reddwarf.co.uk/forum/messages.cfm?threadid=44227736-C46F-AC56-02EBA05285818C14

Sketchy

Cornwall UK

Registered
  11/6/2004
Points
  2483

VIP Member
5th January, 2011 at 3:49:42 PM -

That's much better

 
n/a

GamesterXIII



Registered
  12/4/2008
Points
  1085

I am an April Fool
5th January, 2011 at 6:28:04 PM -


Originally Posted by Sketchy
Just so you know, the formatting in that post gets all messed up on small screens.
I'm reading it on a netbook (1024x600), and everything is too long to fit, so it wraps onto the next line. It's really hard to make sense of.



Actually I think its how the website handles the posts.

I'm on 1680x1050 and having the same problem.

 
n/a

Sketchy

Cornwall UK

Registered
  11/6/2004
Points
  2483

VIP Member
5th January, 2011 at 6:59:37 PM -

Oh, okay. Strange that Mark isn't having the same problem himself.

 
n/a

GamesterXIII



Registered
  12/4/2008
Points
  1085

I am an April Fool
5th January, 2011 at 7:53:59 PM -

Maybe its a browser thing? Chrome here

 
n/a
   

Post Reply



 



Advertisement

Worth A Click