void EggDropGameEngine::Render(CIwRect& bounds)
{
	CIwSVec2 drawGrass(bounds.x + (bounds.w - g_pGrass->GetWidth()) / 2, bounds.y);
	Utils::AlphaRenderImage(g_pGrass, drawGrass, 0xff);

	if (g_bBroken)
	{
		if (g_iCrackIter < 40)
		{
			int yOffset = (g_pSpoon->GetHeight() - g_pEgg->GetHeight()) * g_iCrackIter / 40.0;
			CIwRect bounds2(bounds.x + (bounds.w - g_pEgg->GetWidth()) / 2, bounds.y + yOffset, g_pEgg->GetWidth(), g_pEgg->GetHeight());

			double fallRot = fallingRot + (g_iCrackIter * 2 / 40.0);

			Utils::AlphaRenderAndRotateImage(g_pEgg, bounds2, 0xff, fallRot);

			g_iCrackIter++;
		}
		else
		{
			CIwSVec2 draw(bounds.x + (bounds.w - g_pCrackedEgg->GetWidth()) / 2, bounds.y + (bounds.h - g_pCrackedEgg->GetHeight()));
			Utils::AlphaRenderImage(g_pCrackedEgg, draw, 0xff);
		}
	}
	else
	{
		CIwSVec2 draw(bounds.x + (bounds.w - g_pSpoon->GetWidth()) / 2, bounds.y);
		Utils::AlphaRenderImage(g_pSpoon, draw, 0xff);

		IwGxFlush();

		CIwRect bounds2(bounds.x + (bounds.w - g_pEgg->GetWidth()) / 2, bounds.y, g_pEgg->GetWidth(), g_pEgg->GetHeight());
		Utils::AlphaRenderAndRotateImage(g_pEgg, bounds2, 0xff, rot);
	}
}
Esempio n. 2
0
TEST(Bounds, Grow)
{
  Bounds bounds(wd, topLeft, plateDim);
  bounds.grow(123, 0);

  EXPECT_EQ(623, bounds.width());
  // height should not be affected
  EXPECT_EQ(400, bounds.height());
  // topLeft not be affected
  EXPECT_EQ(10, bounds.leftAsUint());
  EXPECT_EQ(48, bounds.topAsUint());

  Bounds bounds2(wd, topLeft, plateDim);
  bounds2.grow(0, 123);

  EXPECT_EQ(523, bounds2.height());
  // width should not be affected
  EXPECT_EQ(500, bounds2.width());
  // topLeft not be affected
  EXPECT_EQ(10, bounds2.leftAsUint());
  EXPECT_EQ(48, bounds2.topAsUint());
}
Esempio n. 3
0
void testSectors3() {
  Rectangle bounds(250, 250);
  Sectors s(bounds);
  Table<bool> t(bounds, true);
  Rectangle bounds2(15, 15);
  Rectangle bounds3(3, 3);
  for (int i : Range(40)) {
    Vec2 pos(bounds.randomVec2());
    for (Vec2 v : bounds2.translate(pos).intersection(bounds))
      t[v] = false;
  }
  for (int i : Range(100)) {
    Vec2 pos(bounds.randomVec2());
    for (Vec2 v : bounds3.translate(pos).intersection(bounds))
      t[v] = true;
  }
  for (Vec2 v : bounds)
    if (t[v])
      s.add(v);
  for (int i : Range(100000)) {
    Vec2 v = bounds.randomVec2();
    if (Random.roll(3)) {
      s.remove(v);
      t[v] = false;
    } else {
      s.add(v);
      t[v] = true;
    }
  }
  for (Vec2 pos : bounds) {
    CHECK(t[pos] == s.contains(pos));
    if (t[pos])
      for (Vec2 v : pos.neighbors8())
        if (v.inRectangle(bounds))
          CHECK(t[v] == s.same(pos, v));
  }
  std::cout << s.getNumSectors() << " sectors" << endl;
}