Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

I have a 2D grid (x,y coordinates) where each cell corresponds to each pixel of the interface that I am working with and I have a point A(x1,y1). Now I need to travel around in the grid, and I wont just move this single point, but would like to move a bunch of points together. Now what do you think is the best figure that I shall move, i.e. a circle with a predefined radius, or a square with a fixed side.

Also, once I decide upon the figure, I need to know, what all points are there in the figure, given a specific central point, and work with those points too.

I was thinking that a square would be a better idea, since I'll just have to check the if the difference of the coordinates of the point to be checked from the central point is less than side/2.

But I've heard that calculations with circle are not bad either.

Kindly suggest,

share|improve this question
    
So if I understand your question correctly, you would like to "move" a geometrical shape on the screen? –  Marton Mar 22 '13 at 12:48

1 Answer 1

up vote 2 down vote accepted
  1. Write a method that draws the "bunch of points" around the central point.

    public void DrawMyPoints(Point center)
      {
         float radius = 10.0;
         MyPreferredGraphicsLib.DrawCircle(center, radius);
         //Draw a circle or a square, for example.
         //Most graphics libraries have dedicated methods for basic geometrical shapes.
      }
    
  2. Every time you move the center point, clear the screen and redraw all the points:

    public void MoveMyPoints(Point newCenter)
      {
         MyPreferredGraphicsLib.ClearScreen(); //Usually automatic in anything post-Pascal.
         DrawMyPoints(newCenter);
      }
    
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.