Example #1
0
int main() {
	int input;
	printf("Welcome!\n");
	printf("1. Single Player\n");
	printf("2. Multiplayer\n");
	printf("3. Load Game\n");
	printf("4. Exit\n");
	printf("Selection:");
	scanf("%d", &input);
	switch (input) {
		case 1:
		singleplayer();
		break;
		case 2:
		multiplayer();
		break;
		case 3:
		loadgame();
		break;
		case 4:
		printf("Thanks for playing!\n");
		break;
		default:
		printf("Bad input, quitting!\n");
		break;
	}
	return 0;
}
bool game_config_manager::init_game_config(FORCE_RELOAD_CONFIG force_reload)
{
	// Add preproc defines according to the command line arguments.
	game_config::scoped_preproc_define multiplayer("MULTIPLAYER",
		cmdline_opts_.multiplayer);
	game_config::scoped_preproc_define test("TEST", cmdline_opts_.test);
	game_config::scoped_preproc_define editor("EDITOR", jump_to_editor_);
	game_config::scoped_preproc_define title_screen("TITLE_SCREEN",
		!cmdline_opts_.multiplayer && !cmdline_opts_.test && !jump_to_editor_);

	load_game_config(force_reload);

	game_config::load_config(game_config_.child("game_config"));

	hotkey::deactivate_all_scopes();
	hotkey::set_scope_active(hotkey::SCOPE_GENERAL);
	hotkey::set_scope_active(hotkey::SCOPE_GAME);

	hotkey::load_hotkeys(game_config(), true);
	::init_textdomains(game_config());
	about::set_about(game_config());
	ai::configuration::init(game_config());

	return true;
}
Example #3
0
void GameMenu::setConnections()
{
    connect(this->buttons[0], SIGNAL(clicked()), this, SLOT(singleplayer()));
    connect(this->buttons[1], SIGNAL(clicked()), this, SLOT(multiplayer()));
    connect(this->buttons[2], SIGNAL(clicked()), glView, SLOT(quit()));
    connect(this->buttons[3], SIGNAL(clicked()), this, SLOT(getPaddle()));
    connect(this->buttons[4], SIGNAL(clicked()), this, SLOT(unpause()));
    connect(this->buttons[5], SIGNAL(clicked()), this, SLOT(reset()));
    connect(this->buttons[6], SIGNAL(clicked()), this, SLOT(reset()));
}
Example #4
0
    void update()
    {
        bool updating = lastmillis-updatemillis > 100; // fixed rate logic at 10fps
		loopv(players) if(players[i]->ai)
		{
            if(updating && updatemillis < lastmillis)
            {
                avoid();
                forcegun = multiplayer(false) ? -1 : aiforcegun;
                updatemillis = lastmillis;
            }
			if(!intermission) think(players[i], updating);
			else players[i]->stopmoving();
		}
    }
Example #5
0
void loadstate(char *fn)
{
    stop();
    if(multiplayer()) return;
    f = gzopen(fn, "rb9");
    if(!f) { conoutf("could not open %s", fn); return; };
    
    string buf;
    gzread(f, buf, 8);
    if(strncmp(buf, "CUBESAVE", 8)) goto out;
    if(gzgetc(f)!=islittleendian) goto out;     // not supporting save->load accross incompatible architectures simpifies things a LOT
    if(gzgeti()!=SAVEGAMEVERSION || gzgeti()!=sizeof(dynent)) goto out;
    string mapname;
    gzread(f, mapname, _MAXDEFSTR);
    nextmode = gzgeti();
    changemap(mapname); // continue below once map has been loaded and client & server have updated 
    return;
    out:    
    conoutf("aborting: savegame/demo from a different version of cube or cpu architecture");
    stop();
};
Example #6
0
void loadstate(char *fn) {
	stop();
	if (multiplayer())
		return;
	f = gzopen(fn, "rb9");
	if (!f) {
		conoutf("could not open %s", fn);
		return;
	};

	char buf[_MAXDEFSTR];
	gzread(f, buf, 8);
	// not supporting save->load accross incompatible architectures simpifies things a LOT
	if (strncmp(buf, "CUBESAVE", 8) || gzgetc(f) != islittleendian || gzgeti() != SAVEGAMEVERSION || gzgeti() != sizeof(Sprite)) {
		conoutf("aborting: savegame/demo from a different version of cube or cpu architecture");
		stop();
	} else {
		memset(buf, 0, _MAXDEFSTR);
		gzread(f, buf, _MAXDEFSTR);
		nextmode = gzgeti();
		changemap(std::string(buf)); // continue below once map has been loaded and client & server have updated
	}
}
Example #7
0
File: main.cpp Project: Saarg/ISN
int main()
{
    // Create the main window
    sf::RenderWindow window(sf::VideoMode(800, 900), "SFML window");   //creation d'une fenetre de 800/900
    window.setFramerateLimit(60);                                      //limite le programme a 60 fps

    mapping backgroung;

    sf::Font font;
    if (!font.loadFromFile("foughtknight.ttf"))                        //police d'écriture
        return EXIT_FAILURE;

    sf::Text texttitle("SpaceShoot", font, 50);

    sf::Text text[5];
    text[0]=sf::Text("solo", font, 50 );
    text[1]=sf::Text("duel", font, 50 );
    text[2]=sf::Text("multijoueur", font, 50 );
    text[3]=sf::Text("options", font, 50 );
    text[4]=sf::Text("quitter", font, 50 );                            //tableau de caractere

    int a(0);                                                          //a ---> la variable permettant de naviguer dans le menu

    texttitle.setPosition(window.getSize().x/2-(texttitle.getGlobalBounds().width)/2, 100);

    text[0].setPosition(window.getSize().x/2-(text[0].getGlobalBounds().width)/2, 250);
    text[1].setPosition(window.getSize().x/2-(text[1].getGlobalBounds().width)/2, 300);
    text[2].setPosition(window.getSize().x/2-(text[2].getGlobalBounds().width)/2, 350);
    text[3].setPosition(window.getSize().x/2-(text[3].getGlobalBounds().width)/2, 400);
    text[4].setPosition(window.getSize().x/2-(text[4].getGlobalBounds().width)/2, 450); //position des textes

    float x=10, y=50;
    float A=(-4*y)/(x*x), B=-(-4*y)/x;
    sf::VertexArray propul(sf::Points, x*y);
    for(int i = 0 ; i < y ; i++)
    {
        for(int j = 0 ; j < x ; j++)
        {
            float YMAX=A*(j*j)+B*j;

            int alpha = 255-(i/YMAX)*255;
            if(alpha<0)
                alpha = 0;

            int R = 255;
            int G = 100;
            int B = 70;

            propul[i*x+j].position = sf::Vector2f(j, y-i);
            propul[i*x+j].color = sf::Color(R, G, B, alpha);
        }
    }

    // Start the game loop
    while (window.isOpen())
    {
        // Process events
        sf::Event event;
        text[a].setColor(sf::Color::White);
        while (window.pollEvent(event))
        {
            // Close window : exit
            if (event.type == sf::Event::Closed)
                window.close();
            else if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Up))//touche Z ou haut
                a=a-1;
            else if ((event.type == sf::Event::KeyPressed) && (event.key.code == sf::Keyboard::Down))
                a=a+1;
        }
        if(a<0 )//condition
            a =4;
        else if(a>4.4 )
            a =0;
        text[a].setColor(sf::Color::Red);

        if(sf::Keyboard::isKeyPressed(sf::Keyboard::Return))//sionfaitentré
        {
            switch(a)
            {
            case 0:
                solo(&window);
                break;

            case 1:
                break;

            case 2:
                multiplayer(&window);
                break;

            case 3:
                break;

            case 4:
                window.close();
                break;

            }
        }


        window.clear();
        backgroung.Draw(&window);
        window.draw(texttitle);

        for(int i=0; i<=4; i++)
            window.draw(text[i]);

        window.display();
    }
}
Example #8
0
    void renderscoreboard(g3d_gui &g, bool firstpass)
    {
        const ENetAddress *address = connectedpeer();
        if(showservinfo && address)
        {
            string hostname;
            if(enet_address_get_host_ip(address, hostname, sizeof(hostname)) >= 0)
            {
                if(servinfo[0]) g.titlef("%.25s", 0xFFFF80, NULL, servinfo);
                else g.titlef("%s:%d", 0xFFFF80, NULL, hostname, address->port);
            }
        }
     
        g.pushlist(0);
        g.text(server::modename(gamemode), 0xFFFF80);
        g.separator();
        const char *mname = getclientmap();
        g.text(mname[0] ? mname : "[new map]", 0xFFFF80);
        if(m_timed && mname[0] && (maplimit >= 0 || intermission))
        {
            g.separator();
            if(intermission) g.text("intermission", 0xFFFF80);
            else 
            {
                int secs = max(maplimit-lastmillis, 0)/1000, mins = secs/60;
                secs %= 60;
                g.pushlist();
                g.strut(mins >= 10 ? 4.5f : 3.5f);
                g.textf("%d:%02d", 0xFFFF80, NULL, mins, secs);
                g.poplist();
            }
        }
        if(paused || ispaused()) { g.separator(); g.text("paused", 0xFFFF80); }
        g.poplist();

        g.separator();
 
        int numgroups = groupplayers();
        loopk(numgroups)
        {
            if((k%2)==0) g.pushlist(); // horizontal
            
            scoregroup &sg = *groups[k];
            int bgcolor = sg.team && m_teammode ? (isteam(player1->team, sg.team) ? 0x3030C0 : 0xC03030) : 0,
                fgcolor = 0xFFFF80;

            g.pushlist(); // vertical
            g.pushlist(); // horizontal

            #define loopscoregroup(o, b) \
                loopv(sg.players) \
                { \
                    fpsent *o = sg.players[i]; \
                    b; \
                }    

            g.pushlist();
            if(sg.team && m_teammode)
            {
                g.pushlist();
                g.background(bgcolor, numgroups>1 ? 3 : 5);
                g.strut(1);
                g.poplist();
            }
            g.text("", 0, " ");
            loopscoregroup(o,
            {
                if(o==player1 && highlightscore && (multiplayer(false) || demoplayback || players.length() > 1))
                {
                    g.pushlist();
                    g.background(0x808080, numgroups>1 ? 3 : 5);
                }
                const playermodelinfo &mdl = getplayermodelinfo(o);
                const char *icon = sg.team && m_teammode ? (isteam(player1->team, sg.team) ? mdl.blueicon : mdl.redicon) : mdl.ffaicon;
                g.text("", 0, icon);
                if(o==player1 && highlightscore && (multiplayer(false) || demoplayback || players.length() > 1)) g.poplist();
            });
            g.poplist();

            if(sg.team && m_teammode)
            {
                g.pushlist(); // vertical

                if(sg.score>=10000) g.textf("%s: WIN", fgcolor, NULL, sg.team);
                else g.textf("%s: %d", fgcolor, NULL, sg.team, sg.score);

                g.pushlist(); // horizontal
            }

            if(!cmode || !cmode->hidefrags())
            { 
                g.pushlist();
                g.strut(7);
                g.text("frags", fgcolor);
                loopscoregroup(o, g.textf("%d", 0xFFFFDD, NULL, o->frags));
                g.poplist();
            }

            if(multiplayer(false) || demoplayback)
            {
                if(showpj)
                {
                    g.pushlist();
                    g.strut(6);
                    g.text("pj", fgcolor);
                    loopscoregroup(o,
                    {
                        if(o->state==CS_LAGGED) g.text("LAG", 0xFFFFDD);
                        else g.textf("%d", 0xFFFFDD, NULL, o->plag);
                    });
                    g.poplist();
                }
        
                if(showping)
                {
                    g.pushlist();
                    g.text("ping", fgcolor);
                    g.strut(6);
                    loopscoregroup(o, 
                    {
                        fpsent *p = o->ownernum >= 0 ? getclient(o->ownernum) : o;
                        if(!p) p = o;
                        if(!showpj && p->state==CS_LAGGED) g.text("LAG", 0xFFFFDD);
                        else g.textf("%d", 0xFFFFDD, NULL, p->ping);
                    });
                    g.poplist();
                }
Example #9
0
                d->ai->views[1] = viewfieldy(d->skill);
                d->ai->views[2] = viewdist(d->skill);
            }
        }
        else if(d->ai) destroy(d);
    }

    void update()
    {
        if(intermission) { loopv(players) if(players[i]->ai) players[i]->stopmoving(); }
        else // fixed rate logic done out-of-sequence at 1 frame per second for each ai
        {
            if(totalmillis-updatemillis > 1000)
            {
                avoid();
                forcegun = multiplayer(false) ? -1 : aiforcegun;
                updatemillis = totalmillis;
            }
            if(!iteration && totalmillis-itermillis > 1000)
            {
                iteration = 1;
                itermillis = totalmillis;
            }
            int count = 0;
            loopv(players) if(players[i]->ai) think(players[i], ++count == iteration ? true : false);
            if(++iteration > count) iteration = 0;
        }
    }

    bool checkothers(vector<int> &targets, fpsent *d, int state, int targtype, int target, bool teams)
    { // checks the states of other ai for a match