Beispiel #1
0
void iMinimapView::OnMapContentChanged()
{
	PrepareMap();
	HDC hdc = GetDC();
	Compose(hdc);
	ReleaseDC(hdc);
}
void TestExtendedInterlayer()
{
	// Setup
	terminal_set("window.title='Omni: extended output / interlayer animation'");
	terminal_composition(TK_ON);

	int map_left = terminal_state(TK_WIDTH)/2 - map_width/2;
	int map_top = terminal_state(TK_HEIGHT)/2 - map_height/2;

	std::srand(std::time(nullptr));
	auto map = PrepareMap();
	PlaceFoe();

	auto Attack = [&]
	{
		int damage = 1+std::rand()%10;
		foe_hp -= damage;
		int x = foe_x, y = foe_y;
		if (foe_hp <= 0)
		{
			map[foe_y*map_width+foe_x] = 1;
			PlaceFoe();
			terminal_clear();
			DrawMap(map_left, map_top, map);
		}
		AnimateDamage(map_left+x, map_top+y, -damage);
	};

	auto Step = [&](int dx, int dy)
	{
		if (player_x+dx == foe_x && player_y+dy == foe_y)
		{
			Attack();
		}
		else if (map[(player_y+dy)*map_width+player_x+dx] <= 1)
		{
			player_x += dx;
			player_y += dy;
		}
	};

	for (bool proceed=true; proceed;)
	{
		terminal_clear();
		DrawMap(map_left, map_top, map);
		terminal_refresh();

		do
		{
			int key = terminal_read();
			if (key == TK_CLOSE || key == TK_ESCAPE)
			{
				proceed = false;
			}
			else if (key == TK_LEFT)
			{
				Step(-1, 0);
			}
			else if (key == TK_UP)
			{
				Step(0, -1);
			}
			else if (key == TK_RIGHT)
			{
				Step(1, 0);
			}
			else if (key == TK_DOWN)
			{
				Step(0, 1);
			}
		}
		while (proceed && terminal_has_input());
	}

	// Clean up
	terminal_composition(TK_OFF);
	terminal_clear();
	terminal_layer(0);
}
Beispiel #3
0
void iMinimapView::PrepareMap()
{
	PrepareMap(m_pMap, m_dibMap, true);
}