identifying actors with x/y coordinates...
harrio
Member Posts: 234
what's cookin,
is there a way to check an x/y position and ask if an actor is at that current position? any part of the actor, not just the center position.
i want to be able know if an actor is in a particular area without having to collide with that actor to identify it.
something like: if ((pos x)(pos y))==('enemy' actor) then ...
is there a way to check an x/y position and ask if an actor is at that current position? any part of the actor, not just the center position.
i want to be able know if an actor is in a particular area without having to collide with that actor to identify it.
something like: if ((pos x)(pos y))==('enemy' actor) then ...
Comments
Rectangular collision actor: (self.x-width/2<=x'<=self.x+width/2)
if attribute changes self.position.X <= x'+self.Size.width/2
and
if attribute changes self.position.X >= x'-self.Size.width/2
and
if attribute changes self.position.Y <= y'+self.Size.height/2
and
if attribute changes self.position.Y >= y'-self.Size.height/2
Note: Since there is no greater than or equal to , nor less than or equal to, each of the conditions above needs to be 2 conditions. I'll check into adding >= and <=.
Circular collisions: distance between the 2 points is less than or equal to the radius of the circle.
if attribute changes, self.width (or height, whichever is smaller and thus is the radius) >= 2*magnitude(self.Position.X-x', self.Position.Y-y')
kamazar: i started down that path of reasoning but i think, and correct me chefs if i'm wrong but, the position variables only reference the center point of the actor. i want to be able to just determine an x/y point and see if there is an actor at that point, even if it is just a corner piece of the actor touching that particular x/y point.
codemonkey: i thought that i might be able to use an invisible, collidable, 1 pixel actor to see if any other actor is at that point. but then i thought, for memory usage and optimum speed, it would be better if there were a behavior,method or reference where i could just input the x/y parameter and return if an actor currently resided at that point.
please let me know if i'm interpreting this wrong but it looks like your method is seeing if a generic x/y point is contained within the height and width of a specific actor. i want to go somewhat the opposite way and have a generic point that i define and discover if there is any actor currently intersecting that point. that way, i won't have to deal with the dimensions of any specific actor, i can just see if any actor is on this point at any time.
is this doable?
i'll draw up a quick diagram illustrating why i want this, as opposed to using invisible collidable actors.
here's the diagram of what i'm trying to accomplish.
http://docs.google.com/View?id=dcrvmt6h_56fdt57nv9
once i made it, i realized something and i hope you chefs can confirm this for me. in order to cut down on unnecessary actors being spawned. i can use just one invisible, collidable, 1 pixel actor for checking below the enemy actors. and for each actor instance i can change/constrain the 'enemy checker' actor position to self.position x and self.position y - 40. that would be the center position of the enemy actor directly below, if there is one. that way, i only have one actor that bounces around to all the enemy actor instances checking below them for other enemy actors. and i could do the same for the 'player checker' actor. having just one that moves to the enemy actor who is trying to fire.
this seems alot better than each enemy actor spawning a checker actor.
but if there were a method to check an x/y point for an actor present there. i would not need to make any actors to accomplish this.
am i making space invaders harder than it should be?...lol