Platform X Entity display

Piccolo

Well-known member
I was wondering if there was some kind of working way to correctly display/hide an entity based of his relative position to an obstacle.

platform1.png


platform2.png


I know I can create something similar to this via tricky scripts & "fake" entities usage, but it's quite painful  :'(
 
I asked for help about it in the times of "Lavalit"
But no solution. The position of offset (in X) will determine how character is displayed or hide by ofstacle/plateform. :-\

I think it's a matter of engine since the sprite is 2D anyway.

If someone have a solution, I'm interested as well.
 
nedflandeurse said:
The position of offset (in X) will determine how character is displayed or hide by ofstacle/plateform....

That is absolutely wrong. The Z position of two objects determines their drawing order, not X, and you can override this on a case basis with setlayer.

The problem, which I'm sure Piccolo understands and we tried to explain to you several times, is that the actual entity (and thus its coordinates) vs. the visual representation (sprite) have NOTHING to do with each other. Sprites don't "exist". They don't occupy space, they don't have collision - they're nothing but drawn in graphics with no effect at all on the game play.

In this case, that box has one location that is in effect a single pixel on screen, while the visual sprite is massive. There is no silver bullet for this in any engine without complicated scripts and platforming. That's why you don't often see huge objects or platforms like this in sprite based games with controllable Z movement, and when you do, they are almost always canted left to right rather than right to left is this one is.

Sorry Piccolo - there's really no getting round the complexity. :(

DC
 
Damn.

Now that you mention it, it's true that games that handle this correctly have no controllable Z movement.

Well at least technically it is possible to achieve. In fact I already did it for the rectangular platforms in my "clown" stage. But the technique I used involves decomposing the obstacle and sacrificing shadow, which is another problem. That's why I created this topic before creating new levels with such methods.

I'm working on a new workaround using wall, panel, scripts and fake entities. Here's hoping I'll get satisfying results with that.
 
Sorry, I don't know why I typed "X" since it's the horizontal axis.

I might have a solution, but it will not work with this "Oblique projection"
 
maxman said:
I wonder if setlayer for that huge platform could work. (I fear it won't.)

I guess it would create either picture 1 or picture 2 effect.

I've come up with a solution. It's certainly not the best nor the most economic but I think I'll continue with this one, because I want to have shadows.

- Platform as platform is created via wall
- Platform as sprite is drawn on panel
(These two points allow shadow drawn by the engine)

- Platform as sprite is also drawn via two entities. Basically, one of these entities allow proper masking when player is in front and on the left side of the platform, while the other allow proper masking when player is behind and on the right side.
- Both of these entities become invisible when player altitude > platform wall altitude. What is visible in these conditions is the platform drawn on the panel (which "support" shadows).
- In addition, the first entity become invisible when x distance from player is greater than a certain value. So that it doesn't mask the player when he is on the right side of the platform.

The main drawbacks of this method are that it's not global and specific to one entity (and that you have to draw the platform on the panel if you want shadows). The main benefits are that you don't need to edit sprites and you still have shadows.

For a global method (see my clown stage) you'll also need to have mutiple entities but each of these entities should draw a part of the platform sprite.
 
Piccolo said:
maxman said:
I wonder if setlayer for that huge platform could work. (I fear it won't.)

I guess it would create either picture 1 or picture 2 effect.

I've come up with a solution. It's certainly not the best nor the most economic but I think I'll continue with this one, because I want to have shadows.

- Platform as platform is created via wall
- Platform as sprite is drawn on panel
(These two points allow shadow drawn by the engine)

- Platform as sprite is also drawn via two entities. Basically, one of these entities allow proper masking when player is in front and on the left side of the platform, while the other allow proper masking when player is behind and on the right side.
- Both of these entities become invisible when player altitude > platform wall altitude. What is visible in these conditions is the platform drawn on the panel (which "support" shadows).
- In addition, the first entity become invisible when x distance from player is greater than a certain value. So that it doesn't mask the player when he is on the right side of the platform.

The main drawbacks of this method are that it's not global and specific to one entity (and that you have to draw the platform on the panel if you want shadows). The main benefits are that you don't need to edit sprites and you still have shadows.

For a global method (see my clown stage) you'll also need to have mutiple entities but each of these entities should draw a part of the platform sprite.

hiihihi
Piccolo I advice you a setlayer game!  ;)
 
Just got up (3 hours ago). The experiment took me 4-5 days to try to fix it. I made it based on White Dragon's post which was a clue for mentioning a setlayer game.

OK. I can tell you how I do that platform. First off:

1. You need to have an original platform sprite so you can platform-ize that as a platform entity as base or template. I did name a template entity in this code here:

Code:
name  wsample
type panel
shadow	0
facing	1
antigravity 100
subject_to_wall 1
subject_to_platform 1
subject_to_obstacle 1
gfxshadow 1


anim	idle
	loop	1
	delay	120
	offset	149 199
	platform	149 204 -77 -147 191 121 70 130
	frame	data/chars/misc/wsample.png

And this is the original platform sprite:

wsample.png


2. Of course, an original sprite overlaps entities on both left and right sides because it is an overlapper for entities to fall or walk around. To fix it, you need to separate one platform sprite into two halves by using GIMP or any kind of photoshop program, but it doesn't have to be exactly half in splitting them in measurement. I did use FG color to clear off for separation. I don't recommend editing and saving it in Paint because it will revert to RGB mode (so you'll have to start over) when opening any photoshop program. Look at these two for example:

plathalf.png


plat2.png


3. Now that I indicated you the two pictures, the first one is an overlapper just like the original platform sprite I mentioned above, and the second one, you need to use setlayer for it so it doesn't overlap on the right side (look at the shot below). BTW setlayer is a little bit tricky because it's like z but for mostly entities. You're gonna make the back side cover itself while the front will be uncovered. It's how setlayer is set. Also, you need to create those two split ones as entities.

mybor_0014.png


Here're the codes for the two split entities:

One for the first image above:
Code:
name  plathalf
type none
shadow	0
facing	1
gfxshadow 1
antigravity 100
subject_to_wall 1
subject_to_platform 1
subject_to_obstacle 1


anim	idle
	loop	1
	delay	120
	offset	149 199
	platform	149 204 -77 -147 191 121 70 130
	frame	data/chars/misc/plathalf.png

The other one for the second:

Code:
name  plat1
type panel
shadow	0
gfxshadow 1
facing	1
antigravity 100
subject_to_wall 1
subject_to_platform 1
subject_to_obstacle 1
setlayer 51



anim	idle
	loop	1
	delay	120
	offset	149 199
	platform	149 204 -77 -147 191 121 70 130
	frame	data/chars/misc/plat2.png

Now that I included the codes for those two, you don't have to have all of them especially two being platformed. One of them will need platform for the others but it's up to you if you leave those two entities with two platforms.

The two pictures, I think, need to have the same pixel measurement and offsets so they can get positioned well.

(Funny thing is, type doesn't matter to me to consider whether it's panel or none for platforms, but I always use none type.)

4. You place your separate platforms in the same coords and scrollpos (at) in stage. Try to make the one entity (plathalf) come first before the other. The first one being spawned will overlap the second.

Example:
Code:
spawn plathalf
coords 180 230
at 0


spawn plat1
coords 180 230
at 0

That's how I do it.

White Dragon said:
Good work maxman!!

Thanks White Dragon. :)

White Dragon said:
Piccolo said:
White Dragon said:
hiihihi
Piccolo I advice you a setlayer game!  ;)

What do you mean ? Using setlayer and changing it when "necessary" ? Did you use such a technique to solve this problem in your mod ?

No divide it into trangles and set the right layer for these triangles ;)

Like he says, divide into triangles, but I split them for separation.
 
Ok thanks for the full explanation. That's a similar technique to what I used for the clown stage, except platform parts had different offsets (because I wasn't using setlayer). Mixing all these ideas I should be able to come up with a valuable solution for what I need.
 
No problem.

Yeah, setlayer was tricky for me to understand when I first learned about it. That platform you posted in your first post is and looks tricky to do. I don't know how well you could handle that difficult platform due to its sides.
 
Yeah Ned, mine works. ;) I had been trying to fix it for 4 or 5 days (with countless tries) for Piccolo. It was tough at first, but when I got to that method of splitting later on, it works. :)

Try to split them in a simple way.

EDIT: Ned, I was wrong. If you're going to use the ring, then you don't need to split in half. My help was meant for Piccolo, but for you, no need to split since you have the ring. I'm very sorry for my mistake, man.
 
maxman said:
Yeah Ned, mine works. ;) I had been trying to fix it for 4 or 5 days (with countless tries) for Piccolo. It was tough at first, but when I got to that method of splitting later on, it works. :)

Try to split them in a simple way.

OK,
Say me if I undertand right. The hard part is tweaking both sprite shapes, right?

BTW : it might be used as a tutorial.
 
Back
Top Bottom