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

[pygame] simple rectangle drawing




pre-ps: not on the mailing list

hello, everyone!

i am trying to make a simple game that will use either a series of
rectangles or circles to make up the display.

how can i do this with pygame?

the code i used in c before was:

void
do_set (int x, int y, REP rep)
{
	SDL_Rect r;

	r.x = x * TILEX;
	r.y = y * TILEY;
	r.h = TILEY;
	r.w = TILEX;

	if ((SDL_FillRect (screen, &r, ct[rep].rgb)) == -1)
		cout << "error" << endl;

	SDL_UpdateRect (screen, r.x, r.y, r.w, r.h);
}

where rep was an index into a colortable ct.

the problem i am having (i think) is that the cliprect in pygame is
unnecessarily extending itself.

this is basically the python code:


		r = pygame.rect.Rect (left, top, right, bottom)
		self.background.set_clip (r)
		if obj == None:
			self.background.fill ((0,0,0))
		else:
			self.background.fill (obj.color)
		pygame.display.update ()

--
etoffi <http://oluworld.sourceforge.net/>
____________________________________
pygame mailing list
pygame-users@seul.org
http://pygame.seul.org