Paper mario fangame
Would you like to react to this message? Create an account in a few clicks or log in to continue.

Engine Dev Log

Go down

Engine Dev Log Empty Engine Dev Log

Post by Gumbo Sun Feb 22, 2015 5:32 pm

Today and yesterday, I added pipes.

Engine Dev Log G8x0T

I tried to make them as accurate as possible to the pipes in ttyd, and that means making the lines thick, adding the shadow, and using the appropriate colours. I think I did a pretty good job.

As far as programming goes, here is the code for the pipe:

Code:

d3d_draw_cylinder(-24, -24, height, 24, 24, height-16, sprite_get_texture(sprite100, 0), 2, 1, false, 6);
d3d_draw_cylinder(-20, -20, height-16, 20, 20, height-16-40, sprite_get_texture(sprite98, 0), 2, 1, false, 6); //top of the middle section, this one has shadows, and is only the top half
d3d_draw_cylinder(-20, -20, height-16-20, 20, 20, z+20, sprite_get_texture(sprite106, 0), 2, 1, false, 6); //middle of the middle section, this one has no top or bottom lines or a shadow, and is full
d3d_draw_cylinder(-20, -20, z+40, 20, 20, z, sprite_get_texture(sprite106, 1), 2, 1, false, 6);//bottom of the middle section, this one has a bottom line but no top line and is only the bottom half
//0 = nolines
//1 = bottom lines
//2 = top lines
d3d_draw_floor(-24, -24, height, 24, 24, height, sprite_get_texture(sprite104, 0), 1, 1);
d3d_draw_floor(-24, -24, height-16, 24, 24, height-16, sprite_get_texture(sprite107, 0), 1, 1);

I eye-dropped the pipe colours straight from TTYD screenshots, too.

The pipe is split into what should be considered 6 pieces. I'll start from the top down.

The top is actually just a 48x48 image of a hexagon, that looks like the top of a pipe. The cylinder below this is open, because in game maker you can only choose the texture of the sides of cylinders, not the top or bottom. So I had to make a floor on top of it.

The next segment is the top part of the pipe, obviously. It's a 48x48 cylinder with 6 sides, textured with a picture of what is essentially a 3 panel 256x256 image of dark green, green, dark green, surrounded with thick black lines.

The next part would be the same thing as the first part, only there's no black hexagon in the middle of the green hexagon, and it's below the second part of the pipe. This is so that if you somehow manage to look up, from the bottom of the pipe, you don't see right through the open cylinder and into the bottom of the first piece.

These next 3 parts have got to be the most interesting, in my opinion. At first I only had 1 part for this whole thing, but when I tried to make the pipes taller, I realized that it would stretch the texture. That would stretch the shadow too much, and the lines at the bottom and the top of the pipe would become thicker/thinner(I can't remember which). This meant I had to add half segments that were always a constant size at the top and the bottom, so that they would never stretch. And then I added the middle segment, which is literally just the same as the top of the pipe, but it doesn't have any lines on the bottom or top of the texture. Making it taller does not stretch the side of the lines visibly.
Gumbo
Gumbo
Admin

Posts : 20
Join date : 2015-02-18
Age : 27
Location : Canada

https://starlessky.forumotion.org

Back to top Go down

Engine Dev Log Empty Collisions

Post by Gumbo Sun Feb 22, 2015 5:47 pm

As far as collisions go, it's going to be harder than I wish it would be.

I could just use P3DC DLL, but I've tried that in the past and just... Just.... I just.... ................ no

I've come up with my own solution, but it's not finished yet.

It's this:

Code:

z+=zspeed;
zspeed-=zgravity;

if z<=0
{
zgravity = 1;
zspeed=0;
z=0;
}

if z>=current_object_over.z && z<=current_object_over.height && zspeed<0 && collision_circle(x, y, 16, current_object_over, true, true)
{
zgravity=1;
zspeed=0;
z=current_object_over.height;
}

It essentially gets the object ID of the object mario is 'over' on the x and y axiss's's''s', and then it checks if you're both FALLING and INSIDE of the object. If you are, it stops you, and puts you on top of the object. This is flawed because of two reasons:

1) If you have two objects in the same place, but at different heights, it only gets the ID of one of those objects, meaning you can only go on one of them. If you try going on the other one, you just fall through it.

2) Imagine you do have a solid object. If you run into it and jump, on your way down you'll end up teleporting on the top of it. Think about it. You're both falling, colliding with the object, and 'inside' it (inbetween the bottom of it and the top of it).

Problem 1 I've already come up with a solution to, which is to only basically have the object's collision mask exist when the z of mario is between the top and bottom of it. That way, it won't get the object ID of an object you're 'colliding with' on the xy axis if you're not about to fall on it, and will get the object ID of an object that's above or below that object if you're about to fall on THAT one. That's the best way I can explain it.

Problem 2 I have yet to come up with a solution for, but I haven't given it much thought. Really, my priority should be getting XY collisions sorted out, since I have nothing for that yet. You can literally walk inside of the pipe, but you cant collide with it. XY collisions in game maker become harder than Z collisions do when you move to 3D or top down, which is something I hadn't anticipated 2 years ago when I started working on this engine.
Gumbo
Gumbo
Admin

Posts : 20
Join date : 2015-02-18
Age : 27
Location : Canada

https://starlessky.forumotion.org

Back to top Go down

Back to top


 
Permissions in this forum:
You cannot reply to topics in this forum