void LevelLoader::CreateLevel(const std::string& filepath, jvis::InstancedSpriteSet* instance, bool active)
{
    _spriteSet = instance;
    ReadDefinitions(filepath);
    ReadLevel(filepath);
    BuildLevel(instance, active);
}
Example #2
0
void NewGame(void)
{
    do {
        ParseParam(ReadLevel());
        Game();
    } while (_level_resolved);
}
Example #3
0
void GoLevel(void)
/* pide un nivel y su c?digo de acceso y lo lanza si es v?lido */
{
    int n_password;

    _level = GetNumber("GO LEVEL\n\n\n\n\nLEVEL NUMBER: %s\n", 30);

    if (_level == 0) {
        _level = 1;
        return;
    }

    n_password = GetNumber("GO LEVEL\n\n\n\n\nACCESS CODE: %s\n", 999998);

    ParseParam(ReadLevel());

    if (n_password == 822994)
        GameEnd();
    else if (n_password != 170868 && _password != n_password) {
        _level = 1;

        strcpy(_text_mask, "GO LEVEL\n\n\n\n\nWRONG ACCESS CODE\n");

        for (;;) {
            DrawWaterVirtualScreen();
            DrawText();
            qdgdfv_dump_virtual_screen();

            qdgdfv_input_poll();

            if (_qdgdfv_key_escape || _qdgdfv_key_enter)
                break;
        }

        while (_qdgdfv_key_escape || _qdgdfv_key_enter)
            qdgdfv_input_poll();
    }
    else {
        do {
            Game();
            ParseParam(ReadLevel());
        } while (_level_resolved);
    }
}
Example #4
0
/*-----------------------------------------------------------------------------
 *  Main Function
 *  Initiates the graphics buffer, creates the window
 *-----------------------------------------------------------------------------*/
int main( int argc, char *argv[] )
{
    /* Seed the random number generator */
    srand(time(0));

    /* Initialize the drawing environment */
    glutInit( &argc, argv );

    /* Initialize the display mode */
    glutInitDisplayMode ( GLUT_DOUBLE | GLUT_MULTISAMPLE );

    /* Create an application window of a certain size */
    glutInitWindowSize( 850, 450 );

    /* Create an application window on the screen */
    glutCreateWindow( "Assignment #3: 2D Transformations" );

    /* Register the function that does drawing */
    glutDisplayFunc( Draw );

    /* Create the Keyboard callback */
    glutKeyboardFunc( Keyboard );

    /* Create the Mouse callbacks */
    glutMouseFunc( Mouse ); 
    glutMotionFunc( MouseMove );

    /* Create the Reshape callback */
    glutReshapeFunc( Reshape );

    /* Enable GL Properties */
    glEnable(GL_MULTISAMPLE);

    /* Register Exit Handler */
    atexit(ClearMemory);

    /* Initialize the House Shapes */
    InitShapes( );

    /* Add the transform */
    tlLevel.root = NULL;
    tlSelectedTransforms.root = NULL;
    tlAvailableTransforms.root = NULL;

    /* Open the file */
    file = fopen("level.dat", "r");
    ReadLevel(file, currentLevelString);

    /* Turn over control to OpenGL */
    glutMainLoop();

    return( 0 );  /* NOTE: this is here only for ANSI requirements */
}
Example #5
0
/*-----------------------------------------------------------------------------
 *  Keyboard
 *  Handles the keyboard input for each of the various buttons
 *-----------------------------------------------------------------------------*/
void Keyboard( unsigned char key, int x, int y )
{
    /* Determine which key is pressed */
    switch(key)
    {
        case 27: /* Escape the Program */
            exit(0);
            break;
        default: 
            if(gameComplete)
            {
                exit(EXIT_SUCCESS);
            }
            else if(levelComplete)
            {
                /* Clear the Lists */
                ClearList(&tlLevel);
                ClearList(&tlSelectedTransforms);
                ClearList(&tlAvailableTransforms);

                /* Load the next level */
                ReadLevel(file, currentLevelString);

                /* Reset the pointers */
                selectedIndex = 0;
                selectedNode = NULL;

                /* Clear the level */
                levelComplete = FALSE;
            }
            else /* Exit if another key was pressed */
                return;
    }

    /* Redraw the Display */
    glutPostRedisplay();
}
Example #6
0
void GamePlay () {
	DrawLine (0,500,800,500,GLOBAL_FRONTCOLOR);
	if (Objects==0 || DataBase[Objects-1][1]<=Width-40) {
		ReadLevel(CURRENT_LEVEL);
	 }

	 if (HeroIsDead==0) {
		if (isRestart==1) {
			HeroAngle=(HeroAngle+10)%360;
			HeroIsDead=CheckCollision();
			HeroY+=HeroFly;
			DrawHero (125,HeroY, HeroSides, HeroAngle, HeroColor);
		} else {
			DrawHero (125,HeroY,HeroSides,HeroAngle,GLOBAL_FRONTCOLOR);
		}
		if (TO_NEXT_LEVEL>0) {
			DrawText (Width-TO_NEXT_LEVEL,300,"jump to start new level",GLOBAL_FRONTCOLOR);
			if (TO_NEXT_LEVEL<500) {
				TO_NEXT_LEVEL+=2;
			} else {
				if ((Key==' ' || Arrow==28) && TO_NEXT_LEVEL<=504) {
					CURRENT_LEVEL++;
					HeroSides=CURRENT_LEVEL;
					if (CURRENT_LEVEL>MAX_LEVEL) MAX_LEVEL=CURRENT_LEVEL;
					GLOBAL_CHECKPOINT=0;
					TO_NEXT_LEVEL=505;
				}
				if (TO_NEXT_LEVEL>=505) {
					TO_NEXT_LEVEL+=2;
					if (TO_NEXT_LEVEL>1000) TO_NEXT_LEVEL=0;
				}
			}

		}

	  } else {
		GLOBAL_SPEED=0;
		DeltaSpeed=0;
		TO_NEXT_LEVEL=0;
		HeroIsDead++;
		DrawPew (125,HeroY,HeroIsDead,HeroColor);
		if (HeroIsDead>100) {
			 ResetLevel(CURRENT_LEVEL);
			 if (GLOBAL_CHECKPOINT==0) {
				isRestart=1;
				HeroY=100;
			 } else {
				isRestart=0;
				HeroY=SPAWN_Y+41-DeltaH[HeroSides];
				if (HeroSides>7) HeroY-=22;
			 }
			 HeroIsDead=0;
			 HeroFly=0;
			 if (HeroSides%2==0) {
				HeroAngle=360/(HeroSides*2);
			 } else {
				HeroAngle=0;
			 }
		}
	  }
	  if (Key=='f'&& CURRENT_LEVEL<3) {
		int i=0;
		Objects=0;
		for (i=0; i<11; i++) LevelProps[i][0]=0;
		isRestart=1;
		HeroIsDead=0;
		HeroY=100;
		HeroFly=1;
		TO_NEXT_LEVEL=0;
		GAME_TYPE=3;
		Panel=1;
	  }
	  if (Key==27) {
		GLOBAL_CHECKPOINT=0;
		int i=0;
		for (i=0; i<11; i++) ResetLevel (i);
		isRestart=1;
		HeroIsDead=0;
		HeroY=100;
		HeroFly=1;
		TO_NEXT_LEVEL=0;
		if (CURRENT_LEVEL<3) {
			GAME_TYPE=3;
			Panel=1;
			Key=' ';
		} else {
			GAME_TYPE=0;
		}
	  }
}