Beispiel #1
0
// standard in-game tick (as opposed to title-screen, inventory etc)
void game_tick_normal(void)
{
Object *o;

	player->riding = NULL;
	player->bopped_object = NULL;
	Objects::UpdateBlockStates();

	if (!game.frozen)
	{
		// run AI for player and stageboss first
		HandlePlayer();
		game.stageboss.Run();
		
		// now objects AI and move all objects to their new positions
		Objects::RunAI();
		Objects::PhysicsSim();
		
		// run the "aftermove" AI routines
		HandlePlayer_am();
		game.stageboss.RunAftermove();
		
		FOREACH_OBJECT(o)
		{
			if (!o->deleted)
				o->OnAftermove();
		}
	}
//main
int main()
{
Beginning: /* Label */
	printf("\n");

	player.x = 2, player.y = 5;
	target.x = 3, target.y = 0;
	enemy1.x = 0, enemy1.y = 1;
	enemy2.x = 5, enemy2.y = 3;

		/* Game Loop */
	while (1)
	{
		DrawMap();

		char input;
		printf("Enter a choice: l(Left), r(Right), u(Up), d(Down) and e(Exit)\n");
		scanf_s(" %c", &input);
		
		if (input=='e')
			goto Exit;
		else
		{
			HandlePlayer(input);
			HandleEnemy();
		
			system("cls");

			if ((player.x==enemy1.x && player.y==enemy1.y) ||		/* colliding with an enemy */
				(player.x==enemy2.x && player.y==enemy2.y))
			{
				score();
				printf("Sorry, you failed...\n Your score is: %d\n", score1);
				goto Beginning;
			}
			else if (player.x==target.x && player.y==target.y)		/* Target reached */
			{
				score();
				printf("Congratulation, you won...\n Your score is: %d\n", score1);
				goto Beginning;
			};
		};
	};

Exit:	/* Label */
    printf("\n");
};