AreThingsOverlapping(Overlay,Overlay)

Started by Rocco, Sat 04/02/2006 17:20:48

Previous topic - Next topic

Rocco

Is there such a function, to make an collisionsdetection between Overlays??
Or a workaround?

monkey0506

For AGS versions 2.7 and later you might be able to do it by checking their X/Y properties...

Pumaman

No, there isn't. You could use the X/Y properties but since the Width and Height aren't exposed, it would be difficult to do a proper check.

Mind if I ask why you want to do collision detection with overlays? It would seem more appropriate to use an Object or Character if that is required.

Rocco

because im trying to do a arcade game module. - coding competition
and a module makes only sense if others can customize this as much as possible.

So all is generated with overlays, or is there another possibilty to access sprites and make them to objects or characters on the fly?

I have functions like:

Code: ags
 
function SetPlayerSprites(int vehicle_sprite_slot, int shoot_sprite_slot)
{
Ã,  
Ã,  vehicle.vehicle_sprite = vehicle_sprite_slot;
Ã,  vehicle.width = GetGameParameter(GP_SPRITEWIDTH, vehicle_sprite_slot,0 ,0);
Ã,  vehicle.height = GetGameParameter(GP_SPRITEWIDTH, vehicle_sprite_slot,0 ,0);
Ã,  vehicle.shoot_sprite = shoot_sprite_slot;

}

function game_init
{
Ã,  Ã,  vehicle.vehicle_graphic = Overlay.CreateGraphical(system.viewport_width/2, system.viewport_height - 10, vehicle.vehicle_sprite,true);
Ã,  Ã,  vehicle.enemy_graphics[0] = Overlay.CreateGraphical(100, 100, vehicle.enemy_sprites[i], true);
}

or for shoot generation:
Code: ags
 
if (shoots_active < MAX_SHOOTS) 
		{
Ã,  Ã,  Ã, // generate shoot
Ã,  Ã,  Ã, int i = 0;
Ã,  Ã,  Ã, while(i < MAX_SHOOTS)
Ã,  Ã,  Ã,  {
Ã,  Ã,  Ã,  Ã,  if(!current_active_shoots[i])
Ã,  Ã,  Ã,  Ã,  Ã, {
Ã,  Ã,  Ã,  Ã,  Ã, vehicle.shoot_graphic[i] = Overlay.CreateGraphical((vehicle.vehicle_graphic.X + (vehicle.width/2)), vehicle.vehicle_graphic.Y, vehicle.shoot_sprite, true);Ã,  	 
Ã,  Ã,  Ã,  Ã,  Ã, vehicle.shoot_graphic[i].X = vehicle.vehicle_graphic.X + (vehicle.width/2);
Ã,  Ã,  Ã,  Ã,  Ã, vehicle.shoot_graphic[i].Y = vehicle.vehicle_graphic.Y;
Ã,  Ã,  Ã,  Ã,  Ã, current_active_shoots[i] = true;
Ã,  Ã,  Ã,  Ã,  Ã, shoots_active++;
Ã,  Ã,  Ã,  Ã,  Ã, shoot = true;
Ã,  Ã,  Ã,  Ã,  return;
	 }
Ã,  Ã,  Ã,  Ã,  Ã, i++;
Ã,  Ã,  Ã,  Ã,  }
}


makes this any sense??
i guess a good customizable arcade module is very difficult to build.

Pumaman

Ok yeah, you'd have to do a manual check with the x, y, width and height to determine if they are overlapping.

Rocco


Scorpiorus

Quote from: Rocco on Sat 04/02/2006 17:43:15I have functions like:
Code: ags
 
function SetPlayerSprites(int vehicle_sprite_slot, int shoot_sprite_slot)
{
Ã,  
Ã,  vehicle.vehicle_sprite = vehicle_sprite_slot;
Ã,  vehicle.width = GetGameParameter(GP_SPRITEWIDTH, vehicle_sprite_slot,0 ,0);
Ã,  vehicle.height = GetGameParameter(GP_SPRITEWIDTH, vehicle_sprite_slot,0 ,0);
Ã,  vehicle.shoot_sprite = shoot_sprite_slot;

}


I have just noticed you have "GetGameParameter(GP_SPRITEWIDTH, ...)" twice which I believe is a common result of copy&paste issue (based on my personal experience :)); should have probaby been GP_SPRITEHEIGHT for the second line, unless you already got it fixed.

Rocco

oh great thanks,

i noticed that the collision detection is not that accurate, and i didnt know why,
now i know it - thanks  :D

SMF spam blocked by CleanTalk