コード例 #1
0
bool FrameFunc()
{
	float delta = hge->Timer_GetDelta();



	if (hge->Input_KeyDown(VK_F5))
		Save_Game();
	if (hge->Input_KeyDown(VK_F6))
		Load_Game();



	//Background
	if(g_vBGPosition.x> 0) g_vBGPosition.x -= BACKGROUND_SCROLLING_SPEED;
	else g_vBGPosition	= hgeVector(1780,0);

	if (hge->Input_KeyDown(VK_ESCAPE))
		isMenuActivate = !isMenuActivate;
	if (isMenuActivate)
	{
		int id = gui->Update(delta);
		switch (id)
		{
		case 1:
			isMenuActivate = false;
			break;
		case 2:
			Load_Game();
			isMenuActivate = false;
			break;
		case 3:
			Save_Game();
			break;
		case 4:
			MessageBox(0, (LPCSTR)"This game was created by \nMOROZOV Dima(Kypoptnik/mimmimmimmim\n)", (LPCSTR)"Credits", WM_CLOSE);
			break;

		case 5: return true;
		}
		return false;
	}


	//Explosionsdeleteanimation
	for(auto i = Explosions.begin(); i != Explosions.end();)
	{
		if((*i).Animation->GetFrame() == 2)
		{
			delete (*i).Animation;
			i = Explosions.erase(i);
		}
		else 
		{
			(*i).Animation->Update(delta);
			i++;
		}
	}
		double nitr=0.18;
	//Enemies 
	int ij=1;
	if (score>10){
	nitr=nitr+0.04;
	ij++;}
	if(score>50)
		{
	nitr=nitr+0.04;
		ij++;}
	if(score>100)
		{
	nitr=nitr+0.04;
		ij++;}
	if(score>200)
		{
	nitr=nitr+0.04;
		ij++;}
	if(score>500)
		{
	nitr=nitr+0.04;
		ij++;}
	if(score>1000)
		{
	nitr=nitr+0.04;
		ij++;}
	if(score>1500)
		{
		nitr=nitr+0.04;
		ij++;}
	level=ij;


	
	for (int i=Enemies.size();i < ij;i++)
	{

		enemy* Enemy = new enemy(hgeVector(hge->Random_Int(1200,1690), hge->Random_Int(60,530)), 
								hgeVector(-hge->Random_Int(1,7), hge->Random_Int(-3,2)),
								g_tEColors[hge->Random_Int(0,4)],
								(nitr));
		Enemies.push_back(Enemy);
	}

	for(auto i = Enemies.begin(); i != Enemies.end();)
	{
		if((*i)->GetPosition().x < -	100 || (*i)->GetPosition().y > 1680 || (*i)->GetPosition().y < 20)
		{
			score++;
			delete (*i);
			i = Enemies.erase(i);
		}
		else
		{
			(*i)->Update(delta);
			i++;
		}
	}
	
	//Player
	Player1->Update(delta);

	//Enemy vs Player
	for(auto i = Enemies.begin(); i != Enemies.end();) //
	{
		if((*i)->GetBoundingBox().Intersect(&Player1->GetBoundingBox()))  //Intersect _ проверяет координаты
		{
			CreateExplosion((*i)->GetPosition());
			score-=8;

			delete (*i);
			i = Enemies.erase(i);

			Player1->SetPosition(hgeVector(150,268));
			Player1->SetVelocity(hgeVector(0,0));
		}
		else i++;
	}

	//Enemy vs Enemy

	for(int i =0; i<Enemies.size(); i++) //
	{
		for (int j= i+1; j<Enemies.size();j++)
		{
			if(Enemies[i]->GetBoundingBox().Intersect(&(Enemies[j]->GetBoundingBox())))  //Intersect _ проверяет координаты
			{
				//CreateExplosion((*i)->GetPosition());
				CreateExplosion((Enemies[i])->GetPosition());
				delete (Enemies[j]);
				Enemies.erase(Enemies.begin()+j);
				delete (Enemies[i]);
				Enemies.erase(Enemies.begin()+i);
				break;
				break;
			}
		}
	}


	//Score
	if(score<=0)
	{
		score =0;
	}
	return false;


}
コード例 #2
0
ファイル: inputs.c プロジェクト: dafyddcrosby/meka
//-----------------------------------------------------------------------------
// Inputs_Check_GUI ()
// Check for GUI related inputs
//-----------------------------------------------------------------------------
// Note: 'sk1100_pressed' tells if SK-1100 emulation has taken a key yet.
// Specific checks are being done here to avoid collision.
//-----------------------------------------------------------------------------
void        Inputs_Check_GUI (bool sk1100_pressed)
{
    // Update INPUTS configuration in priority, since it eat some keys
    Inputs_CFG_Update(&Inputs_CFG);
    //Inputs_CFG_Map_Change_Update();
    //if (Inputs_CFG.active)
    //    Inputs_CFG.Box->update ();

    switch (key_shifts & (KB_CTRL_FLAG | KB_ALT_FLAG | KB_SHIFT_FLAG))
    {
    case 0: // No modifiers
        {
            // State save/load
            if (Inputs_KeyPressed (KEY_F5, FALSE))
                Save_Game ();
            if (Inputs_KeyPressed (KEY_F7, FALSE))
                Load_Game ();

            // State change slot
            /*
            if (cur_drv->id != DRV_COLECO)
                if (!gui.box_z_ordered[0]->focus_inputs_exclusive) // check note in inputs_u.c::Inputs_Emulation_Update()
                {
                    if (Inputs_KeyPressed (KEY_0, FALSE))  Save_Set_Slot (0);
                    if (Inputs_KeyPressed (KEY_1, FALSE))  Save_Set_Slot (1);
                    if (Inputs_KeyPressed (KEY_2, FALSE))  Save_Set_Slot (2);
                    if (Inputs_KeyPressed (KEY_3, FALSE))  Save_Set_Slot (3);
                    if (Inputs_KeyPressed (KEY_4, FALSE))  Save_Set_Slot (4);
                    if (Inputs_KeyPressed (KEY_5, FALSE))  Save_Set_Slot (5);
                    if (Inputs_KeyPressed (KEY_6, FALSE))  Save_Set_Slot (6);
                    if (Inputs_KeyPressed (KEY_7, FALSE))  Save_Set_Slot (7);
                    if (Inputs_KeyPressed (KEY_8, FALSE))  Save_Set_Slot (8);
                    if (Inputs_KeyPressed (KEY_9, FALSE))  Save_Set_Slot (9);
                }
            */
            if (Inputs_KeyPressed_Repeat (KEY_F6, FALSE, 30, 3)) 
                Save_Set_Slot (opt.State_Current - 1);
            if (Inputs_KeyPressed_Repeat (KEY_F8, FALSE, 30, 3)) 
                Save_Set_Slot (opt.State_Current + 1);

            // Blitters switch
            if (Inputs_KeyPressed (KEY_F1, FALSE))    
                Blitters_SwitchNext();

            // Speed & Frame skip 
            if (Inputs_KeyPressed (KEY_F2, FALSE))
                Frame_Skipper_Switch ();
            if (Inputs_KeyPressed (KEY_F3, FALSE))
                Frame_Skipper_Configure (-1);
            if (Inputs_KeyPressed (KEY_F4, FALSE))
                Frame_Skipper_Configure (1);

            // Input peripheral
            if (Inputs_KeyPressed (KEY_F9, FALSE))
                Inputs_Peripheral_Next (PLAYER_1);

            // Switch mode (Fullscreen <-> GUI)
            if (Inputs_KeyPressed (Inputs.Cabinet_Mode ? KEY_F10 : KEY_ESC, FALSE))
                Action_Switch_Mode ();

            // Sprites Refresh switch
            if (Inputs_KeyPressed (KEY_F11, FALSE))
                Action_Switch_Layer_Sprites ();

            // Hard Pause
            if (Inputs_KeyPressed (KEY_F12, FALSE))
                Machine_Pause_Need_To = TRUE;
        }
        break;
    case KB_CTRL_FLAG:
        {
            // Easter egg: Tetris
            if (!sk1100_pressed && Inputs_KeyPressed (KEY_T, FALSE))
                Tetris_Start ();
            // Nintendon't - now removed because it is too violent
            #ifdef ARCH_DOS
                if (!sk1100_pressed && Inputs_KeyPressed (KEY_N, FALSE))     
                    Quit_Msg ("Nintendont.");
            #endif

            // Hard Pause
            if (Inputs_KeyPressed (KEY_F12, FALSE) || (!sk1100_pressed && Inputs_KeyPressed (KEY_P, FALSE)))
                Machine_Pause_Need_To = TRUE;
            // Hard Reset
            if (!sk1100_pressed && Inputs_KeyPressed (KEY_BACKSPACE, TRUE)) // Note: eat backspace to avoid triggering software reset as well
                Machine_Reset ();

            // CTRL-TAB cycle thru boxes with TAB_STOP flag
            if (Inputs_KeyPressed(KEY_TAB, FALSE))
            {
                int n;

                // Remove keypress
                // FIXME-KEYPRESS
                t_list *keypresses;
                for (keypresses = Inputs.KeyPressedQueue; keypresses != NULL; )
                {
                    t_key_press *keypress = keypresses->elem;
                    keypresses = keypresses->next;
                    if (keypress->scancode == KEY_TAB)
                        list_remove(&Inputs.KeyPressedQueue, keypress);
                }

                // Cycle focus
                for (n = gui.boxes_count - 1; n >= 0; n--)
                {
                    t_gui_box *b = gui.boxes_z_ordered[n];
                    if ((b->flags & GUI_BOX_FLAGS_TAB_STOP) && (b->flags & GUI_BOX_FLAGS_ACTIVE))
                    {
                        gui_box_set_focus(b);
                        break;
                    }
                }
            }

        }
        break;
   case KB_ALT_FLAG:
       {
           // SK-1100 Keyboard switch
           if (Inputs_KeyPressed (KEY_F9, FALSE))        
               Keyboard_Switch ();
           // Background Refresh switch
           if (Inputs_KeyPressed (KEY_F11, FALSE)) 
               Action_Switch_Layer_Background ();
           // Next frame (pause hack)
           if (Inputs_KeyPressed (KEY_F12, FALSE))
               Machine_Pause_Need_To = (machine & MACHINE_PAUSED) ? 2 : 1;

           if (!sk1100_pressed)
           {
               // FPS Counter switch
               if (Inputs_KeyPressed (KEY_F, FALSE))         
                   Frame_Skipper_Switch_FPS_Counter ();
               // Applets hotkeys
               if (Inputs_KeyPressed (KEY_L, FALSE))         FB_Switch ();
               if (Inputs_KeyPressed (KEY_O, FALSE))         Options_Switch ();
               if (Inputs_KeyPressed (KEY_M, FALSE))         TB_Message_Switch ();
               if (Inputs_KeyPressed (KEY_P, FALSE))         PaletteViewer_Switch();
               if (Inputs_KeyPressed (KEY_T, FALSE))         TileViewer_Switch ();
               if (Inputs_KeyPressed (KEY_I, FALSE))         TechInfo_Switch ();
               // Quit emulator
               if (Inputs_KeyPressed (KEY_X, FALSE))         
                   opt.Force_Quit = TRUE;
               // Hard Reset
               if (Inputs_KeyPressed (KEY_BACKSPACE, TRUE))  // Note: eat backspace to avoid triggering software reset as well
                   Machine_Reset ();

               // GUI fullscreen/windowed
                if (Inputs_KeyPressed (KEY_ENTER, FALSE))
                {
                    if (Meka_State == MEKA_STATE_FULLSCREEN)
                    {
                        t_video_driver *driver = VideoDriver_FindByDriverId(Blitters.current->driver);
                        if (driver && driver->drv_id_switch_fs_win)
                        {
                            // FIXME: Put that properly in blitter interface
                            // FIXME: Not saved anywhere... better than nothing anyway.
                            Blitters.current->driver = driver->drv_id_switch_fs_win;
                            Video_Setup_State();
                        }
                    }
                    else if (Meka_State == MEKA_STATE_GUI)
                    {
                        t_video_driver *driver = VideoDriver_FindByDriverId(g_Configuration.video_mode_gui_driver);
                        if (driver && driver->drv_id_switch_fs_win)
                        {
                            g_Configuration.video_mode_gui_driver = driver->drv_id_switch_fs_win;
                            Video_GUI_ChangeVideoMode(g_Configuration.video_mode_gui_res_x, g_Configuration.video_mode_gui_res_y, g_Configuration.video_mode_gui_depth);
                        }
                    }
                    return;
                }

           }
       }
       break;
    }

    // Quit emulator
    if (key [Inputs.Cabinet_Mode ? KEY_ESC : KEY_F10]) 
        opt.Force_Quit = TRUE;

    // Debugger switch
    #ifdef MEKA_Z80_DEBUGGER
        // Disabled when SK-1100 is emulated because of collision in usage of ScrollLock key
        // Actually on SC-3000 it is hardwired to NMI
        if (!Inputs.Keyboard_Enabled && Inputs_KeyPressed (KEY_SCRLOCK, TRUE))
        //if (!sk1100_pressed && Inputs_KeyPressed (KEY_SCRLOCK, TRUE))
            Debugger_Switch ();
    #endif

    // Screen capture
    if (Inputs_KeyPressed (KEY_PRTSCR, FALSE))
        Capture_Request();

    // SF-7000 Disk 21 Bomber Raid
    // if (Test_Key(KEY_W))
    //     PSG.Registers[6] = PSG.Registers[6] ^ 0x04;

    // Wonder Boy III, Current Song
    //if (key[KEY_J])
    //   Msg (0, "RAM[0xFF9] = %02X", RAM[0xFF9]);

    // Old video modes debugging
    // if (Test_Key(KEY_J)) BACK_AREA -= 0x100;
    // if (Test_Key(KEY_K)) BACK_AREA += 0x100;
    // if (Test_Key(KEY_U)) BACK_AREA -= 0x1;
    // if (Test_Key(KEY_I)) BACK_AREA += 0x1;
    // SG-1000 stuff
    // if (Test_Key(KEY_U)) SG_BACK_TILE -= 0x100;
    // if (Test_Key(KEY_I)) SG_BACK_TILE += 0x100;
    // if (Test_Key(KEY_O)) SG_BACK_TILE -= 0x2000;
}
コード例 #3
0
ファイル: Game.c プロジェクト: GURKE/Memory
int Mouse_Clicked(int *mod, int *card1, int *card2, struct Card *cards[], int amCards, SDL_Event event, int amplayers, int GameSizeX, int GameSizeY)
{
    int Types[] = { 1, 2 };
    int actcard = dist2object(&objects, event.button.x, event.button.y, Types, 2);

    if (objects[actcard].type == 2) // Button
    {
        switch (objects[actcard].button.Type) // Beenden
        {
        case 0:
            return -1;
        case 1:
            Save_Game(amplayers, amCards, cards, GameSizeX, GameSizeY);
            break;
        case 2:
            Load_Game();
            break;
        default:
            break;
        }
    }
    else
    {
        switch (*mod)
        {
        case 0:
        case 1: // tap card
            if (actcard > -1 && objects[actcard].enabled && !objects[actcard].card.visible)
            {
                if (*mod == 0)
                    *card1 = actcard;
                else
                    *card2 = actcard;

                objects[actcard].card.visible = 1;
                (*mod)++;
            }
            break;

        case 2: // Remove them or move them back
            if (objects[*card1].card.type == objects[*card2].card.type)
            {
                objects[*card1].enabled = 0;
                objects[*card2].enabled = 0;

                pairs[AktPlayer]++;

                char *c = (char *)malloc(sizeof(char));
                sprintf(c, "%d", pairs[AktPlayer]);
                objects[textfield[AktPlayer][1]].picture = Create_Picture_By_Text(objects[textfield[AktPlayer][1]].picture, concat(c, " pairs found"), 0);

                NuOfRePairs--;
                *c = (char *)malloc(sizeof(char));
                sprintf(c, "%d", NuOfRePairs);
                objects[PosOfReCards].picture = Create_Picture_By_Text(objects[PosOfReCards].picture, concat("Amount of remaining pairs: ", c), 0);

                if (NuOfRePairs == 0) // Game ends
                {
                    GameEnd(amplayers);
                }
            }
            else
            {
                objects[*card1].card.visible = 0;
                objects[*card2].card.visible = 0;

                char *c = (char *)malloc(sizeof(char));
                sprintf(c, "%d", AktPlayer + 1);
                objects[textfield[AktPlayer][0]].picture = Create_Picture_By_Text(objects[textfield[AktPlayer][0]].picture, concat("Player ", c), 0);

                AktPlayer++;
                if (AktPlayer == amplayers) AktPlayer = 0;

                sprintf(c, "%d", AktPlayer + 1);
                objects[textfield[AktPlayer][0]].picture = Create_Picture_By_Text(objects[textfield[AktPlayer][0]].picture, concat("Player ", c), 1);
            }
            *mod = 0;
            break;
        default:
            break;
        }
        paint_screen(_screen, &objects);
    }
}