Nifty Engine Trick
Author: | skn3
|
Submitted: | 28th July, 2002
|
Views: | 5514
| Rated: |
|
|
Welcome to the wonderful world of making engines. By now you probably have thousands of detectors,.. you have over come those annoying position player at x,Y of object leaving a nasty offset bug. AND!, many other problems.
Ok, here comes my article reason.
So many people use seperate active objects to detect collisions. This is good and all, but highly wastefull of a key feature in click. First of all if you use seperate objects, it means no multiple's of the character/item that has the custom movement. Aswell as that, its ugly.
Ok, the solution. If you didn't already know, mmf,tgf,k&p and most program languages in whatever form they come in, will position everything on screen do all your calculations etc .
THEN
draw everything.
So how does this benifit me ?
Well, what this means is that you can do as much as you want in events, and it will only draw the result for that cycle of the program, once everything's done !
Again how can i use this ?
Well your detector objects are positioned say 32 pixels to the right of your player .
All you do is move the actualy player 32 pixels, test for collisions and what ever, then move it back 32 in the same loop.
Something liek this in the events
event 1
if flag 0 off
---set player x=player x + 32
---flag 0 on
event 2
if flag 0 on
+If player NOT overlaps background
---flag 0 off
event 3
if flag 0 on
+If player overlaps background
---set player x=player x - 32
---flag 0 off
try this out, and try putting a background object in the players path . to the right.
You will notice that it moves like normal until it hits a background.
AH HA !, amazing you made a detector, without using a detector.
Once you have mastered this, you can use it for absolutly everything.
Anyway thats all, and excuse my spelling
|
|
skn3
Registered 05/01/2002
Points 1179
|