Esempio n. 1
0
void send_save_shop(uint16 shopnum)
{
	buffer_t buffer;

	clear_buffer(&buffer);

	add_opcode(&buffer, CSAVESHOP);
	add_buffer(&buffer, &shopnum, SIZE16);
	add_string(&buffer,shop(shopnum)->name);
	add_string(&buffer,shop(shopnum)->joinsay);
	add_string(&buffer,shop(shopnum)->leavesay);
	add_buffer(&buffer, &shop(shopnum)->fixesitems, SIZE8);
	add_buffer(&buffer, &shop(shopnum)->tradeitem, MAX_TRADES * sizeof(trade_item_t));

	send_data(&buffer);
}
Esempio n. 2
0
int main(int argc, const char *argv[])
{
    WorkShop shop(5, 100, 150);
    shop.startWorking();
    
    return 0;
}
int main(int argc,char* args[])
{
 SDL_Init(SDL_INIT_EVERYTHING);
 screen=SDL_SetVideoMode(0,0,32,SDL_FULLSCREEN);
 background=SDL_LoadBMP("wooden_background.bmp");
 apply_surface(0,0,background,screen);
 //print_main_layer();
 load_prices();
 print_player_info(true);
 print_shop(4,5);
 SDL_Flip(screen);
 shop(5,5);
 save_player1("player1");
 //SDL_Delay(1000);
return 0;
}
Esempio n. 4
0
main()
{
	int i,j,order,wave;
	srand(time(NULL));
	printf("Ready? Go! 30 waves!\n\n");
	ph=50;pa=3;pd=0;wave=30;phealth=200;
	for (i=1;i<=wave;i++)
	{
		printf("\n***********The No.%d wave**********\n",i);
		if (i<=25) learn();
		h=rand()%(30*(1+i/4))+ph+10;
		a=rand()%(5*(1+i/8))+pa+1;
		d=rand()%(3*(1+i/8))+pd;
		m=i;
		ph=h;pa=a;pd=d;win=2;
		preskill();
		do
		{
			for (j=0;j<=4;j++)
			      if (k[j]) k[j]--;
		printf("Your situation:health:%d  attack:%d  defend:%d\n",health,attack,defend);
		printf("The enemy's situation:health:%d  attack:%d  defend:%d\n",h,a,d);
		printf("Your turn   1:attack;2:skills   ");
		scanf("%d",&order);
		switch (order)
		{
			case 1:attacke();break;
			case 2:skill();break;
			default:printf("Order error!Lose one turn!");break;
		}
		if (h>0) reattack();
		printf("\n");
	}   while (health>0&&h>0);
		if (win==1) {printf("You win the wave!\n");money+=m;honor++;} else if (win==0) {printf("You lose the wave!\n");health=phealth;}
		attack++;
		shop();
		health+=i*10+pa;
		(phealth+=i*12);
		attack+=rand()%3;
		defend+=rand()%2;
	}
	printf("You succeeded in %d waves out of %d!",honor,wave);
}
Esempio n. 5
0
int main() {
	// Constantly loop, listening for user input and performing an action

	char c;

	for (;;) {
		// Flavour & help text, always display before the prompt
		help();

		// Display the current achievements
		getAchievements();
		displayAchievements();

		// Display the current upgrade count
		currentUpgrades();

		// Random Sales
		displaySales();

		// Display the prompt
		printf("\n%d doves - %d/32 upgrades\n", doves, countUpgrades());
		printf("> ");

		// Perform an action
		c = getFirstCharOfLine();

		if (c == '\n')
			getDoves();
		else if (c == 'b')
			shop();
		else if (c == 'q')
			break;

		// Clear the screen
		printf(clearScreen);
	}

	// The game ends
	printf("Game over - you acquired %d/32 upgrades\n", countUpgrades());
	return 0;
}
Esempio n. 6
0
int main(void)
{
	struct Hero mage = {
		"",
		MAGE,
		450,
		0,
		50,
		200,
		30,
		10,
		1,
		1,
		0,
		0, 
		NULL,
		NULL
	};
	struct Hero warrior = {
		"",
		WARRIOR,
		550,
		60,
		0,
		0,
		5,
		25,
		1.3,
		1,
		0,
		0, 
		NULL,
		NULL
	};
	struct Hero thief = {
		"",
		THIEF,
		400,
		60,
		0,
		0,
		10,
		15,
		1,
		1.2,
		5,
		0, 
		NULL,
		NULL
	};
	struct Hero bot1 = {
		"Mage",
		ANY,
		500,
		0,
		45,
		0,
		15,
		15,
		1.4,
		1.5,
		10,
		0, 
		NULL,
		NULL
	};
	struct Hero bot2 = {
		"Guard",
		ANY,
		400,
		65,
		0,
		0,
		15,
		35,
		1.8,
		1,
		0,
		0, 
		NULL,
		NULL
	};
	struct Hero bot3 = {
		"Black knight",
		ANY,
		700,
		100,
		0,
		0,
		25,
		25,
		1,
		1.2,
		5,
		0, 
		NULL,
		NULL
	};
	struct Hero * hero;
	struct Hero * bot = &(bot3);
	COORD posHead;
	int a;
	int b;
	int p = 0;
	int status = 0;
	int true = 0;
	const char * Interface[3] = {
		"New game",
		"Load",
		"Records"
	};
	HANDLE hConsole = GetStdHandle(STD_OUTPUT_HANDLE);
	metka: a = move (hConsole, 3, Interface, 7, hero, &(mage), &(warrior), &(thief));
	switch (a){
		case 0 : createHero(&(hero), &(mage), &(warrior), &(thief)); true = 1; break;
		case 1 :
			system("cls");
			FILE * fp = NULL;
			printf("enter full name of file what you will open to load\n");
			char str[30];
			gets(str);
			fp = fopen(str, "r");
			if (NULL == fp)
				status = 1;
			if (status == 0)
			{
				fscanf(fp, "%i", &(b));
				switch (b)
				{
					case MAGE: hero = &(mage); break;
					case WARRIOR: hero = &(warrior); break;
					case THIEF: hero = &(thief); break;
				}
				int Weapon_type;
				int Armor_type;
				fscanf(fp, "%i %i %i", &(Weapon_type), &(Armor_type), &(hero->gold));
				switch (Armor_type)
				{
					case -1: status = 1; break;
					case 6: hero->Armor = &(steel_armor); break;
					case 7: hero->Armor = &(mage_robe); break;
					case 8: hero->Armor = &(lether_armor); break;
					case 9: hero->Armor = &(dragon_armor); break;
					case 10: hero->Armor = &(arcgmage_robe); break;
					case 11: hero->Armor = &(elven_armor); break;
				}
				if (status != 1){
					hero->health += hero->Armor->health;
					hero->damage += hero->Armor->damage;
					hero->mag_damage += hero->Armor->mag_damage;
					hero->mana += hero->Armor->mana;
					hero->magic_protect += hero->Armor->magic_protect;
					hero->armor += hero->Armor->armor;
					hero->critical_damage += hero->Armor->critical_damage - 1;
					hero->critical_chanse += hero->Armor->critical_chanse;
				}
				switch (Weapon_type)
				{
					case -1: status = -1; break;
					case 0: hero->Weapon = &(steel_sword); break;
					case 1: hero->Weapon = &(magic_stick); break;
					case 2: hero->Weapon = &(steel_dagger); break;
					case 3: hero->Weapon = &(great_sword); break;
					case 4: hero->Weapon = &(wood_scepter); break;
					case 5: hero->Weapon = &(thief_dagger); break;
				}
				if (status != -1){
					hero->health += hero->Weapon->health;
					hero->damage += hero->Weapon->damage;
					hero->mag_damage += hero->Weapon->mag_damage;
					hero->mana += hero->Weapon->mana;
					hero->magic_protect += hero->Weapon->magic_protect;
					hero->armor += hero->Weapon->armor;
					hero->attack_speed = hero->Weapon->attack_speed;
					hero->critical_damage += hero->Weapon->critical_damage - 1;
					hero->critical_chanse += hero->Weapon->critical_chanse;
				}
				true = 1;
				
			}
			else 
				printf("error input");
			fclose(fp);	
			break;
		case 2 : printRec(); goto metka;break;
		
	}
	
	
	while (true)
	{
		shop(hero, &(mage), &(warrior), &(thief));
		true = battle(hero, &(bot1), &(bot2), &(bot3));
		if (true == 2)
			;
		else if (true)
			printf("WIN\n");
		else
			printf("LOSE\n");
		getchar();
	}
	system("cls");
	posHead.X = 34;
	posHead.Y = 10;
	SetConsoleCursorPosition(hConsole, posHead);
	SetConsoleTextAttribute(hConsole, FOREGROUND_RED);
	puts("GAME OVER");
	posHead.Y = 11;
	SetConsoleCursorPosition(hConsole, posHead);
	printf("your result is %i", hero->gold);
	posHead.Y++;
	SetConsoleCursorPosition(hConsole, posHead);
	printf("enter your nickname\n");
	char nick[20];
	posHead.Y++;
	SetConsoleCursorPosition(hConsole, posHead);
	gets(nick);
	if (nick[0] == '\0')
		strcpy(nick, "noName");
	int record[10];
	char temp[10][20];
	FILE * fp = NULL;
	fp = fopen("reclab4.txt", "r");
	if (NULL == fp)
		return 0;
	for (int i = 0; i < 10; i++){
		fscanf(fp, "%i %s", &record[i], temp[i]);
		//printf("%i. %8i  %s\n", i + 1, record, nick);
		if (record[i] > hero->gold)
			p = i;
	}
	fclose(fp);
	fp = fopen("reclab4.txt", "w");
	for (int i = 0; i < 10; i++){
		if (p == i - 1)
			fprintf(fp, "%i %s\n", hero->gold, nick);
		fprintf(fp, "%i %s\n", record[i], temp[i]);
	}
	SetConsoleTextAttribute(hConsole, FOREGROUND_BLUE | FOREGROUND_RED | FOREGROUND_GREEN);
	getchar();
	fclose(fp);
	return EXIT_SUCCESS;
}
TEST_F(SimulatorTest, spreadFireShop){
	Shop shop(Point(3, 5), Size(2, 2), 20, 20); // First burning shop
	House house1(Point(1, 3), 20);
	House house2(Point(1, 5), 20);
	House house3(Point(1, 7), 20);
	House house4(Point(3, 3), 20);
	House house5(Point(3, 7), 20);
	House house6(Point(5, 3), 20);
	House house7(Point(5, 5), 20);
	House house8(Point(5, 7), 20);

	Street horizontalDown("Horizontaldown", Point(0, 0), Point(8, 0));
	Street horizontalUp("Horizontalup", Point(0, 8), Point(8, 8));
	Street verticalLeft("verticalLeft", Point(0, 0), Point(0, 8));
	Street verticalRight("verticalRigth", Point(8, 0), Point(8, 8));

	EXPECT_TRUE(ptrCity->add(horizontalDown));
	EXPECT_TRUE(ptrCity->add(horizontalUp));
	EXPECT_TRUE(ptrCity->add(verticalLeft));
	EXPECT_TRUE(ptrCity->add(verticalRight));

	EXPECT_TRUE(ptrCity->add(shop));
	EXPECT_TRUE(ptrCity->add(house1));
	EXPECT_TRUE(ptrCity->add(house2));
	EXPECT_TRUE(ptrCity->add(house3));
	EXPECT_TRUE(ptrCity->add(house4));
	EXPECT_TRUE(ptrCity->add(house5));
	EXPECT_TRUE(ptrCity->add(house6));
	EXPECT_TRUE(ptrCity->add(house7));
	EXPECT_TRUE(ptrCity->add(house8));

	Simulator sim(ptrCity, ptrOutput);

	std::vector<House*> houses = ptrCity->getHouses();
	std::vector<House*>::iterator it;

	// Set first house on fire
	ptrCity->getShops()[0]->setFire();
	ptrOutput->step();

	// Count houses on fire
	int counter = 0;

	counter = 0;
	for(it = houses.begin();it != houses.end();it++){
		if((*it)->isBurning()){
			counter++;
		}
	}

	EXPECT_EQ(counter, 0);

	sim.burningDown();
	ptrOutput->step();
	sim.burningDown();
	ptrOutput->step();
	sim.burningDown();
	sim.spreadFire();
	ptrOutput->step();

	counter = 0;
	for(it = houses.begin();it != houses.end();it++){
		if((*it)->isBurning()){
			counter++;
		}
	}

	EXPECT_EQ(counter, 2);

	sim.spreadFire();
	sim.burningDown();
	ptrOutput->step();

	counter = 0;
	for(it = houses.begin();it != houses.end();it++){
		if((*it)->isBurning()){
			counter++;
		}
	}

	EXPECT_EQ(counter, 4);
}
Esempio n. 8
0
void ArenaBattle::start()
{
	std::cout << "[*] Server starting up on port " << LISTEN_PORT << " ... ";
	std::cout.flush();
	try {
		boost::asio::io_service io_service;
		tcp::endpoint endpoint(tcp::v4(), LISTEN_PORT);
		tcp::acceptor acceptor(io_service, endpoint);
		std::cout << "okay" <<std::endl;
		while (true) {
			std::cout << "[*] Waiting for player to connect ... ";
			std::cout.flush();
			tcpStream = new tcp::iostream;
			UserInterface display(tcpStream);
			acceptor.accept(*tcpStream->rdbuf());
			std::cout << "okay" << std::endl;
			(*tcpStream) << "    *** Welcome to the \"Mad Libs\" Arena Battler ***" << std::endl;
			(*tcpStream) << " - Where Your Adventure is " << display.getSlogan() << " -" << std::endl;
			createHuman(display);
			display.introduction(human);
			currentLevel = 1;
			playing = true;
			while (playing && currentLevel <= 10)
			{
				option = display.menu("Home", mainMenu);
				if (option == 1)
				{
					std::cout << "[*] " << human.getName() << " has started level " << currentLevel << std::endl;
					Level level(&display, currentLevel++);
					level.battle(human);
					if (!human.isDead() && currentLevel < 10) {
						human.increaseHealthBy(10);
						(*tcpStream) << human.getName() << " rests and restores his health to " << human.getHealth() << ".\n" << std::endl;
					}
				}
				else if (option == 2)
				{
					Shop shop(&display);
					shop.browse(human);
				}
				else if (option == 3)
				{
					display.showAttributes(human);
					display.showAttributes(human.getWeapon());
					display.showAttributes(human.getArmor());
				}
				else if (option == 4)
				{
					display.ask("\n[?] Are you sure you want to quit the game? [y/n]: ");
					if (strncmp("y", display.getInputBuffer(), 1) == 0 || strncmp("Y", display.getInputBuffer(), 1) == 0) {
						playing = false;
					}
				}
				if (human.isDead())
				{
					playing = false;
				}
			}
			if (currentLevel == 11 && !human.isDead()) {
				(*tcpStream) << "\n  *** You defeated the dragon and saved the princess, huzzah ***" << std::endl;
			}
			(*tcpStream) << "\n[*] Thanks for playing the Medieval Mad Lib Battler\n";
			tcpStream->close();
			delete tcpStream;
			std::cout << "[*] Player disconnected from server" << std::endl;

		}
	}
	catch (char* error)
	{
		std::cout << "\n[!] Error: " << error << std::endl;
	}
}
Esempio n. 9
0
// the main function
void _main(void) {
    unsigned int difficulty = NORMAL;
    short int key=0;
    short int keys[8];
    unsigned int level_num = 1;
    unsigned short int score = 0;
    int done = 0;
    unsigned int money = 0;
    int cannon_level = 1;
    int missile_level = 0;
    char map[12][MAP_SIZE];

    // seed the random numbers
    randomize();
    // get the key masks
    getKeyMasks(keys);


    INT_HANDLER interrupt1 = GetIntVec(AUTO_INT_1);  // this will save auto int 1

    // draw title screen and wait for keypress
    GrayOn();
    drawTitle(2);
    ngetchx();

    //draw background title screen and menu
    drawTitle(1);
    drawWords(difficulty);
    POSITION pointer = {10,0};
    drawPointer(pointer);
    // the menu loop
    while (1) {
        key = ngetchx();
        if (key == KEY_ENTER && pointer.y != OPTIONS) {
            if (pointer.y == PLAY) break;
            if (pointer.y == HIGH_SCORES) printHiScores();
            if (pointer.y == HELP) doHelp();
            if (pointer.y == ABOUT) {
                SetIntVec(AUTO_INT_1,interrupt1);
                GrayOff();
                exit(0);
            }
            GraySetAMSPlane(LIGHT_PLANE);
            clrscr();
            GraySetAMSPlane(DARK_PLANE);
            clrscr();
            drawTitle(1);
            drawWords(difficulty);
            pointer=(POSITION) {
                10,0
            };
            drawPointer(pointer);
        }
        if (key == KEY_LEFT && pointer.y == OPTIONS && difficulty < VERY_EASY) {
            difficulty+=1;
            GraySetAMSPlane(LIGHT_PLANE);
            clrscr();
            GraySetAMSPlane(DARK_PLANE);
            clrscr();
            drawTitle(1);
            drawPointer(pointer);
            drawWords(difficulty);
        }
        if (key == KEY_RIGHT && pointer.y == OPTIONS && difficulty > IMPOSSIBLE)  {
            difficulty-=1;
            GraySetAMSPlane(LIGHT_PLANE);
            clrscr();
            GraySetAMSPlane(DARK_PLANE);
            clrscr();
            drawTitle(1);
            drawPointer(pointer);
            drawWords(difficulty);
        }
        if (key == KEY_UP || key == KEY_DOWN) drawPointer(pointer);
        if (key == KEY_UP && pointer.y > 0) pointer.y--;
        if (key == KEY_DOWN && pointer.y < 4) pointer.y++;
        if (key == KEY_UP || key == KEY_DOWN) drawPointer(pointer);
    }
    key = 0;
    // turn off gray, so we can destroy auto-int-1 and not mess it up
    GrayOff();

    // DESTROY auto-interrupt 1 so as not to mess up _rowread
    SetIntVec(AUTO_INT_1,DUMMY_HANDLER);

    // turn gray back on
    GrayOn();

    // randomize the map
    randomMap(difficulty, map, level_num);
    //the main game loop
    while (!quit() && !done) {
        done = 0;
        int fin = 0;
        int win = 0;
        int forward = 0;
        int map_x_location = 0;
        int laser = 0;
        int justLaser = 0;
        int missile = 0;
        int justMissile = 0;
        int missileSlow = 2;
        POSITION laserPos;
        POSITION oldLaserPos;
        POSITION missilePos;
        POSITION oldMissilePos;
        POSITION oldShip;
        POSITION ShipPos = {0,5};

        // we need to disable gray temporarily to do the shop screen...
        GrayOff();
        SetIntVec(AUTO_INT_1, interrupt1);
        shop(&money, &cannon_level, &missile_level);
        SetIntVec(AUTO_INT_1, DUMMY_HANDLER);
        GrayOn();

        // draws the level
        Draw_Map(map_x_location, map, ShipPos, laserPos, laser, missilePos, missile);


        // the loop for the action in the level
        while (!quit()) {

            // if the user has a missile out, deal with it
            if (missile && missileSlow == 2) {
                missileSlow = 1;
                oldMissilePos = missilePos;
                missilePos.x++;
                missilePos.y+=missile;
                if (missilePos.x > map_x_location + 20) missile = 0;
                if (missilePos.y < 0 || missilePos.y > 12) {
                    missile = 0;
                    eraseMissile(missilePos, map_x_location);
                }
                if (blowWall(missilePos,map)) {
                    if (map[missilePos.y][missilePos.x] < 4) {
                        map[missilePos.y][missilePos.x]-=3;
                        if (map[missilePos.y][missilePos.x] == 0) {
                            score++;
                            money+=BLOCK_VALUE;
                        }
                    }
                    if (map[missilePos.y][missilePos.x] < 0) map[missilePos.y][missilePos.x] = 0;
                    missile = 0;
                    justMissile = 0;
                    Draw_Map(map_x_location,map,ShipPos,laserPos,laser,missilePos,missile);
                }
                // if the shot was just fired, then there wont be one to erase
                if (!justMissile && missile == 1) {
                    moveMissile(oldMissilePos,missilePos,map_x_location);
                } else if (missile == 1) {
                    drawMissile(missilePos,map_x_location);
                    justMissile = 0;
                } else if (!justMissile && missile == -1) {
                    moveUpMissile(oldMissilePos, missilePos, map_x_location);
                } else if (missile == -1) {
                    drawUpMissile(missilePos, map_x_location);
                    justMissile = 0;
                }

            } else {
                missileSlow++;
            }

            // if the user has a laser shot that is still going, continue it
            if (laser) {
                oldLaserPos = laserPos;
                laserPos.x++;
                if (laserPos.x > map_x_location + 20) laser=0;
                if (blowWall(laserPos,map)) {
                    if (map[laserPos.y][laserPos.x] < 4) {
                        map[laserPos.y][laserPos.x]-=cannon_level;
                        if (map[laserPos.y][laserPos.x] <= 0) {
                            score++;
                            money+=BLOCK_VALUE;
                            map[laserPos.y][laserPos.x] = 0;
                        }
                    } else if (map[laserPos.y][laserPos.x] == 4 && cannon_level == 4) {
                        map[laserPos.y][laserPos.x] = 1;
                    }
                    laser = 0;
                    justLaser = 0;
                    Draw_Map(map_x_location,map,ShipPos,laserPos,laser, missilePos, missile);
                }
                // if the shot was just fired, then there wont be one to erase
                if (!justLaser && laser) {
                    moveLaser(oldLaserPos,laserPos,map_x_location);
                } else if (laser) {
                    drawLaser(laserPos,map_x_location);
                    justLaser = 0;
                }
            }

            // scroll the screen forward one block every (difficulty) time through the main loop
            if (forward == difficulty) {
                map_x_location++;
                ShipPos.x++;
                forward = 0;
                if (map_x_location >= MAP_SIZE - 20) {
                    win = 1;
                    level_num++;
                    break;
                }
                // if you ran into a wall, quit
                if (detectWall(ShipPos,map)) {
                    win = 1;
                    score /= 2 ;
                    break;
                }
                Draw_Map(map_x_location,map,ShipPos,laserPos,laser, missilePos, missile);
            } else {
                forward++;
            }

            // if you ran into a wall, quit
            if (detectWall(ShipPos,map)) {
                win = 1;
                score = 0;
                break;
            }

            if (_rowread(~((short)(1<<1))) & (1<<6) && _rowread(~((short)(1<<2))) & (1<<6)) {
                win = 1;
                level_num++;
                break;
            }

            // get keypresses
            key = _rowread(ARROW_ROW);

            // if the user pressed right, move the ship right
            if (key & keys[RIGHT]) {
                oldShip = ShipPos;
                ShipPos.x++;
                if (ShipPos.x > map_x_location + 18) ShipPos.x--;
                if (!detectWall(ShipPos,map)) {
                    moveShip(oldShip,ShipPos,map_x_location);
                }	else {
                    win = 1;
                    score = 0;
                    break;
                }
            }
            // If the user pressed left, move the ship left
            if (key & keys[LEFT]) {
                oldShip = ShipPos;
                ShipPos.x--;
                if (ShipPos.x < map_x_location) ShipPos.x++;
                if (!detectWall(ShipPos,map)) {
                    moveShip(oldShip,ShipPos,map_x_location);
                } else {
                    win = 1;
                    score = 0;
                    break;
                }
            }

            // if the user pressed up, move the ship up
            if (key & keys[UP]) {
                oldShip = ShipPos;
                if (ShipPos.y - 1 < 0) {
                    ShipPos.y = 0;
                } else {
                    ShipPos.y--;
                }
                if (!detectWall(ShipPos,map))	{
                    moveShip(oldShip,ShipPos,map_x_location);
                } else {
                    win = 1;
                    score = 0;
                    break;
                }
            }

            // if the user pressed down, move the ship down
            if (key & keys[DOWN]) {
                oldShip = ShipPos;
                ShipPos.y++;
                if (ShipPos.y > 10) ShipPos.y = 10;
                if (!detectWall(ShipPos,map)) {
                    moveShip(oldShip,ShipPos,map_x_location);
                } else {
                    win = 1;
                    score = 0;
                    break;
                }
            }

            // if 2nd was pushed, fire the laser
            if (key & keys[SECOND]) {
                if (!laser) {
                    justLaser = 1;
                    laser = 1;
                    laserPos.x = ShipPos.x + 1;
                    laserPos.y = ShipPos.y;
                }
            }

            // if diamond was pushed fire the downward missiles
            if (key & keys[DIAMOND]) {
                if (missile_level == 3 || missile_level == 1) {
                    if (!missile) {
                        justMissile = 1;
                        missile = 1;
                        missileSlow = 2;
                        missilePos.x = ShipPos.x;
                        missilePos.y = ShipPos.y;
                    }
                }
            }

            // if shift was pushed fire the upward missiles
            if (key & keys[SHIFT]) {
                if (missile_level == 2 || missile_level == 3) {
                    if (!missile) {
                        justMissile = 1;
                        missile = -1;
                        missileSlow = 2;
                        missilePos.x = ShipPos.x;
                        missilePos.y = ShipPos.y;
                    }
                }
            }

            /*if (key & keys[ALPHA]) {
            score += 10;
            }*/
            // slow down the program because _rowread is too fast
            delay();
        }



        // back to the overall game loop
        if (win) {
            if (level_num <= LEVEL_NUM) {
                won(difficulty, map, level_num);
            } else {
                fin = 1;
                break;
            }
        }
    }

    // the user left, either by winning or quitting, so make sure everything is reset so the calc will be fine
    GrayOff();
    SetIntVec(AUTO_INT_1,interrupt1);
    hiScoresGo(score, difficulty, level_num);
}
Esempio n. 10
0
//
// Fix a compile error - see http://stackoverflow.com/questions/920500/what-is-the-purpose-of-cxa-pure-virtual for details.
//
// extern "C" void __cxa_pure_virtual() { while (1); }
//
// The main entry point
//
int main(void) {
	//
	// Board and port initialisations
	//
	StellarisLaunchpad pad;
	StellarisPort port1(SYSCTL_PERIPH_GPIOD);
	StellarisPort port2(SYSCTL_PERIPH_GPIOE);
	//
	// Create a set of objects representing the output pins
	//
	StellarisPortPin clock(GPIO_PORTD_BASE, GPIO_PIN_1);
	StellarisPortPin shift(GPIO_PORTD_BASE, GPIO_PIN_2);
	StellarisPortPin chipSelect(GPIO_PORTD_BASE, GPIO_PIN_3);
	StellarisPortPin a(GPIO_PORTE_BASE, GPIO_PIN_1);
	StellarisPortPin b(GPIO_PORTE_BASE, GPIO_PIN_2);
	StellarisPortPin c(GPIO_PORTE_BASE, GPIO_PIN_3);

	//
	// Create and initialise the LedArrayDriver
	//
	LedArrayDriver led(&clock, &chipSelect, &shift, &a,&b,&c, NBR_OF_DISPLAY_ROWS, NBR_OF_DISPLAY_COLUMNS);
	led.init();

	AsciiMessage welcome("**** Welcome to the Museum of Computing - open Fridays 10am to 4pm and Saturdays 9:30am to 5pm ****");
	AsciiMessage exhib1("**** Visit our \"Gaming on the Go\" exhibition - 35 years of handheld games consoles ****");
	AsciiMessage retroGaming("**** Join our computer games sessions on Saturdays for some retro gaming ****");
	AsciiMessage website("**** See us on the web at http://www.museum-of-computing.org.uk/ ****");
	AsciiMessage hackspace("**** Join the Swindon Hackspace at the Museum of Computing - Wednesdays 6:30pm to 10pm ****");
	AsciiMessage compClub("**** Ask about our Kids Computer Club on Saturdays ****");
	AsciiMessage schoolVisit("**** Arrange a school visit and take part in a tour of the museum, quizzes and mini projects ****");
	AsciiMessage shop("**** Our shop has a range of gifts and souvenirs ****");

	RepeatedGraphic multiInvader(invader, 10, 8);
	AnimatedGraphic pacman(animPacman, 17, 7);// columns * frames
	AnimatedGraphic invader(animInvader, 11, 4);// columns * frames


	LeftScroller scrollLeft1(led, invader, 2, displayBuffer);
	LeftScroller scrollLeft2(led, welcome, 1, displayBuffer);
	LeftScroller scrollLeft3(led, exhib1, 1, displayBuffer);
	LeftScroller scrollLeft4(led, multiInvader, 1, displayBuffer);
	LeftScroller scrollLeft5(led, retroGaming, 1, displayBuffer);
	LeftScroller scrollLeft6(led, pacman, 1, displayBuffer);
	LeftScroller scrollLeft7(led, compClub, 1, displayBuffer);
	LeftScroller scrollLeft8(led, schoolVisit, 1, displayBuffer);
	LeftScroller scrollLeft9(led, website, 1, displayBuffer);
	LeftScroller scrollLeft10(led, shop, 1, displayBuffer);
	LeftScroller scrollLeft11(led, hackspace, 1, displayBuffer);
	do
	{
		scrollLeft1.init();  while(scrollLeft1.animate());
		scrollLeft2.init();  while(scrollLeft2.animate());
		scrollLeft3.init();  while(scrollLeft3.animate());
		scrollLeft4.init();  while(scrollLeft4.animate());
		scrollLeft5.init();  while(scrollLeft5.animate());
		scrollLeft6.init();  while(scrollLeft6.animate());
		scrollLeft7.init();  while(scrollLeft7.animate());
		scrollLeft8.init();  while(scrollLeft8.animate());
		scrollLeft9.init();  while(scrollLeft9.animate());
		scrollLeft10.init(); while(scrollLeft10.animate());
		scrollLeft11.init(); while(scrollLeft11.animate());
	} while(1);
}