Godmaster Posted May 4, 2007 Report Share Posted May 4, 2007 I'm here again with some questions, so let's start. I was testing the old Dami' 360 engine, when I got curious to enlarge/shrink the main character, like Chaotix and Sonic CD. This could be useful to make a stand-up collision, because the main one is 32x32 px. I looked for the constants parameters on proprieties, then I changed the mask radius, and it resulted in a messed up collision. So, Anybody knows a way to enlarge/ shrink masks and make crouch/ stand-up collisions? Link to comment Share on other sites More sharing options...
Godmaster Posted May 5, 2007 Author Report Share Posted May 5, 2007 er... anyone? Link to comment Share on other sites More sharing options...
Kain Posted May 5, 2007 Report Share Posted May 5, 2007 In the global constants (Global Game Settings [in the left sidebar] -> Constants), you can see Dami has a constant called "mask_radius". 99% of the collision statements are based off of this constant. If you got rid of the constant, and added a variable "mask_radius" inside the Player object, then you could change the mask_radius whenever you want. The smaller the mask_radius, the smaller the object. However, there are two more thing that are based on size that don't use mask_radius. They are the MaskMain sprite and the horrizontal_space argument for the calculate_angle script. For the latter, you can just change the code : angle=calculate_angle(angle,8,obstacle_layer | high_layer | low_layer); In the Game Motion part of the Step event to: angle=calculate_angle(angle,mask_radius * 2/3,obstacle_layer | high_layer | low_layer); And that should work well enough. For the MaskMain, you have to construct a mask that is a solid circle of radius 'mask_radius' and change the mask accordingly in the collision_sensor_main function. Or better yet, you could just change the collision_sensor_main function to work with a circle collision. That is, replace the non-commented part of the collision_sensor_main script to: check=argument0; if ((check&obstacle_layer)==obstacle_layer && collision_circle(x,y,mask_radius,obj_walls,1,0)!=noone) return true; if (layer==0 && (check&high_layer) && collision_circle(x,y,mask_radius,obj_hlayer,1,0)!=noone) return true; if (layer==1 && (check&low_layer) && collision_circle(x,y,mask_radius,obj_llayer,1,0)!=noone) return true; return false; Anyway, I can't garentee the same concepts will work for very small radiuses, but that's how you make sonic smaller to the collision engine. As for crouch/standup collisions, you'd have to make your own algorithms for them. I'm not sure the best way to go about them; it depends on what situation you expect to happen and how you want to handle them. Link to comment Share on other sites More sharing options...
Xoram Posted June 16, 2007 Report Share Posted June 16, 2007 I have this implemented in my engine. I simply created lots of different circle sprites with different diameter, starting from 64 and moving down with an interval of 2; 64, 62, 60, 58, etc... You sacrifice some memory, but in the end it ought to work faster than the collision_circle method. Then, depending on an enlargement factor ranging from 0.4 to 2 the engine determines which sprite mask to use for which sensor and calculates the position of them. You don't have to create all these sprites by hand like I did; instead you can create a function that does it for you by first drawing the circles on a surface and then saving the surface as a sprite. Link to comment Share on other sites More sharing options...
Andrew Posted June 17, 2007 Report Share Posted June 17, 2007 Should also mention that R&D isn't the Help Forum. Link to comment Share on other sites More sharing options...
Godmaster Posted June 20, 2007 Author Report Share Posted June 20, 2007 I have this implemented in my engine. I simply created lots of different circle sprites with different diameter, starting from 64 and moving down with an interval of 2; 64, 62, 60, 58, etc... You sacrifice some memory, but in the end it ought to work faster than the collision_circle method. Then, depending on an enlargement factor ranging from 0.4 to 2 the engine determines which sprite mask to use for which sensor and calculates the position of them.You don't have to create all these sprites by hand like I did; instead you can create a function that does it for you by first drawing the circles on a surface and then saving the surface as a sprite. Yeah, but these circles looks much more bigger than the standard one (25x25 pixels), and I don't know if this would work precisely on movimentation, like collisions become glitchy because of constant mask changes. Link to comment Share on other sites More sharing options...
Xoram Posted June 20, 2007 Report Share Posted June 20, 2007 If you change the mask size and distance before you check for any collision, it shouldn't glitch. I don't understand what you mean with that they look much bigger than the standard one. If you want Sonic to be enlarged with a factor 2, meaning that you double the height, you simply enlarge the masks gradually until they are twice as big and move them outwards until their distance to the center of Sonic is twice as long. [Edit] You should also make so that the enlargement stops if both the bottom and top sensors are colliding with an obstacle. Same thing goes for the left and right sensors. Link to comment Share on other sites More sharing options...
Recommended Posts