Problem with Collision Mask

R

Rayos

Guest
Hello everyone,

I am a beginner user of this awesome engine GameMaker: Studio and I am trying from time to time to create something to play with. I am now making a simple Tetris clone but I am stuck at very stupid error. Don't know if this is a GameMaker error itself or I am doing something wrong but...

Every time when alarm[0] starts to work I am cheking a collision if my tetromino is colliding from the bottom with wall (obj_wall) or with tetromino that is already placed (obj_endBlock) using place_meeting. Everything seems to work fine until I rotate my tetromino using image_angle+=90... Then it appears that collision mask (checked as precise collision on whole sprite) is misplaced (?) one or more pixels to the right, because it is happening only when I am trying to put for example reverse L block on top of another tetromino like shown in the screenshot (painted red in this case, normally gray as it stoped moving).

Can somebody help me with this case? I know that I can create a 4 different sprites for each tetromino but in my opinion is waste of time and resources. Thank you in advance for any help!

Rayos
 

Attachments

Nocturne

Friendly Tyrant
Forum Staff
Admin
Don't rotate the collision mask. Use a different sprite so that collision mask is used. Why? Look:

upload_2016-8-3_23-24-13.png

By rotating the sprite, you are effectively shifting the pixels over and down because you can't have the origin in the middle of a pixel. So, yeah, make different sprite images for each rotation and use those instead.
 
R

Rayos

Guest
Thank you kindly for the answer! So there is no other way? I saw the other day a tetris made in full D&D and it seems to works perfectly fine with normal rotations :( ... Also, since all the pixels are moving in such way, doesn't that means that when I am rotating sprite 90 degrees, the mask is also moving like this, so it should be in the same position as the sprite itself? I am a little confused right now...
 
R

Rayos

Guest
Any help, please?

I saw, that this D&D tetris has a GML version. there it's using normal image_angle +=90 with collision mask just like me and it's working fine...
 

Bingdom

Googledom
You will want to have the collision mask 1 pixel smaller than the actual sprite all way around. I believe that objects still count as a collision when they don't overlap, just having no gap between the 2 objects. Correct me if i'm wrong. ;)
 
R

Rayos

Guest
Hey, thanks. I'll try when I came back from work :) In this case, I should have a seperate collision mask for each sprite, with collision being smaller 1px per edge than the actual sprite, right?
 

Bingdom

Googledom
Make 2 separate sprites, one for displaying on the game, the other for a collision mask(this is the one you make 1 pixel smaller per edge). Make sure to put the sprites in the exact same order, because when you change image_index, it will also change mask_index automatically. Also check that both their origins are centered. Lastly if you're not sure, you can change its collision mask through this:
upload_2016-8-5_23-39-52.png
 
R

Rayos

Guest
Sorry for post under post.

If I understand corectly, you are asking me to do a separate sprite mask for each tetromino for 4 different rotations, is it right? If yes, than this is just the case - I want to avoid adding 4 seperate sprites for every rotation, I just want to use image_angle :)
 
R

Rayos

Guest
I've added separate collision mask for each tetromino I have right now (T,L and Reverse L block) and now it's working even worse. Now it's stopping every time midair when find tetromino in right diagonal...
 

Attachments

R

Rayos

Guest
Done this already ;) I've grow tired of this problem and I've made finally separate sprites for each rotation and now I am chaning image_index instead of image_angle. Works fine.

But still it botheres me :/
 
Top