Esempio n. 1
0
static void renderItems(Scene *scene)
{
	int i;
	for(i = 0; i < scene->items_num; ++i) {
		renderCell(4, scene->items[i][0], scene->items[i][1]);
	}
}
Esempio n. 2
0
void MapRenderer::render()
{
	for( int x = 0; x < m_map->cols(); x++ )
	{
		for( int y = 0; y < m_map->rows(); y++ )
		{
			renderCell( x, y, m_map->get(x, y) );
		}
	}
}
Esempio n. 3
0
void Cell::renderSelected(bool check)
{
	renderCell();
	glBegin(GL_QUADS);
	glColor3d(0.3, 0.3, 0.3);
	for (int i = 0; i < 4; ++i)
	{
		glVertex2dv(coords[0 + i].v());
		glVertex2dv(coords[(1 + i) % 4].v());
		glVertex2dv(coords[4 + (1 + i) % 4].v());
		glVertex2dv(coords[4 + i].v());
	}
	glEnd();
	renderPiece(check);
}
Esempio n. 4
0
void Cell::renderPointed(bool check)
{
	renderCell();
	glBegin(GL_QUADS);
	for (int i = 0; i < 4; ++i)
	{
		if (color == White) glColor3d(0.5, 0.5, 0.5);
		else glColor3d(0.8, 0.8, 0.8);
		glVertex2dv(coords[0 + i].v());
		glVertex2dv(coords[(1 + i) % 4].v());
		if (color == White) glColor3d(0.8, 0.8, 0.8);
		else glColor3d(0.5, 0.5, 0.5);
		glVertex2dv(coords[4 + (1 + i) % 4].v());
		glVertex2dv(coords[4 + i].v());
	}
	glEnd();
	if (!empty())
	{
		renderPiece(check);
	}
}
Esempio n. 5
0
void SRM_Render(Scene *scene)
{
	int x, y, id;
	glClearColor(1.0, 0.0, 0.0, 1.0);
	glClear(GL_COLOR_BUFFER_BIT);

	SMM_LoadIdentity();

	glEnableVertexAttribArray(attrib_coord);
	glEnableVertexAttribArray(attrib_color);
	for(x = 0; x < SCENE_WIDTH; ++x) {
		for(y = 0; y < SCENE_HEIGHT; ++y) {
			id = SCENE_GetCell(scene, x, y);
			renderCell(id, x, y);
		}
	}
	renderItems(scene);
	renderSnake(scene);

	glDisableVertexAttribArray(attrib_coord);
	glDisableVertexAttribArray(attrib_color);

	SDL_GL_SwapWindow(window);
}
Esempio n. 6
0
void WCalendar::render(WFlags<RenderFlag> flags)
{
  if (needRenderMonth_) {
    bool create = cellClickMapper_ == 0;
#ifndef WT_TARGET_JAVA
    char buf[30];
#else
    char *buf;
#endif // WT_TARGET_JAVA

    if (create) {
      // FIXME catch events only on container, and use 'tid' to identify
      // the cell -- in Ajax mode
      cellClickMapper_ = new WSignalMapper<Coordinate>(this);
      cellClickMapper_->mapped().connect(this, &WCalendar::cellClicked);
      cellDblClickMapper_ = new WSignalMapper<Coordinate>(this);
      cellDblClickMapper_->mapped().connect(this, &WCalendar::cellDblClicked);
    }

    int m = currentMonth_ - 1;
    if (monthEdit_->currentIndex() != m)
      monthEdit_->setCurrentIndex(m);

    int y = currentYear_;
    Utils::itoa(y, buf);
    if (yearEdit_->text().toUTF8() != buf)
      yearEdit_->setText(WString::fromUTF8(buf));

    WDate todayd = WDate::currentDate();
    date today(todayd.year(), todayd.month(), todayd.day());

    // The first line contains the last day of the previous month.
    date d(currentYear_, currentMonth_, 1);
    d -= date_duration(1);
 
    greg_weekday gw = firstDayOfWeek_ % 7;
    d = previous_weekday(d, gw);

    for (unsigned i = 0; i < 6; ++i) {
      for (unsigned j = 0; j < 7; ++j) {
	Utils::itoa(i * 7 + j, buf);
	std::string cell = std::string("c") + buf;
	
	WDate date(d.year(), d.month(), d.day());

	WWidget *w = impl_->resolveWidget(cell);
	WWidget *rw = renderCell(w, date);
	impl_->bindWidget(cell, rw);

	WInteractWidget* iw = dynamic_cast<WInteractWidget*>(rw->webWidget());

	if (iw && iw != w) {
	  if (clicked().isConnected()
	      || (selectionMode_ == ExtendedSelection)
	      || (selectionMode_ != ExtendedSelection && singleClickSelect_
		  && activated().isConnected()))
	    cellClickMapper_
	      ->mapConnect(iw->clicked(), Coordinate(i, j));

	  if ((selectionMode_ != ExtendedSelection && !singleClickSelect_
	       && (activated().isConnected() ||
		   selectionChanged().isConnected())))
	    cellDblClickMapper_
	      ->mapConnect(iw->doubleClicked(), Coordinate(i, j));
	}

	d += date_duration(1);
      }
    }

    needRenderMonth_ = false;
  }

  WCompositeWidget::render(flags);
}
Esempio n. 7
0
// frames determines how the sprite is drawn, timer
// frame is the x axis distance between cells
void drawSkeleton(Game * game)
{
	// spritesheet has 8 sprites cells on the x axis 1/8 = 0.125
	// spritesheet has 9 sprites cells on the y axis 1/9 = 0.111
	float x_increment = 0.125;
	float y_increment = 0.111;

	if(game->guts == true)
	{
		if(numblood == 0 && gutsToggle)
		{
			makeTESTguts(game);
			gutsToggle = false;
		}
		else
		{

			drawGuts(game);
			drawTESTguts(game);
		}
		return;
	}

	gutcount = 0;
	if(frame <= 3*x_increment)
		frame = 4*x_increment;

	int lvl = 1;
	float toplvl = 0.0f;

	if(game->player.velocity.y > 0) // up
	{
		frame = 5*x_increment;
		lvl = 1;
		toplvl = 0.0f;
	}
	if(game->player.velocity.y < 0) // down
	{
		frame = 3*x_increment;
		lvl = 1;
		toplvl = 0.0f;
	}
	if(game->player.velocity.x == 0)
	{
		frame = 0.0; // starting position 
		lvl = 9;
		toplvl =  8 * 0.1111111111;
		if(game->player.velocity.y > 0) // up
		{
			frame = 5*x_increment;
			lvl = 1;
			toplvl = 0.0f;
		}
		if(game->player.velocity.y < 0) // down
		{
			frame = 3*x_increment;
			lvl = 1;
			toplvl = 0.0f;
		}
	}

	// lower level of texture
	if(frame > 7 * x_increment)
	{
		lvl = 2;
		toplvl = 1 * 0.111111111;
	}


	if(frame > 11 * x_increment)
	{
		lvl = 1;
		toplvl = 0.0;
		frame = 4*x_increment;
	}

	renderCell(frame, x_increment, y_increment, lvl, toplvl, game);
}
Esempio n. 8
0
void WCalendar::render(WFlags<RenderFlag> flags)
{
  if (needRenderMonth_) {
#ifndef WT_TARGET_JAVA
    char buf[30];
#else
    char *buf;
#endif // WT_TARGET_JAVA

    int m = currentMonth_ - 1;
    if (monthEdit_->currentIndex() != m)
      monthEdit_->setCurrentIndex(m);

    int y = currentYear_;
    Utils::itoa(y, buf);
    if (yearEdit_->text().toUTF8() != buf)
      yearEdit_->setText(WString::fromUTF8(buf));

    // The first line contains the last day of the previous month.
    WDate d(currentYear_, currentMonth_, 1);
    d = d.addDays(-1);
 
    d = WDate::previousWeekday(d, firstDayOfWeek_);

    for (unsigned i = 0; i < 6; ++i) {
      for (unsigned j = 0; j < 7; ++j) {
	Utils::itoa(i * 7 + j, buf);
	std::string cell = std::string("c") + buf;
	
	WDate date(d.year(), d.month(), d.day());

	WWidget *w = impl_->resolveWidget(cell);
	WWidget *rw = renderCell(w, date);
	WInteractWidget* iw = dynamic_cast<WInteractWidget*>(rw->webWidget());

	if (rw != w)
	  impl_->bindWidget(cell, std::unique_ptr<WWidget>(rw));

	if (iw && iw != w) {
	  if (clicked().isConnected()
	      || (selectionMode_ == SelectionMode::Extended)
	      || (selectionMode_ != SelectionMode::Extended && 
		  singleClickSelect_ && activated().isConnected())) {
            const Coordinate c(i, j);
	    iw->clicked().connect
	      (this,
	       std::bind(&WCalendar::cellClicked, this, c));
          }

	  if ((selectionMode_ != SelectionMode::Extended &&
	       !singleClickSelect_ && (activated().isConnected() ||
		   selectionChanged().isConnected()))) {
            const Coordinate c(i, j);
	    iw->doubleClicked().connect
	      (this,
	       std::bind(&WCalendar::cellDblClicked, this, c));
          }
	}

    d = d.addDays(1);
      }
    }

    needRenderMonth_ = false;
  }

  WCompositeWidget::render(flags);
}