Powerful Instance Manipulation
Author: | MBK
|
Submitted: | 27th March, 2009
|
Views: | 4733
| Rated: |
|
|
Everyone likes to write these fantastic articles, so I figured I should make one.
I don't think Dines has made an article of this, but it is about something that he said ... and this is what he said under Sketchys article about Duplicates....
DeadManDines:
"One crucially important point which I think people missed from reading my own article on this subject, and which isn't mentioned in this one, is thus:
USE ALTERABLE VALUES!!!
It is MUCH, MUCH easier to handle multiple objects if you design a simple set of events to define states and properties for your objects and record them in alterable strings and values.
Then all you have to do when you code your behaviours is ask MMF whether a certain property is set to YES or NO. Like "Is standing on ground", "Is jumping" and so on. Then ALL objects who are jumping will be selected, or ALL objects who are standing on the ground.
In addition, to avoid the object focus problems mentioned in this article, use Immediate If object. It works this way (pseudocode):
******************************************
ALWAYS *
--- Object A: Set 'Some Property' to: *
*
if ( value("OBJECT A") < value("OBJECT B") ) { *
"YES" *
} else { *
"NO" *
} *
***************************************
Maybe I'll need to make an example, but this method has litterally revolutionised the way I code."
MBK:
Notice the part surrounded by asterisks. This is the exact thing that I finally came up with to solve a visual layering problem with TGF1 instances (aka duplicates). If only I had noticed Dines wonderful words long ago ...
It is a powerful bit of code that can be used for many things.
The thing about it is to make sure you order everything correctly, because one little thing being in the wrong order will mess it up. You'll need to understand how TGF or MMF is processing the logic.
Here's how to make layering in TGF1 without fastloops:
0 = 0 ---> set value B of Platform and Platform Shadow to their respective Y
positions -31 (the platform width is 32)
0 = 0 ---> set value B of Character Shadow to Y of Character Shadow
Alt Val B of Plat
and PlatShadow
are > Alt Val B ---> Bring Platform and PlatformShadow to Front
of Char Shadow
Alt Val B of Plat
and PlatShadow
are < Alt Val B ---> Bring Platform and PlatformShadow to Back
of Char Shadow
It's very simple once you understand the order that everything must go in.
But, I was stuck on a problem for a very long time because I tried this before in the wrong order, so ruled it out as one of TGF1's bugs that kept it from being possible to do that way. If I had gotten the order right in the first place, it would have been solved long ago. Something good did come out of it though, because I re-did the entire 2.5d code over and over because of that and a few other glitches. The result of all the re-doing is a fairly organised method, nicely worked out, with some decent gravity for the jump, and all the glitches solved.
I hope this article has helped some of you.
Check out my Project page for 2.5d Platforming! ... I'm going to add a few more things to this finely tuned simple bit of code, then I'll place it there for you all to enjoy. I expect some nice Beat-em-up games to start getting made once I post my bit of code though. It should make creating beat-em-ups fairly simple.
Or so I hope anyway.
|
No comments have been posted for this article.
|
MBK
Registered 07/06/2007
Points 1578
|