Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » newbie question, tessellation

This thread is locked; no one can reply to it. rss feed Print
newbie question, tessellation
metzor
Member #7,780
September 2006

I'm gonna feel really stupid for asking this, but here it goes

I just started taking a computer graphics course, and we've now started using Allegro C++. We haven't gotten all that far, we basically were handed a sheet with primitive functions (rectfill, ellipsefill, triangle, etc) and one of our first or second assignments was to tessellate (basically tile) the screen with a checkerboard. This was easy enough, as all it really needed was one set of nested for loops and a rectfill statement.

our next assignment has me stumped. i haven't taken a programming class in years, and it's overall very frustrating, which is why I'm making a fool of myself on these forums =)

we basically have to take a polygon with 6 vertices. and tile the screen with it. (this polygon has vertices of (50,0), (25, 25), (50,50), (100,50), (75, 25), (100,0)). we also have to make up our own polygon and do the same thing with it, creating something that you might see from mc escher. but i figure if i could just figure out the code for the first one, i could do it with pretty much any polygon.

anyone have any ideas or help? it's greatly appreciated.

sorry if this is lame :P

Krzysztof Kluczek
Member #4,191
January 2004
avatar

Quote:

(this polygon has vertices of (50,0), (25, 25), (50,50), (100,0), (75, 25), (100,0))

There is probably something wrong with is since you have listed (100,0) twice.

Ib Quezada
Member #7,779
September 2006
avatar

Probably the 2nd (100,0) is the way to tell the shape that it's closing... i'm not sure.

metzor
Member #7,780
September 2006

typo =o

there is a 100,0 but the other one is 100,50

corrected the original post
sorry

miran
Member #2,407
June 2002

What's the problem? Do the same thing as you did when drawing the checkerboard, except that instead of drawing rects, you draw this 6-sided polygon (write a function for this). The for loops should advance by 50 pixels each.

--
sig used to be here

Ron Ofir
Member #2,357
May 2002
avatar

Unless you need to tile it tightly (leaving no spaces). I'm afraid it's not possible with this shape and I'm not sure there's a general way to do so.

miran
Member #2,407
June 2002

Quote:

I'm afraid it's not possible with this shape

Are you sure? ???

--
sig used to be here

Evert
Member #794
November 2000
avatar

Quote:

Unless you need to tile it tightly (leaving no spaces). I'm afraid it's not possible with this shape

It's a regular hexagon. Of course it's possible.

miran
Member #2,407
June 2002

Quote:

It's a regular hexagon.

It's not a regular hexagon. It's a kind of an arrow hexagon, pointing to the left. Easier to tile than a regular honey comb style hexagon...

--
sig used to be here

Simon Parzer
Member #3,330
March 2003
avatar

void draw_my_shape( BITMAP* bmp, int x, int y, int color )
{
  int points[12] = {0,0, -25,25, 0,50, 50,50, 25,25, 50,0};
  for (int i=0; i<12; ++i)
  {
    points<i>+=x;
    points[++i]+=y;
  }
  polygon(bmp,6,points,color);
}

Go to: