zorder automatically set for you

You must understand the Game Editor concepts, before post here.

zorder automatically set for you

Postby DocRabbit » Sat Apr 28, 2007 12:24 pm

For those who don't want to fool with figuring out zorder by position, try this code to set it on launch by position. In other words, object near the top are farther away and farther down in the order. objects in front of your player appear over your player. This works with view parented to your player, or using the smooth scrolling method mak describes in this area. For static actors, like trees, rocks, etc., place the call to global code in the actor create call. For mobile actor (player) place call in draw actor.

Global code:
Code: Select all
void stackit(){
ChangeZDepth("Event Actor", ((y/240)+1)*.5);
              }

The 240 is actually half the window size, so adjust this for your window.

player->Draw Actor script:
Code: Select all
stackit();


tree->Create Actor script:
Code: Select all
stackit();


Everyone may already know this and be using it, but I haven't seen it posted anywhere and may not be the right way to do it, but it works for me and I thought maybe someone else might find it useful. :)
User avatar
DocRabbit
 
Posts: 114
Joined: Fri Oct 27, 2006 2:56 am
Score: 10 Give a positive score

Postby Fuzzy » Sat Apr 28, 2007 7:35 pm

Good job. Probably a good place to post something that I use..

Put this in a text file then load it as global code.

#define HIDDEN -100
#define BACKGROUND 0
#define EARTH 0.1
#define GRASS 0.2
#define PAVEMENT 0.3
#define FOUNDATION 0.4
#define OBJECT 0.5
#define CREATURE 0.6
#define PLAYER 0.7
#define WEATHER 0.8
#define CLOUD 0.9
#define HUD 1.0

Used in conjunction with DocRabbits code, you could sort everything from top to bottom of the screen, using my #defines to sort them according to type.

One point for DocRabbit!
Mortal Enemy of IF....THEN(and Inspector Gadget)

Still ThreeFingerPete to tekdino
User avatar
Fuzzy
 
Posts: 1068
Joined: Thu Mar 03, 2005 9:32 am
Location: Plymostic Programmer
Score: 95 Give a positive score

Postby Game A Gogo » Sat Apr 28, 2007 11:48 pm

interesting to both of you!
DocRabbit, that method is very useful for RPGs!
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby DocRabbit » Sun Apr 29, 2007 2:21 am

After some trial and error using my code, I have come up with a couple of revisions that could be handy to keep player planted on ground and score planted above. Just use if statements to evaluate Global code for <0 and >.999 and force them to one or the other. That way score type can be 1.000 and float over all, and ground can be 0 and player won't disappear moving up if screen scrolls on big playing field.
User avatar
DocRabbit
 
Posts: 114
Joined: Fri Oct 27, 2006 2:56 am
Score: 10 Give a positive score

Postby Game A Gogo » Sun Apr 29, 2007 2:30 am

yes, useful again ^^
I remember me using something similar.
Programming games is an art,
    Respect it.
User avatar
Game A Gogo
 
Posts: 3466
Joined: Wed Jun 29, 2005 10:49 pm
Location: French Canada *laughs*
Score: 181 Give a positive score

Postby Sgt. Sparky » Wed May 02, 2007 9:49 pm

Game A Gogo wrote:yes, useful again ^^
I remember me using something similar.

I made my own zdepth calculation for my trees in my 3D verison(it was all calculation of positions on canvas and scale) and in my other fake 3D version that did not scale. :D
Image
Random Links:
viewtopic.php?p=19474#19474
Right now (10/14/2009) I'm working on some C++ projects, but I might be able to help if you have some Game Editor questions. :)
User avatar
Sgt. Sparky
 
Posts: 1850
Joined: Sat Oct 07, 2006 5:28 pm
Location: Somewhere out there, beneath the pale blue sky...
Score: 236 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron