Posted By
|
Message
|
Lobot
Registered 04/08/2010
Points 465
|
31st December, 2010 at 01:28:07 -
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 21/05/2007
Points 3516
|
31st December, 2010 at 01:48:18 -
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 04/08/2010
Points 465
|
31st December, 2010 at 02:11:13 -
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 06/11/2004
Points 1971
|
31st December, 2010 at 02:12:51 -
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 04/08/2010
Points 465
|
31st December, 2010 at 02:34:19 -
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 18/02/2009
Points 291
|
5th January, 2011 at 11:48:38 -
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 06/11/2004
Points 1971
|
5th January, 2011 at 15:01:15 -
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 18/02/2009
Points 291
|
5th January, 2011 at 15:44:51 -
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 06/11/2004
Points 1971
|
5th January, 2011 at 15:49:42 -
That's much better
n/a
|
GamesterXIII
Registered 04/12/2008
Points 1110
|
5th January, 2011 at 18:28:04 -
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 06/11/2004
Points 1971
|
5th January, 2011 at 18:59:37 -
Oh, okay. Strange that Mark isn't having the same problem himself.
n/a
|
GamesterXIII
Registered 04/12/2008
Points 1110
|
5th January, 2011 at 19:53:59 -
Maybe its a browser thing? Chrome here
n/a
|
|
|