• Hey Guest! Ever feel like entering a Game Jam, but the time limit is always too much pressure? We get it... You lead a hectic life and dedicating 3 whole days to make a game just doesn't work for you! So, why not enter the GMC SLOW JAM? Take your time! Kick back and make your game over 4 months! Interested? Then just click here!

Legacy GM Drawn Circle Collision Mask

C

Chatterb0x

Guest
Hello,
Simple question, though it's never come about until now. Can objects without assigned sprites have collision masks? I'm using draw_circle() and draw_set_circle_precision() and would like to:
  1. Determine the polygons in draw_circle().
  2. Know if draw_set_circle_precision even affects drawn objects.
 
D

DarthTenebris

Guest
Can objects without assigned sprites have collision masks?
Yes it can. I believe there is a property called sprite mask - this defines the collision mask. Even if the object has no sprite to display, if it has this mask I think it should still register collisions based on this mask. If there is a sprite to draw, it will prioritize the mask, if one isn't provided then it will assume the drawn sprite to be the mask.

I don't know how to count the polygons of the drawn circle, but I think draw_set_circle_precision(); will only take effect in the next draw loop of a drawn instance - and even then, I don't think it'll be a performance issue since the instance is not drawing a circle using such a function.

Hope I helped :)
 

NightFrost

Member
You can change an object's mask in the object properties window, it defaults to <same as sprite>. Runtime, you can change an instance's mask using mask_index.
 

TheouAegis

Member
If they're both circles, then the formula is

collision = point_distance(x1,y1,x2,y2) < r1+r2

where r1 and r2 are the lengths of the radii of each circle.
 
C

Chatterb0x

Guest
Thank you for lighting my path. I'm making a breakout style game. I've tried all these methods and none seem to work. :confused:
 
C

Chatterb0x

Guest
Here's the code I'm using currently.
Code:
collision = collision_circle(x,y,12,obj_block,true,true);
          if(collision){
          move_bounce_solid(true);
          }
It won't bounce off obj_block. Why?
(I've tried variations where collision = @TheouAegis code or point_in_circle(). )
 
Last edited by a moderator:
C

Chatterb0x

Guest
Sorry for the triple post. I want future programmers to see the chain of thought and events.
move_bounce_solid() has been replaced with motion_set().
Code:
//Collision.
collision = collision_circle(x,y,12,obj_block,true,true);
            if(collision){
            motion_set(-direction,5);
            }
This works!
 

TheouAegis

Member
Was your block even set to solid? That's the most obvious reason I could think of that your first code didn't work.
 
C

Chatterb0x

Guest
In truth, it's easier to make your own ball sprite. My rationale was that GM:S draw functions are more precise. How much more precise would it have been? I've since made a 24x24 ball and it looks pretty identical.
 
Top