swarm-support
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Swarm-Support] Discrete2d peculiar behavior


From: Alex Olivas
Subject: [Swarm-Support] Discrete2d peculiar behavior
Date: Mon, 25 Oct 2004 18:44:12 -0600
User-agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.3) Gecko/20040913

I found the problem so my last post can be neglected.
It turns out the problem was getting objects near the boundaries
(i.e. negative values for x and/or y).  My code lookes like...


 int deltaX,deltaY;
 for(deltaX=-1;deltaX<=1;deltaX++)
   for(deltaY=-1;deltaY<=1;deltaY++)
     if((deltaX!=0)||(deltaY!=0))
   if([world getObjectAtX: xPos+deltaX Y: yPos+deltaY]!= nil){
     printf("x: %d y: %d\n",xPos+deltaX,yPos+deltaY);
     xprint([world getObjectAtX: xPos+deltaX Y: yPos+deltaY]);

My code would crash at the last line above (the xprint statement).
I was wondering if x=-1 (for example) why does [world getObjectAtX: xPos+deltaX Y: yPos+deltaY]
return a non-nil value?

This is a hack of heatbugs, so world is a Grid2d object and the space contains modified heatbugs.
Thanks,
Alex.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]