Esempio n. 1
0
int main(int argc, char* argv[]) {
    if (!setupGLFW()) return 1;
    glfwWindowHint(GLFW_SAMPLES, 4);
    setupCoreGL();

    #ifndef __APPLE__
    const char* exePath = dirname(argv[0]);
    const char* resPath = "/Resources/";
    const int newPathLen = strlen(exePath) + strlen(resPath) + 1;
    char newPath[newPathLen];
    strcpy(newPath, exePath);
    strcat(newPath, resPath);

    int cwdError;
    if ((cwdError = chdir(newPath)) != 0) {
        perror(newPath);

        return 1;
    }
    #endif

    set_log_file(fopen("../Logs/uf.log", "a"));
    
    setDebug(DEBUG);
    setBind(DEBUG);
 
    #ifdef FULLSCREEN
    GLFWmonitor* monitor = glfwGetPrimaryMonitor();
    const GLFWvidmode* vidmode = glfwGetVideoMode(monitor);
    int width = vidmode->width;
    int height = vidmode->height;
    const char* title =  "Ultra Fighters";
    GLFWwindow* window = glfwCreateWindow(width, height, title, monitor, NULL);
    #else
    int width = 640;
    int height = 480;
    const char* title =  "Ultra Fighters";
    GLFWwindow* window = glfwCreateWindow(width, height, title, NULL, NULL);
    #endif

    if (!window) {
        log_msg(LOG_ERROR, "GLFW3 window creation failed.\n");
        
        return 1;
    }
    
    glfwSetInputMode(window, GLFW_CURSOR, GLFW_CURSOR_DISABLED);

    char cwd[PATH_MAX];
    getcwd(cwd, sizeof(cwd));

    log_msg(LOG_INFO, "#####################################\n");
    log_msg(LOG_INFO, "Started Ultra Fighters!\n");
    log_msg(LOG_INFO, "Current Working Directory: %s\n", cwd);
    log_msg(LOG_INFO, "Started loop!\n");
    
    GameScene scene(window);

    std::ifstream levelFile("levelname.txt");
    std::string levelName;
    std::getline(levelFile, levelName);
    WavefrontObject room(levelName.c_str());
    scene.addChild(&room);

    HUD hud;
    scene.addChild(&hud);

    SphereNode snode(glm::vec3(-2, 2, 4), 0.75); // @temp
    scene.addChild(&snode); // @temp

    Loop loop = Loop(&scene);
    loop.start();
    
    while (!glfwGetKey(window, GLFW_KEY_ESCAPE) && !glfwWindowShouldClose(window)) {
        glfwPollEvents();
    }
    
    log_msg(LOG_INFO, "Stopping program...\n");
    loop.stop();
    glfwTerminate();
    
    return 0;
}
Esempio n. 2
0
InputHandler::InputHandler() {
	mouseOffSet = 256;
	m_pDIObj = 0;
	m_pDIKeyboard = 0;
	m_pDIMouse = 0;
	//trigger sensitivity
	fireTriggerPoint = 100;
	//set binds
	setBind(binds::jump,DIK_SPACE);
	setBind(binds::legPower,DIK_C);
	setBind(binds::use,DIK_E);
	setBind(binds::headPower,DIK_Q);
	setBind(binds::pause,DIK_ESCAPE);
	setBind(binds::leftAttack,mouseOffSet);
	setBind(binds::leftAltAttack,DIK_R);
	setBind(binds::rightAttack,mouseOffSet+1);
	setBind(binds::rightAltAttack,DIK_F);
	setBind(binds::forward,DIK_W);
	setBind(binds::back,DIK_S);
	setBind(binds::left,DIK_A);
	setBind(binds::right,DIK_D);
	setBind(binds::sprint,DIK_LSHIFT);
	//set sensitivity
	for(int i = 0;i<4;++i) {
		sens[i].xSens = 1;
		sens[i].ySens = 1;
	}
	sens[4].xSens = 10;
	sens[4].ySens = 10;
}