how can i make good mask for this sprites

J

Jaqueta

Guest
First of all, Welcome to GMC!

The problem is not only your mask, but it's this.
Code:
image_angle = obj_RightStick.normaldir;
//You see, when you change the image_angle, the mask also rotates with it.
//I recommend putting the draw_angle into a different variable and then use it on the Draw function.
And your collision code as well, if you want a bug-free top-down movement engine, I would suggest to do some more research. Take a look at Youtube for tutorials, or the MarketPlace and you might find something there ;D
 
A

ALI 1415

Guest
First of all, Welcome to GMC!

The problem is not only your mask, but it's this.
Code:
image_angle = obj_RightStick.normaldir;
//You see, when you change the image_angle, the mask also rotates with it.
//I recommend putting the draw_angle into a different variable and then use it on the Draw function.
And your collision code as well, if you want a bug-free top-down movement engine, I would suggest to do some more research. Take a look at Youtube for tutorials, or the MarketPlace and you might find something there ;D
https://www.dropbox.com/s/rz8azkzj9m6v5r5/problem_mask_kindafixed.gmz?dl=0
Adding a circle collision is doing great if you have movement like this.. Its not a perfect collision tho. ****s up when you have really small doors.
Jaqueta & iMilchshake thank you sooooo much for your help :)
 
J

Jaqueta

Guest
I have a nice collision script for you, BUT, there are two conditions when using it.
1º - The movement must be done using the speed variables.
2° - You CAN'T have "slopes" or irregular surfaces, but with rectangular solids, it works like a charm.

Well, to make the character move with the speed variables is pretty simple.
First you need to add HSPEED and VSPEED, just like you where doing with the X and Y variables, however this is your acceleration value, not total speed.
Now on the create, you must define a FRICTION value, remember, this value must be lower than the Acceleration Value.
Code:
friction=FRICTION_VALUE
Last but not least, you need to limit the speed, so the character won't be like sanic huehuehue...
There's a lot of ways of doing that, you can use a if statement:
Code:
if speed>MAXIMUM_SPEED then speed=MAXIMUM_SPEED
or you can use a clamp function
Code:
speed=clamp(speed,0,MAXIMUM_SPEED)
Now, the collision code, remember to make sure that the solid object is NOT marked as solid.
And on the player, you create a collision code with it.
And put this Code:

Code:
//Move to the previous position
x = xprevious;
y = yprevious;
//Slide
if not place_meeting(x+hspeed,y,other.object_index) //If there's nothing at his horizontal direction
{x += hspeed} //It moves him to the direction he's going
else {hspeed=0}; //If not, It set his HSPEED to 0

if not place_meeting(x,y+vspeed,other.object_index) //Same thing as before, but this time on Vertical
{y += vspeed}
else {vspeed=0};
If you have any questions, feel free to send me a PM or something like that. ;D
 
Top