Ejemplo n.º 1
0
int main(int, char const**)
{
    // Create the main window
    RenderWindow window;
    window.create(VideoMode(800, 600), "Pong");

    
    
    //Create and initialize the actual game screen
    GameScreen gamescreen = GameScreen();
    gamescreen.initialize();
    
    
    // Start the game loop
    while (window.isOpen()) {
        
        // Process events
        Event p1;
        while (window.pollEvent(p1)) {
            // Close window: exit
            if (p1.type == Event::Closed) {
                window.close();
            }
            
        }
        

        // Clear screen
        window.clear();

        
        
        /*
         
         Here I am trying to use that standard game loop with initialize, update, and draw. If I ever try to make a real game in C++ I know that I will need to know how to use these methods and create objects outside of this class.
         
         */
        gamescreen.update();        
        
        //Draw each entity (sprite)
        for(Sprite ent : gamescreen.entities) {
            window.draw(ent);
        }
        
        
        
        // Update the window
        window.display();
    }

    return EXIT_SUCCESS;
}
Ejemplo n.º 2
0
Game::Game(void)
{
	ContextSettings settings;
	settings.antialiasingLevel = 8;

	okno.create(VideoMode(1280,720), "Nazwa Gry", Style::Default, settings);

	state = END;
	okno.setFramerateLimit(100);

	if (!font.loadFromFile("data/font.ttf"))
	{
		MessageBox(NULL, "Font not found! Chceck data folder!", "ERROR", NULL);
		return;
	}

	state = MENU;
}
Ejemplo n.º 3
0
Game::Game(void)
{
    ContextSettings settings;
    settings.antialiasingLevel = 8;

    window.create(VideoMode(1280,720),"Mechanized Techno Explorer",Style::Default,
                  settings);

    state = END;
    window.setFramerateLimit(100);

    if(!font.loadFromFile("data/Mecha.ttf"))
    {
        MessageBox(NULL,"Font not found!","ERROR",NULL);
        return;
    }

    state = MENU;
}
Ejemplo n.º 4
0
int main(int argc, char** argv) {
    
    

    
    globalvariables->running = true;

    
    
    window.create(VideoMode(800,600),"Quadcopter Project");
    
    window.setVerticalSyncEnabled(true);
    

    
   
    
     
    //thread CaptureThread(Capture);
    
    LoadingRender loadingrender(globalvariables);
    loadingrender.Load();
    
    globalvariables->currentrenderer = &loadingrender;
    Clock fps;
    while (globalvariables->running)
    {
        globalvariables->currentrenderer->Tick(window);
        
        

        
    }

    delete globalvariables;
    window.close();
    exit(EXIT_SUCCESS);



}
Ejemplo n.º 5
0
	bool init() {
		VideoMode videoMode(width, height);
		window.create(videoMode, "Break Out");
		window.setVerticalSyncEnabled(true);
		window.setFramerateLimit(FRAMES_PER_SECOND);

		 if (!font.loadFromFile("res\\stocky.ttf"))
            return false;  
 
        if (!soundBuffer1.loadFromFile("res\\blip.wav"))
            return false;
         
        if (!soundBuffer2.loadFromFile("res\\blam.wav"))
            return false;
         
        if (!soundBuffer3.loadFromFile("res\\blap.wav"))
            return false;
 
        if (!soundBuffer4.loadFromFile("res\\blop.wav"))
            return false;

		setup();
		return true;
	}
Ejemplo n.º 6
0
int main(int argc, char* argv[])
{
	setlocale(LC_ALL, "polish");
	string title = "Deltix v.";
	title += VERSION;
	///////////////////
	RenderWindow okno; //OKNO
	try
	{
		okno.create(VideoMode(RESOLUTION_WIDTH, RESOLUTION_HEIGHT, COLOR_DEPTH),
			title,
#if __MODE__ != 0
			Style::Fullscreen
#elif __MODE__ == 0
			Style::Default
#endif
			); //TWORZENIE OKNA
		okno.setFramerateLimit(200); //limit do 200fps
		okno.setMouseCursorVisible(false);
	}
	catch (...)
	{
		string temp = "BŁĄD - " + title;
		MessageBox(NULL, "Nie udało się utworzyć okna!", temp.c_str(), MB_OK | MB_ICONERROR);
		return 1;
	}
	
	/////////////////////
	
	States states = Splash;
	// PĘTLA
	while(okno.isOpen())
	{

		switch (states)
		{
		case Splash:
			
			if (SplashUpdate(&okno) < 0)

				states = Menu;
			break;
		case Menu:
			MenuUpdate(&okno);
			break;
		}


		Event eventMain;
		while (okno.pollEvent(eventMain))
		{
			if (eventMain.type == Event::Closed)
				okno.close(); // zamykanie
			/*if (eventMain.type == Event::KeyReleased && eventMain.key.code == Keyboard::C)
			{
				STARTUPINFO si;
				PROCESS_INFORMATION pi;

				ZeroMemory(&si, sizeof(si));
				si.cb = sizeof(si);
				ZeroMemory(&pi, sizeof(pi));
				CreateProcess(TEXT("C:\\WINDOWS\\System32\\calc.exe"), NULL, NULL, NULL, FALSE, CREATE_NEW_CONSOLE, NULL, NULL, &si, &pi);
			}*/ // SYSTEMOWY KALKULATOR pod "C"
			switch (states)
			{
			case Menu:
				MenuEvents(&okno, eventMain); //Eventy Menu
				break;
			}
				
		}//TABELA EVENTÓW
		
		if (states != Splash) drawPointer(&okno);
		okno.display();
	}

#if __DEBUG__ == 1
	system("pause");
#endif
	return 0;
}
Ejemplo n.º 7
0
int main()
{
    //-----------------------------
    RenderWindow window; //creates the main window
    window.create(VideoMode(SCREEN_WIDTH, SCREEN_HEIGHT), "SFML Works!"); //gives the main window attributes such as width, height, and a name
    //-----------------------------

    //-----------------------------
    window.setFramerateLimit(60);//sets frame rate (makes game speed faster/slower)
    //-----------------------------

    //-----------------------------
    RectangleShape mybox; //A rectangle shape
    mybox.setFillColor(Color::Red); //sets color
    mybox.setSize(Vector2f(20,30)/*an xy coordinate using float*/); //sets size
    mybox.setPosition(0,0); //sets position using the upper left corner of the box by default
    //-----------------------------


    //-----------------------------
    while (window.isOpen()) //the almighty gameloop (Keeps game running until gameover)
    {
        Event event; //creates an event, so we have access to it's many wonderful functions
        while (window.pollEvent(event))// event loop (constantly checks for user inputs and queues the actions)
        {
            switch (event.type)// checks the type of the event...
            {
            case Event::Closed: //closed event, triggered by clicking the X button
                window.close(); //closes the window
                break;

                // key pressed
            case Event::KeyPressed: //KeyPressed event, triggered by pressing any key
                switch (event.key.code) //takes in user inputs and performs actions
                {
                case Keyboard::Escape: //if esc button is pressed...
                    window.close();//close the window
                    break;

                case Keyboard::W://if W is pressed...
                    mybox.move(Vector2f(0,-5));//move the box up
                    break;

                case Keyboard::A://if A is pressed...
                    mybox.move(Vector2f(-5,0));//move the box left
                    break;

                case Keyboard::S://if S is pressed...
                    mybox.move(Vector2f(0,5));//move the box down
                    break;

                case Keyboard::D://if D is pressed...
                    mybox.move(Vector2f(5,0));//move the box right
                    break;

                default:
                    break;
                }//end of switch (event.key.code)
                break;

            default:
                break;
            }//end of switch (event.type)
        }//end of while (window.pollEvent(event))


        //~~~~~~~~~~~~~~~
        process();
        //~~~~~~~~~~~~~~~


        //~~~~~~~~~~~~~~~
        window.clear();//clears the screen
        window.draw(mybox);//draws your box shape on the screen (note: invisible unless displayed)
        //window.display();//displays what ever you drew.
        //~~~~~~~~~~~~~~~

    }//end of while (window.isOpen())

    //-----------------------------

}//end of int main()