I have a game where letter panels float down the screen, and they can either be shot with a missile or captured with a bubble to spell a word.
The problem i am having is that the collisions of the panels are not being detected very well. The missile will float well past the letters and then blow them up, or not detect at all.
all of the letters are their own panels, and there are 43 letters in the alphabet, and i use text.string arrays to cycle through the numbers to see if the letter has been hit. i use these strings to make statements that retrieve the coords of the letter panels, and compare the location with the location of the missile. This is only the portion of code where the missile collision is detected. The bubble detection is nearly identical.
the pos_y_array contains strings like "g1w_letter_pan.pos_y" to direct the code to each letter's pos_y, and pos_x_array is the same
enemy_pan_x_num and y_num are variables that take the x and y coords out of each letter panel, and use it to compare its position with the missile panel.
Code:
function set_collisions ()
{
collision_loop_count = 0;
while(missile_pan.pos_x != 1200)
{
if (collision_loop_count >= 42)
{
collision_loop_count = 0;
}
str_cpy(collision_string, "enemy_pan_x_num = ");
str_cat(collision_string, pos_x_array.string[collision_loop_count]);
str_cat(collision_string, ";");
execute(collision_string);
str_cpy(collision_string2, "enemy_pan_y_num = ");
str_cat(collision_string2, pos_y_array.string[collision_loop_count]);
str_cat(collision_string2, ";");
execute(collision_string2);
if (enemy_pan_x_num <= missile_pan.pos_x + 100
&& missile_pan.visible == on
&& enemy_pan_x_num >= missile_pan.POS_X - 125
&& enemy_pan_y_num >= missile_pan.POS_Y - 100) // enemy is hit
{
this part makes the ship dissappear and blow up, and start its path again.
break;
}
collision_loop_count += 1;
WAIT(1);
}
}
can someone please help me figure out how to make sure the collisions are detected in real time, and accurately?