Ejemplo n.º 1
0
bool bScreen::blit(Dot in)
{
	SDL_Surface *temp = NULL;
	SDL_Surface *nScreen = NULL;
	SDL_Rect *player = new SDL_Rect;
	SDL_Rect pos;
	SDL_Rect offset;
	SDL_Rect camera;
	bool success = false;
	camera = in.getCamera();

	offset.x = 0;
	offset.y = 0;
	
	pos.x = (in.getx()) - (camera.x);
	pos.y = (in.gety())- (camera.y);
	temp = in.getPlayerImage(0);
	player->x = 10 + ((in.phase/2)*PLAYERSPRITEW);
	player->y = 3 + ((in.direction)*PLAYERSPRITEH);
	player->w = 20;
	player->h = 30;
	
	SDL_BlitSurface(this->background, &camera, this->screen, &offset);

	SDL_BlitSurface(temp , player, this->screen, &pos );
	
	
	//rember to ask about possible memory leak here 
	//	delete temp;

	return success;

}
void loop () {
	//Handle events on queue
	while( SDL_PollEvent( &e ) != 0 )
	{
		//User requests quit
		if( e.type == SDL_QUIT )
		{
			quit = true;
		}
		
		//Handle input for the dot
		dot.handleEvent( e );
	}
	
	//Calculate time step
	float timeStep = stepTimer.getTicks() / 1000.f;

	//Move for time step
	dot.move( timeStep );

	//Restart step timer
	stepTimer.start();

	//Clear screen
	SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
	SDL_RenderClear( gRenderer );

	//Render dot
	dot.render();

	//Update screen
	SDL_RenderPresent( gRenderer );
}
Ejemplo n.º 3
0
void loop () {
	//Handle events on queue
	while( SDL_PollEvent( &e ) != 0 )
	{
		//User requests quit
		if( e.type == SDL_QUIT )
		{
			quit = true;
		}
		
		//Handle input for the dot
		dot.handleEvent( e );
	}
	
	//Move the dot
	dot.move( tileSet );
	dot.setCamera( camera );

	//Clear screen
	SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
	SDL_RenderClear( gRenderer );

	//Render level
	for( int i = 0; i < TOTAL_TILES; ++i )
	{
		tileSet[ i ]->render( camera );
	}

	//Render dot
	dot.render( camera );

	//Update screen
	SDL_RenderPresent( gRenderer );
}
Ejemplo n.º 4
0
void
Worldmap::update_locked_nodes()
{
  // FIXME: This shouldn't be a polling function
  path_graph->graph.for_each_node(unlock_nodes(path_graph.get()));

#if 0
  bool credits_unlocked = false;
  StatManager::instance()->get_bool(worldmap.get_short_name() + "-endstory-seen", credits_unlocked);

  if (!credits_unlocked)
  {
    // See if the last level is finished
    Dot* dot = path_graph->get_dot(final_node);
    if (dot)
    {
      if (dot->finished())
      {
        ScreenManager::instance()->push_screen(new StoryScreen(worldmap.get_end_story()));
      }
    }
    else
    {
      log_info("Error: Worldmap: Last level missing");
    }
  }
#endif
}
Ejemplo n.º 5
0
Asteroid::Asteroid(int ast_size){
    int i, gen, dots, interval, angle, radius, min_radius, delta_radius;
    Asteroid* ast;
    Dot d;

    item = NULL;

    dots = 3*pow(2,ast_size);
    interval = 360/dots;
    min_radius = 10*pow(2,ast_size);
    delta_radius = 1.25*min_radius;

    //Generating vertex
    for(i=0; i<dots; i++){
        angle = rand()%interval + i*interval;
        radius = rand()%delta_radius + min_radius;

        d.setX(radius*cos(angle*PI/180));
        d.setY(radius*sin(angle*PI/180));
        loop_vertex.push_back(d);
    }


    if(ast_size != SMALL){

        //Generating subparts
        gen = rand()%2+2;
        while(gen>0){
            ast = new Asteroid(ast_size-1);
            d.setX(rand()%4-2);
            d.setY(rand()%4-2);
            ast->setSpeed(d);
            parts.push_back(ast);
            gen--;
        }
    }

    if(ast_size == BIG){
        //Generating item
        gen = rand()%(NUM_ITEMS*3);
        if(gen%3 == 0){
            item = new Item(gen/3);
            item->setSpeed(rand()%360, 0.25);
        }
    }

    //Adjusting centroid
    centralize();

    //setColor(0, 1, (float)(BIG - ast_size)/BIG);
    setColor(0, (GLfloat)(ast_size*0.125 + 0.75), (GLfloat)(0.25-ast_size*0.125));
    setHandling(1);

    if(rand()%2 == 0){
        commands[TURN_LEFT] = true;
    }
    else{
        commands[TURN_RIGHT] = true;
    }
}
Ejemplo n.º 6
0
float Dot::whichSide(Dot a, Dot b){
    float xa = a.getX();
    float ya = a.getY();
    float xb = b.getX();
    float yb = b.getY();

    return (xa*yb - ya*xb + y*(xb-xa) + x*(ya-yb));
}
Ejemplo n.º 7
0
void GraphicsScene::connectToNearest(Dot *start){
    if(!centersPointers.isEmpty()){
        Dot *end = nearestCenter(start);

        QGraphicsItem *newConnection = new Connection(start->getPosPointer(),end->getPosPointer());

        addItem(newConnection);
        start->setConnection(((Connection*)newConnection));
        update(QRectF(-50,-50,1000,1000));
    }
}
Ejemplo n.º 8
0
void ParticleEngineApp::update()
{
	if (int(app::getElapsedFrames()) % 120 == 0) {
		mDotLoc.x	= randFloat(0.0f, app::getWindowWidth());
		mDotLoc.y	= randFloat(0.0f, app::getWindowHeight());
		mDotCol		= ColorA(randFloat(), randFloat(), randFloat(), 1.0f);
	}
	if (mIsPressed) {
		mDot.addParticles(N_PARTICLES, mMouseLoc, mMouseVel);
	}
	mDot.update(mDotLoc, mDotCol);
}
Ejemplo n.º 9
0
int main( int argc, char* args[] ) {
  //Start up SDL and create window
  if( !init() ) {
    printf( "Failed to initialize!\n" );
  } else {
    //Load media
    if( !loadMedia() ) {
      printf( "Failed to load media!\n" );
    } else {
      //Main loop flag
      bool quit = false;

      //Event handler
      SDL_Event e;

      //The dot that will be moving around on the screen
      Dot dot;

      //While application is running
      while( !quit ) {
        //Handle events on queue
        while( SDL_PollEvent( &e ) != 0 ) {
          //User requests quit
          if( e.type == SDL_QUIT ) {
            quit = true;
          }

          //Handle input for the dot
          dot.handleEvent( e );
        }

        //Move the dot
        dot.move();

        //Clear screen
        SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
        SDL_RenderClear( gRenderer );

        //Render objects
        dot.render();

        //Update screen
        SDL_RenderPresent( gRenderer );
      }
    }
  }

  //Free resources and close SDL
  close();

  return 0;
}
Ejemplo n.º 10
0
void
Worldmap::draw(DrawingContext& gc)
{
  Vector2i pingu_pos(static_cast<int>(pingus->get_pos().x),
                     static_cast<int>(pingus->get_pos().y));
  int min, max;
  int width  = worldmap.get_width();
  int height = worldmap.get_height();

  if (width >= gc.get_width())
  {
    min = gc.get_width()/2;
    max = width - gc.get_width()/2;
  }
  else
  {
    min = width - gc.get_width()/2;
    max = gc.get_width()/2;
  }
  pingu_pos.x = Math::clamp(min, pingu_pos.x, max);

  if (height >= gc.get_height())
  {
    min = gc.get_height()/2;
    max = height - gc.get_height()/2;
  }
  else
  {
    min = height - gc.get_height()/2;
    max = gc.get_height()/2;
  }
  pingu_pos.y = Math::clamp(min, pingu_pos.y, max);

  gc_state.set_size(gc.get_width(), gc.get_height());
  gc_state.set_pos(Vector2i(pingu_pos.x, pingu_pos.y));

  gc_state.push(gc);

  for (auto i = drawables.begin (); i != drawables.end (); ++i)
  {
    (*i)->draw(gc);
  }

  Vector2f mpos = gc_state.screen2world(Vector2i(mouse_x, mouse_y));
  Dot* dot = path_graph->get_dot(mpos.x, mpos.y);
  if (dot)
    dot->draw_hover(gc);

  gc_state.pop(gc);
}
Ejemplo n.º 11
0
Dot* GraphicsScene::nearestCenter(Dot *dot){
    double nearestDistance = QRectF(-50,-50,1000,1000).width();
    Dot *nearestCenterPointer;
    for(int i = 0; i < centersPointers.size(); i++){
        Dot *center = centersPointers.at(i);
        double newDistance = distance(dot->getPos(),center->getPos());

        if(newDistance < nearestDistance){
            nearestDistance = newDistance;
            nearestCenterPointer = centersPointers.at(i);
        }
    }

    return nearestCenterPointer;
}
Ejemplo n.º 12
0
SDL_Rect sword :: get_position(Dot myDot, Setup foo)
{
    if(look_up)
    {
        box.x = myDot.box.x;
        box.y = (myDot.box.y - le) + properHeight;
        weaponsT.loadFromFile( "first_test12.bmp" );

    }

    else if(look_down && !myDot.is_onGround())                      ///very much so temp--- this should be its own move, once i get moves sorted :D
    {
        box.x = myDot.box.x;
        box.y = myDot.box.y + myDot.box.h;
        weaponsT.loadFromFile( "first_test11.bmp" );
    }

    else
    {

         if(!direction)
         {
             box.x = myDot.box.x +  trueWidth;
             weaponsT.loadFromFile( "first_test10.bmp" );
         }
         else
         {
             box.x = (myDot.box.x - 128) + (128 - trueWidth);
             weaponsT.loadFromFile( "first_test9.bmp" );
         }
         box.y = myDot.box.y + trueHeight/2;
         return box;
    }
}
Ejemplo n.º 13
0
SDL_Rect gun :: get_position(Dot myDot, Setup foo)
{
    if(look_up)
    {
        box.x = myDot.box.x;
        box.y = myDot.box.y;
        weapons2T.loadFromFile( "first_test16.bmp" );
    }

    else if(look_down && !myDot.is_onGround())                      ///very much so temp--- this should be its own move, once i get moves sorted :D
    {
        box.x = myDot.box.x;
        box.y = myDot.box.y + (myDot.box.h - speed);
        weapons2T.loadFromFile( "first_test15.bmp" );
    }

    else
    {

         if(!direction)
         {
             box.x = myDot.box.x +  (trueWidth - speed);
             weapons2T.loadFromFile( "first_test14.bmp" );
         }
         else
         {
             box.x = (myDot.box.x - 128) + (128 - trueWidth);
             weapons2T.loadFromFile( "first_test13.bmp" );
         }
         box.y = myDot.box.y + trueHeight/2;
    }
    return box;
}
Ejemplo n.º 14
0
void Polygon::draw(){
    unsigned int i;
    Dot d;

    glLoadIdentity();
    glTranslatef(position.getX(), position.getY(), 0);
    glRotated(direction, 0, 0, 1);
    glColor3f(color[RED], color[GREEN], color[BLUE]);
    glBegin(GL_LINES);
        for(i=0; i<lines_vertex.size(); i++){
            d = lines_vertex.at(i);
            glVertex2f(d.getX(), d.getY());
        }
    glEnd();
    glBegin(GL_LINE_STRIP);
        for(i=0; i<strip_vertex.size(); i++){
            d = strip_vertex.at(i);
            glVertex2f(d.getX(), d.getY());
        }
    glEnd();
    glBegin(GL_LINE_LOOP);
        for(i=0; i<loop_vertex.size(); i++){
            d = loop_vertex.at(i);
            glVertex2f(d.getX(), d.getY());
        }
    glEnd();
}
Ejemplo n.º 15
0
void
Worldmap::enter_level()
{
  NodeId node = get_pingus()->get_node();

  if (node != NoNode)
  {
    Dot* dot = path_graph->get_dot(node);
    if (dot)
    {
      dot->on_click();
    }
  }
  else
  {
    if (globals::developer_mode)
      log_info("Worldmap: Pingus not on level");
  }
}
void Picture::mousePressEvent(QMouseEvent *e)
{
    if (e->button() == Qt::LeftButton) {
           if (selectedPoints.size() < 8)
           {
               Dot* dot = new Dot(this);
               dot->show();
               update();
               dot->move(e->x(), e->y());
               Vector3i *newPoint = new Vector3i(e->x(), e->y(), 1);
               selectedPoints.push_back(*newPoint);
           }
           else
           {
               double w = (double)boardDimensions->x();
               double h = (double)boardDimensions->y();

               double divisor = w;
               if(w>h)
                divisor = h;

               w = ((double)boardDimensions->x()/divisor);
               h = ((double)boardDimensions->y()/divisor);

               realWorldPoints.push_back(Vector3d(0, 0, 1));
               realWorldPoints.push_back(Vector3d(0, h, 1));
               realWorldPoints.push_back(Vector3d(w, h, 1));
               realWorldPoints.push_back(Vector3d(w, 0, 1));

               // Calculate H Matrix
               MatrixXd H = Utils::calculateHomographyMatrix(selectedPoints, realWorldPoints);

               QImage inputImage = QImage("/home/fschuindt/dev/qt-persperctive-distortion-remotion/work-1/MyActions/brahma01.jpg");
               QImage outputImage = Utils::applyHomography(H, inputImage, vector<Vector3i>(selectedPoints.begin()+4, selectedPoints.end()));
               Utils::saveImage(outputImage, "/home/fschuindt/teste.jpg");

           }
    }

}
void loop () {
	//Handle events on queue
	while( SDL_PollEvent( &e ) != 0 )
	{
		//User requests quit
		if( e.type == SDL_QUIT )
		{
			quit = true;
		}

		//Handle input for the dot
		dot.handleEvent( e );
	}
	
	//Move the dot
	dot.move();

	//Scroll background
	--scrollingOffset;
	if( scrollingOffset < -gBGTexture.getWidth() )
	{
		scrollingOffset = 0;
	}

	//Clear screen
	SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
	SDL_RenderClear( gRenderer );

	//Render background
	gBGTexture.render( scrollingOffset, 0 );
	gBGTexture.render( scrollingOffset + gBGTexture.getWidth(), 0 );

	//Render objects
	dot.render();

	//Update screen
	SDL_RenderPresent( gRenderer );
}
Ejemplo n.º 18
0
void GraphicsScene::updateConnections(){
    int i = 0;
    while(i<items().size()){
        QGraphicsItem *activeItem = items().at(i);
        if(((CustomItem*)activeItem)->getName() == std::string("Connection")){
            removeItem(activeItem);
        }
        else{
            i++;
        }
    }
    i = 0;
    while(i<items().size()){
        QGraphicsItem *activeItem = items().at(i);
        if(((CustomItem*)activeItem)->getName() == std::string("Dot")){
            Dot *dot = ((Dot*)activeItem);
            if(!dot->isCenter()){
                connectToNearest(dot);
            }
        }
        i++;
    }
    update(QRectF(-50,-50,1000,1000));
}
Ejemplo n.º 19
0
void
Worldmap::on_primary_button_press(int x, int y)
{
  Vector2f click_pos = gc_state.screen2world(Vector2i(x, y));

  if (globals::developer_mode)
  {
    FileWriter writer(std::cout);
    writer.begin_mapping("leveldot");
    writer.write_string("levelname", "");
    writer.begin_mapping("dot");
    writer.write_string("name", "leveldot_X");
    writer.write_vector("position", click_pos);
    writer.end_mapping();
    writer.end_mapping();
    std::cout << std::endl;
    std::cout << std::endl;
  }

  Dot* dot = path_graph->get_dot(click_pos.x, click_pos.y);
  if (dot)
  {
    if (globals::developer_mode)
      log_info("Worldmap: Clicked on: %1%", dot->get_name());

    if (path_graph->lookup_node(dot->get_name()) == pingus->get_node())
    {
      if (globals::developer_mode)
        log_info("Worldmap: Pingu is on node, issue on_click()");
      dot->on_click();
    }
    else
    {
      if (dot->accessible())
      {
        if (!pingus->walk_to_node(path_graph->lookup_node(dot->get_name())))
        {
          if (globals::developer_mode)
            log_info("Worldmap: NO PATH TO NODE FOUND!");
        }
        else
        {
          StatManager::instance()->set_string(worldmap.get_short_name() + "-current-node", dot->get_name());
        }
      }
      else
      {
        Sound::PingusSound::play_sound("chink");
      }
    }
  }
}
Ejemplo n.º 20
0
void gun:: weaponControl(Dot myDot)
{
 // Uint8 *keystates = SDL_GetKeyState( NULL );
    Mix_PlayChannel( -1, gunSound, 0 );
    if(!direction)
    {
        right = true;
        left = false;
    }
    else
    {
        left = true;
        right = false;
    }

    if(up)
    {
         look_up = true;
         right = false;
         left = false;
    }

    else
    {
         look_up = false;
    }

    if(down && !myDot.is_onGround())
    {
         look_down = true;
    }

    else
    {
         look_down = false;
    }

    for( int p = 0; p < 20; p++ )
    {
        particles[ p ] = new Particle( box.x, box.y, 4);
    }

}
Ejemplo n.º 21
0
void Editor::draw(const Dot &dot)
{
    // Cross
    sf::RectangleShape horizontal(sf::Vector2f(7, 3)), vertical(sf::Vector2f(3, 7));
    horizontal.setPosition(dot.pos().x-3, dot.pos().y-1);
    vertical.setPosition(dot.pos().x-1, dot.pos().y-3);
    // Text
    sf::Text text(std::to_string(dot.number()), _font);
    text.setCharacterSize(12);
    text.setPosition(dot.pos().x - 5, dot.pos().y - 18);
    // Colors
    horizontal.setFillColor(sf::Color::Red);
    vertical.setFillColor(sf::Color::Red);
    text.setColor(sf::Color::Black);
    // Draw
    _window.draw(horizontal);
    _window.draw(vertical);
    _window.draw(text);
}
Ejemplo n.º 22
0
//if the player pushes against a movable tile then that tile will move
void mTile:: moveTile(Dot myDot , Tile *tiles[], mTile *mtiles[], turret *turrets[] ){
    Uint8 *keystates = SDL_GetKeyState( NULL );
    
    //if both the player and the block is on the ground
    if(myDot.touches_ground(myDot.box ,tiles, mtiles, turrets) == true && wall2ground(tiles, mtiles)== true)
    {
        //if the player presses x then the movement of the mtile is mapped to the player
        if(left_collision2(myDot.box, box)== true && get_type() == Push_Tile && keystates[ SDLK_x ])
        {   
             box.x = myDot.box.x + 50;
             pull = -1;
        }
        //this applies to both right and left collision
        else if(right_collision2(myDot.box, box)== true && get_type() == Push_Tile && keystates[ SDLK_x ])
        {  
             box.x = myDot.box.x - 80;
             pull = 1;
        }
    }
    // the break-away tile
    if( get_type() == break_Tile )
    {
        if(wall2ground(tiles, mtiles)== false && ground_collision(myDot.box, box))
        {
            trap = true;
        }
        //checks if the tile is not toucing the ground and the player colliding with it
        if(trap && wall2ground(tiles, mtiles)== false)
        {
            //if the so the tile falls until it hits the ground
            box.y += 10;    
        }
    }
    //if there is nothing under a mtile it will fall
    else if(wall2ground(tiles, mtiles)== false)
    {
        box.y += 10;
    }

}
Ejemplo n.º 23
0
int main ( int argc, char** argv )
{
    Setup setup1;
    //cerr << "address of Setup: " << &setup1 << '\n';
    ImageManager im1;
    SoundManager sm1;
    Dot myDot;
    World world1;
    cout << "rest of main \n";

    if(setup1.init() == false)
    {
        return 1;
    }
    //newScreen = setup1.getScreen();

    if(im1.loadFont() == false)
    {
        return 1;
    }


    if(im1.getFiles() == false)
    {
        cout << "error  loading images" << endl;
        return 1;
    }


    if(sm1.soundFiles() == false)
    {
        cout << "error loading sounds \n";
        return 1;
    }

    if(world1.set_tiles() == false)
    {
    	cout  << "error loading map \n";
    	return 1;
    }
    //Mix_Music* bgm = sm1.getTrack(0);
    // make sure SDL cleans up before exit
    atexit(SDL_Quit);

    // centre the bitmap on screen
    //SDL_Rect dstrect;
    //dstrect.x = (screen->w - bmp->w) / 2;
    //dstrect.y = (screen->h - bmp->h) / 2;

    Timer frames1;
    Timer delta;
    delta.start();

    // program main loop
    bool done = false;
    while (done == false)
    {
        frames1.start();
        // message processing loop
        SDL_Event event;
        while (SDL_PollEvent(&event))
        {
            //cout << &event << endl;
            //SDL_Event *e = &event;

            myDot.change_heading(event);
            myDot.handle_input(event);

            if(event.type == SDL_QUIT)
            {
                done = true;
            }
            // get keystates
            //Uint8 *keystates = SDL_GetKeyState(NULL);

            if(event.type == SDL_KEYDOWN)
            {

                if(event.key.keysym.sym == SDLK_p)
                {
                    if(Mix_PlayingMusic() == 0)
                    {
                        sm1.playAll();
                    }
                    else
                    {
                        if(Mix_PausedMusic() == 1)
                        {
                            Mix_ResumeMusic();
                        }
                        else
                        {
                            Mix_PauseMusic();
                        }
                    }
                }

                if(event.key.keysym.sym == SDLK_ESCAPE)
                {
                    done = true;
                }
            }
        }

        myDot.move(setup1, world1, delta.get_ticks());
        myDot.shoot(setup1);
        delta.start();
        myDot.setCamera(setup1);

        im1.drawAll(myDot, setup1, world1);
        myDot.showParticleD(im1, setup1);

        im1.drawPlayer(setup1, myDot);
        myDot.showBulletD(im1, setup1);



        /**
        Uint8 *keystates = SDL_GetKeyState(NULL);
        if(keystates[SDLK_p])
        {
            // key state template
        }
        **/


        //SDL_Surface* test = TTF_RenderText_Solid(im1.getFont(), "test", im1.getColour());
        //im1.applySurface(10, 10, test, newScreen);



        if(SDL_Flip(setup1.getScreen()) == -1)
        {
            return 1;
        }

        //framecount++;

        //cout << "frames" << SDL_GetTicks() << endl;

        if(frames1.get_ticks() < 1000 / setup1.getFPS())
        {
            SDL_Delay((1000 / setup1.getFPS()) - frames1.get_ticks());
            //cout << "delay" << 1000 / setup1.getFPS() - frames1.get_ticks();
        }

    }// end main loop

    //Mix_FreeMusic(bgm);
    setup1.freeScreen();
    im1.clean();
    sm1.cleanSound();

    // all is well ;)
    printf("Exited cleanly\n");
    return 0;
}
Ejemplo n.º 24
0
/*Foo::Foo()
{
          offSet = 0;
          velocity = 0;
          
          frame = 0;
          status = FOO_RIGHT;
}
void Foo::move()
{
     offSet += velocity;
     
     if( ( offSet < 0 ) || ( offSet + FOO_WIDTH > SCREEN_WIDTH ) )
         offSet -= velocity;
}
void Foo::show()
{
     if( velocity < 0 )
     {
         status = FOO_LEFT;
         
         frame++;
     }
     else if( velocity > 0 )
     {
          status = FOO_RIGHT;
          
          frame++;
     }
     else
         frame = 0;
         
     if( frame >= 4 )
         frame = 0;
         
     if( status == FOO_RIGHT )
         apply_surface( offSet, SCREEN_HEIGHT - FOO_HEIGHT, foo, screen, &clipsRight[frame] );
     else if( status == FOO_LEFT )
          apply_surface( offSet, SCREEN_HEIGHT - FOO_HEIGHT, foo, screen, &clipsLeft[frame] );
}
void Foo::handle_events()
{
    //If a key was pressed
    if( event.type == SDL_KEYDOWN )
    {
        //Set the velocity
        switch( event.key.keysym.sym )
        {
            case SDLK_RIGHT: velocity += FOO_WIDTH / 4; break;
            case SDLK_LEFT: velocity -= FOO_WIDTH / 4; break;
        }
    }
    //If a key was released
    else if( event.type == SDL_KEYUP )
    {
        //Set the velocity
        switch( event.key.keysym.sym )
        {
            case SDLK_RIGHT: velocity -= FOO_WIDTH / 4; break;
            case SDLK_LEFT: velocity += FOO_WIDTH / 4; break;
        }
    }
}

void set_clips()
{
     //clip the sprite sheet
     clipsRight[0].x = 0;
     clipsRight[0].y = 0;
     clipsRight[0].w = FOO_WIDTH;
     clipsRight[0].h = FOO_HEIGHT;
     
     clipsRight[1].x = FOO_WIDTH;
     clipsRight[1].y = 0;
     clipsRight[1].w = FOO_WIDTH;
     clipsRight[1].h = FOO_HEIGHT;
     
     clipsRight[2].x = FOO_WIDTH * 2;
     clipsRight[2].y = 0;
     clipsRight[2].w = FOO_WIDTH;
     clipsRight[2].h = FOO_HEIGHT;
     
     clipsRight[3].x = FOO_WIDTH * 3;
     clipsRight[3].y = 0;
     clipsRight[3].w = FOO_WIDTH;
     clipsRight[3].h = FOO_HEIGHT;
     
     clipsLeft[0].x = 0;
     clipsLeft[0].y = FOO_HEIGHT;
     clipsLeft[0].w = FOO_WIDTH;
     clipsLeft[0].h = FOO_HEIGHT;
     
     clipsLeft[1].x = FOO_WIDTH;
     clipsLeft[1].y = FOO_HEIGHT;
     clipsLeft[1].w = FOO_WIDTH;
     clipsLeft[1].h = FOO_HEIGHT;
     
     clipsLeft[2].x = FOO_WIDTH * 2;
     clipsLeft[2].y = FOO_HEIGHT;
     clipsLeft[2].w = FOO_WIDTH;
     clipsLeft[2].h = FOO_HEIGHT;
     
     clipsLeft[3].x = FOO_WIDTH * 3;
     clipsLeft[3].y = FOO_HEIGHT;
     clipsLeft[3].w = FOO_WIDTH;
     clipsLeft[3].h = FOO_HEIGHT;
}*/
int main( int argc, char* args[] )
{
     bool quit = false;
     
     int frame = 0;
     
     bool cap = true;
     
     Timer fps;
     Timer update;
     
     
     
     if( init() == false )
         return 1;
     
     if( load_files() == false )
         return 1;
     //set_clips();
     Dot myDot;
     
     update.start();
     
     while( quit == false)
     {
            fps.start();
            while( SDL_PollEvent(&event) )
            {
                   myDot.handle_input();
                                  
                   if( event.type == SDL_QUIT )
                       quit = true;
            }
            
            myDot.move();
            myDot.set_camera();
            //std::stringstream fpsm;
            //fpsm << "FPS: " << frame / ( fps.get_ticks() / 1000.f );
            apply_surface( 0, 0, background, screen, &camera );
            //SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0xFF, 0xFF, 0xFF ) );
            myDot.show();
            
            if( update.get_ticks() > 1000.f )
            {
                
                std::stringstream fpsm;
                
                fpsm << "FPS: " <<  ( frame );
                fpsmessage = TTF_RenderText_Solid(font, fpsm.str().c_str(), textColor );
                
                frame = 0;
                update.start();
            }
            apply_surface( 10, 10, fpsmessage, screen);
            if( SDL_Flip( screen ) == -1 )
                return 1;
            
            frame++;
            if( ( ( fps.get_ticks() ) < 1000 / FRAMES_PER_SECOND ) )
                SDL_Delay( ( 1000 / FRAMES_PER_SECOND ) - ( fps.get_ticks() ) );
                
            
        
     }
     
     clean_up();
     return 0;
}
Ejemplo n.º 25
0
int main( int argc, char* args[] )
{
	//Start up SDL and create window
	if( !init() )
	{
		printf( "Failed to initialize!\n" );
	}
	else
	{
		//Load media
		if( !loadMedia() )
		{
			printf( "Failed to load media!\n" );
		}
		else
		{	
			//Main loop flag
			bool quit = false;

			//Event handler
			SDL_Event e;

			//The background scrolling offset
            int scrollingOffset = 0;

			//Angle of rotation
			double degrees = 0;

			//The dot that will be moving around on the screen
			Dot dot ( 100, 300);

			//Opening Fonts and message
			TTF_Font *times;
			times = TTF_OpenFont("arial.ttf", 14);

			SDL_Color white = {255, 255, 255};
			
			std::stringstream health;
			health <<"Health:" << dot.hp << "    Points: " << POINTS;

			const std::string str = health.str();

			SDL_Surface *surface = TTF_RenderText_Solid(times,
									health.str().c_str(), white);


			 SDL_Texture * texture = SDL_CreateTextureFromSurface(gRenderer,
					 surface);

			  int texW = 0;
			  int texH = 0;
			  SDL_QueryTexture(texture, NULL, NULL, &texW, &texH);
			  SDL_Rect dstrect = { 0, 0, texW, texH };

			
			//creating enemies
			std::vector<Enemy*> enemies;

			for (int i = 0; i < NumberEnemies; i++)
			{
				enemies.push_back(new Enemy(i*100, 0));
			}
			
			//Flip type
			SDL_RendererFlip flipType = SDL_FLIP_NONE;

			//While application is running
			while( !quit)
			{

				//Handle events on queue
				while( SDL_PollEvent( &e ) != 0 )
				{
					//User requests quit
				if( e.type == SDL_QUIT )
					{
						quit = true;
					}

					dot.handleEvent(e);
				}

				//rotating
					degrees += 1;


					//collision between enemies and bullets
				for (int i = 0; i < enemies.size(); i++)
				{
					for (int j = 0; j < bulletsUp.size(); j++)
					{
						enemies[i]->move(bulletsUp[j]->getColliders());
					}

					for (int j = 0; j < bulletsLeft.size(); j++)
					{
						enemies[i]->move(bulletsLeft[j]->getColliders());
					}

					for (int j = 0; j < bulletsRight.size(); j++)
					{
						enemies[i]->move(bulletsRight[j]->getColliders());
					}

					enemies[i]->move(dot.getColliders());

					enemies[i]->shoot(enemies[i]->mPosX, enemies[i]->mPosY);

					dot.move( enemies[i]->getColliders());
				}


				//moving of bullets
				for (int i = 0; i < bulletsUp.size(); i++)
				{
					bulletsUp[i]->moveUp(dot.getColliders());
				}

				for (int i = 0; i < bulletsLeft.size(); i++)
				{
					bulletsLeft[i]->moveLeft(dot.getColliders());
				}

				for (int i = 0; i < bulletsRight.size(); i++)
				{
					bulletsRight[i]->moveRight(dot.getColliders());
				}

				for (int i = 0; i < enemyBullets.size(); i++)
				{
					enemyBullets[i]->enemyMove(dot.getColliders());
				}

				//Scroll background
                --scrollingOffset;
                if( scrollingOffset < -gBGTexture.getWidth() )
                {
                    scrollingOffset = 0;
                }

				//Clear screen
				SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );

				SDL_RenderClear( gRenderer );

				//Render background
                gBGTexture.render( scrollingOffset, 0 );
				SDL_RenderCopy(gRenderer, texture, NULL, &dstrect);
                gBGTexture.render( scrollingOffset + gBGTexture.getWidth(), 0 );

				//Render Dot
				dot.render();

				//displaying enemeies and bullets
				for (int i = 0; i < enemies.size(); i++)
				{
					enemies[i]->render(degrees,flipType);
				}

				for (int i = 0; i < bulletsUp.size(); i++)
				{
					bulletsUp[i]->render();
				}

				for (int i = 0; i < bulletsLeft.size(); i++)
				{
					bulletsLeft[i]->render();
				}

				for (int i = 0; i < bulletsRight.size(); i++)
				{
					bulletsRight[i]->render();
				}

				for (int i = 0; i < enemyBullets.size(); i++)
				{
					enemyBullets[i]->render();
				}

				//Update screen
				SDL_RenderPresent( gRenderer );
			}
		}
	}

	//Free resources and close SDL
	close();

	return 0;
}
Ejemplo n.º 26
0
int main( int argc, char* args[] )
{
	//Start up SDL and create window
	if( !init() )
	{
		printf( "Failed to initialize!\n" );
	}
	else
	{
		//Load media
		if( !loadMedia() )
		{
			printf( "Failed to load media!\n" );
		}
		else
		{	
			//Main loop flag
			bool quit = false;

			//Event handler
			SDL_Event e;

			//The dot that will be moving around on the screen
			Dot dot;

			//The camera area
			SDL_Rect camera = { 0, 0, SCREEN_WIDTH, SCREEN_HEIGHT };

			//While application is running
			while( !quit )
			{
				//Handle events on queue
				while( SDL_PollEvent( &e ) != 0 )
				{
					//User requests quit
					if( e.type == SDL_QUIT )
					{
						quit = true;
					}

					//Handle input for the dot
					dot.handleEvent( e );
				}

				//Move the dot
				dot.move();

				//Center the camera over the dot
				camera.x = ( dot.getPosX() + Dot::DOT_WIDTH / 2 ) - SCREEN_WIDTH / 2;
				camera.y = ( dot.getPosY() + Dot::DOT_HEIGHT / 2 ) - SCREEN_HEIGHT / 2;

				//Keep the camera in bounds
				if( camera.x < 0 )
				{ 
					camera.x = 0;
				}
				if( camera.y < 0 )
				{
					camera.y = 0;
				}
				if( camera.x > LEVEL_WIDTH - camera.w )
				{
					camera.x = LEVEL_WIDTH - camera.w;
				}
				if( camera.y > LEVEL_HEIGHT - camera.h )
				{
					camera.y = LEVEL_HEIGHT - camera.h;
				}

				//Clear screen
				SDL_SetRenderDrawColor( gRenderer, 0xFF, 0xFF, 0xFF, 0xFF );
				SDL_RenderClear( gRenderer );

				//Render background
				gBGTexture.render( 0, 0, &camera );

				//Render objects
				dot.render( camera.x, camera.y );

				//Update screen
				SDL_RenderPresent( gRenderer );
			}
		}
	}

	//Free resources and close SDL
	close();

	return 0;
}
Staff* CScribeToNeoScribeXML::Scribe2MEIXMLStaff(const CScribeReaderVisitable& scribe_data, const scribe_part& partit, StaffGrp* staffgrp, const int i)
{
    
    std::string staffnum("s");
    staffnum += std::to_string(i); //autogenerate staff ids
    
    //finish score definitions
    //add staff definition for current part
    //NB. look to alternatively embedding these in staffs
    StaffDef* staffdef = new StaffDef;
    
    //define staff from data
    staffgrp->addChild(staffdef);
    staffdef->addAttribute("id", staffnum);
    staffdef->addAttribute("lines", std::to_string(partit.initial_staff_data.staff_lines));
    staffdef->addAttribute("label", CScribeCodes::voice_labels[partit.voice_type].c_str());
    
    //define clef from data
    Clef* clef = new Clef;
    staffdef->addChild(clef);
    
    scribe_clef loc_clef;
    loc_clef.clef_line = partit.initial_staff_data.clef_line;
    loc_clef.clef = partit.initial_staff_data.clef;
    //convert scribe-based clef position to mei
    //int mei_clef_line = ((loc_clef.clef_line + 1)/2) - 1; = incorrect
    int mei_clef_line = 1 + (loc_clef.clef_line-3)/2;
    //4-line staves are numbered 3, 5, 7, 9 in scribe
    //if (partit->staff_lines<=4) mei_clef_line -= (5 - partit->staff_lines);
    
    clef->addAttribute("line", std::to_string(mei_clef_line)); //these need to be set for each staff/part
    clef->addAttribute("shape", std::string(&(partit.initial_staff_data.clef),1).c_str()); //the first event in stored memory should be the initial clef
    
    Staff* staff = new Staff;
    
    staff->addAttribute("id", staffnum);
    staff->addAttribute("source", partit.abbrev_ms);
    //folio on which part appears
    
    Pb* pb = new Pb; //new ELEMENT?
    staff->addChild(pb);
    pb->addAttribute("n", partit.folios);
    //first staff on which part appears
    Sb* sb = new Sb;
    sb->addAttribute("n", "0"); //set to "0" since this isn't encoded in scribe; data will need to be enhanced later
    staff->addChild(sb);
    
    coloration_type current_color = coloration_type::full_black; // this needs to be better handled with a default coloration in a part
    
    for (std::vector<scribe_row>::const_iterator rowit = partit.rows.begin(); rowit!=partit.rows.end(); rowit++)
    {
        if (rowit->is_comment) {
            //check it this is the correct way to handle a comment
            
            MeiCommentNode* comment = new MeiCommentNode;
            comment->setValue(rowit->comment);
            staff->addChild(comment);
            //NB. syl can have a type (eg. initial) attribute and also encode color as <rend> child element
        } else {
            
            //syllable container (holds syllables, notes, neumes, and ligatures)
            Syllable* syllable = new Syllable; //neumes.h
            staff->addChild(syllable);
            
            //add actual syllable if present
            if (!rowit->syllable.empty()) {
                Syl* syl = new Syl;
                syl->setValue(rowit->syllable);
                syllable->addChild(syl);
            }
            
            //extract events - notes, rests ligatures, uneumes and/or ligatures
            for (std::vector<scribe_event>::const_iterator eventit = rowit->events.begin(); eventit!=rowit->events.end(); eventit++ )
            {
                current_color = eventit->local_coloration;
                
                //use temp TiXML pointer which is either syllable, uneume/ineume or ligature - add notes to this, but make sure that uneume/inueme/ligature pointer is preinserted into syllable
                //handle events for each row
                code_t event_type = scribe_data.GetCodes()->get_code_type(eventit->code);//codes->get_code_type(eventit->code);
                //foster parent will change roles according to child elements that need to be added
                MeiElement* foster = syllable;
                
                switch (event_type)
                {
                    case code_t::ineume:
                    {
#ifdef IGNOREGAPS
                        Ineume* ineume = new Ineume;
                        //ineume->addAttribute("name", scribe_data.GetCodes()->code_to_name(eventit->code));
                        foster->addChild(ineume);
                        foster = ineume;
                        
#else                   //this needs work, hence excluded
                        if (!eventit->preceding_gap || foster->getChildren().empty())
                        {
                            Ineume* ineume = new Ineume;
                            //ineume->addAttribute("name", scribe_data.GetCodes()->code_to_name(eventit->code));
                            foster->addChild(ineume);
                            foster = ineume;
                        }
                        else
                        {
                            MeiElement* lastNeume = foster->getChildren().back();
                            if (lastNeume->getName() == "ineume")
                            {
                                Ineume* newNeume = new Ineume(*dynamic_cast<Ineume*>(lastNeume));
                                /*for (std::vector<MeiElement*>::const_iterator child = lastNeume->getChildren().begin(); child!=lastNeume->getChildren().end(); child++ ) {
                                    MeiElement* clone = new MeiElement(**child);
                                    newNeume->addChild(clone);
                                }*/
                                foster->removeChild(lastNeume);
                                foster->addChild(newNeume);
                                //delete lastNeume;
                                foster = newNeume;
                            }
                            else
                                foster = lastNeume;
                        }
#endif
                        goto do_note;
                        break;
                    }
                    case code_t::uneume:
                    {
                        Uneume* uneume = new Uneume;
                        uneume->addAttribute("name", scribe_data.GetCodes()->code_to_name(eventit->code));
                        foster->addChild(uneume);
                        foster = uneume;
                        goto do_note;
                        break;
                    }
                    case code_t::ligature:
                    {
                        Ligature* ligature = new Ligature; //mensural.h
                        ligature->addAttribute("name", scribe_data.GetCodes()->code_to_name(eventit->code));
                        foster->addChild(ligature);
                        foster = ligature;
                        if (current_color!=coloration_type::full_black)
                        {
                            switch (current_color) {
                                case full_red:
                                    ligature->addAttribute("color", "red");
                                    break;
                                case void_red:
                                    ligature->addAttribute("color", "red");
                                    ligature->addAttribute("void", "true"); //this seems a sensible solution for this problem and a suitable additional attribute to the MEI description
                                    break;
                                case void_black:
                                    ligature->addAttribute("void", "true"); //**
                                    break;
                                case full_blue:
                                    ligature->addAttribute("color", "blue");
                                    break;
                                default:
                                    break;
                            }
                        }
                        //goto do_note;
                        //break;
                    }
                    case code_t::note:
                    do_note:
                    {
                        for (auto i = eventit->pitch_num.begin(); i!=eventit->pitch_num.end(); i++)
                        {
                            int note_count = 1;
                            MeiElement* temp_foster = foster;
                            
                            //handle note attributes according to type
                            if ( foster->getName()=="ineume" )
                            {
                                Uneume* temp_uneume = new Uneume;  //handle ineumes
                                //find uneume names
                                temp_uneume->addAttribute("name", CScribeReaderVisitable::get_ineume_part(eventit->code, i - eventit->pitch_num.begin(), note_count));
                                foster->addChild(temp_uneume);
                                temp_foster = temp_uneume; //allow notes to be children of uneume
                            } else if ((eventit->code=="B" || eventit->code=="V" || eventit->code=="L") && eventit->pitch_num.size()>1 && scribe_data.GetType()==chant && i!=eventit->pitch_num.begin()) //codes like virga and punctum may be followed by several pitch numbers, indicating a sequence of simple neumes
                            {
                                Uneume* temp_uneume = new Uneume;
                                temp_uneume->addAttribute("name", scribe_data.GetCodes()->code_to_name(eventit->code));
                                foster->getParent()->addChild(temp_uneume); //link to syllable element, not uneume!
                                temp_foster = temp_uneume;
                            }
                            //also handle ligatures
                            auto j = 0;
                            //insert note or notes for unneumes in ineumes
                            for (; j < note_count ; j++)
                            {
                                //convert note location to pitch name
                                // need to handle dots as element rather than attribute?
                                char pitch_name = loc_clef.get_pitch_name(*i);
                                int octave = loc_clef.get_octave(*i);
                                
                                Note* note = new Note;
                                if (foster->getName()=="syllable")
                                {
                                    note->addAttribute("dur", scribe_data.GetCodes()->code_to_name(eventit->code));
                                }
                                else if (foster->getName()=="ligature")
                                {
                                    note->addAttribute("dur", scribe_data.get_ligature_part(eventit->code, j));
                                }
                                note->addAttribute("pname", std::string(&pitch_name,1));
                                note->addAttribute("oct", std::to_string(octave));
                                int note_loc = *i - 3; //3 is bottom line in Scribe, 0 in MEI
                                note->addAttribute("loc", std::to_string( note_loc ));
                                if (current_color!=coloration_type::full_black)
                                {
                                    switch (current_color) {
                                        case full_red:
                                            note->addAttribute("color", "red");
                                            break;
                                        case void_red:
                                            note->addAttribute("color", "red");
                                            note->addAttribute("void", "true"); //this seems a sensible solution for this problem and a suitable additional attribute to the MEI description
                                            break;
                                        case void_black:
                                            note->addAttribute("void", "true"); //**
                                            break;
                                        case full_blue:
                                            note->addAttribute("color", "blue");
                                            break;
                                        default:
                                            break;
                                    }
                                }
                                temp_foster->addChild(note);
                            }
                            i+=j-1;
                        }
                    }
                        break;
                        //dot needs to be handled as a unique element in our extended definition
                        /*Stinson, 7 July 2013: Further notes on DOT
                         The code has two arguments: the first is the substantive position on the staff; the second refines that position up or down and is capable of five variants: 0 = exactly on the line or exactly in the middle of the space between the lines; -1 = 0.1 of the space between the lines below (or for +, above) the space or line; -2= 0.2 of the space below the normal position for that line or space; -3 = 0.3 below the normal position; -4 = 0.4 below the normal position.
                         Only values between 0 and 4 are permitted as the second argument as 5 would be the equivalent of having the dot on the next numbered line or space, e.g. '7 -5', if it were permitted, would be the same as '6 0'.*/
                    case code_t::dot:
                    {
                        Dot* dot = new Dot;
                        char pitch_name = loc_clef.get_pitch_name(eventit->pitch_num[0]);
                        int octave = loc_clef.get_octave(eventit->pitch_num[0]);
                        dot->addAttribute("ploc", std::string(&pitch_name,1));
                        dot->addAttribute("oloc", std::to_string(octave));
                        /*vo: records the vertical adjustment of a feature's programmatically-determined location in terms of staff interline distance; that is, in units of 1/2 the distance between adjacent staff lines. (MEI2013)*/
                        //only set for non-defult positions
                        if (eventit->pitch_num[1]!=0)
                        {
                            float v_pos = eventit->pitch_num[1]/10.0*2;
                            dot->addAttribute("vo", to_string_with_precision(v_pos,1));
                        }
                        foster->addChild(dot);
                    }
                        break;
                    case code_t::rest:
                    {
                        Rest* rest = new Rest;
                        foster->addChild(rest);
                        switch (*(eventit->code.c_str())) {
                                //rests of type 'R' has two associated pitch numbers from which we might infer the type
                            case generic_rest:
                            {
                                int end = eventit->pitch_num[0];
                                int start = eventit->pitch_num[1];
                                int rest_type = start-end;
                                switch (rest_type) {
                                    case minim_rest:
                                        rest->addAttribute("type", "minima");
                                        break;
                                    case semibreve_rest:
                                        rest->addAttribute("type", "semibrevis");
                                        break;
                                    case breve_rest:
                                        rest->addAttribute("type", "brevis");
                                        break;
                                    case long_rest:
                                        rest->addAttribute("type", "longa imperfecta");
                                        break;
                                    case perf_long_rest:
                                        rest->addAttribute("type", "long perfecta");
                                        break;
                                    default:
                                        break;
                                }
                                char ploc = loc_clef.get_pitch_name(start);
                                rest->addAttribute("ploc", std::string(&ploc,1));
                                rest->addAttribute("oloc", std::to_string(loc_clef.get_octave(start)));
                                break;
                                //also process 'RSM', semiminim rest
                            }
                                //case semiminim_rest:
                                //rest->SetAttribute("type", "semiminim");
                                //    break;
                            default:
                                rest->addAttribute("type", scribe_data.GetCodes()->code_to_name(eventit->code));
                                if (!eventit->pitch_num.empty()) {
                                    char pitch_name = loc_clef.get_pitch_name(eventit->pitch_num[0]);
                                    int octave = loc_clef.get_octave(eventit->pitch_num[0]);
                                    rest->addAttribute("ploc", std::string(&pitch_name,1));
                                    rest->addAttribute("oloc", std::to_string(octave));
                                }
                                break;
                        }
                    }
                        break;
                    // non-standard mensuration signs
                    case code_t::mensuration:
                    {
                        Mensur* mensuration_sign = new Mensur;
                        foster->addChild(mensuration_sign);
                        
                        if (eventit->code == "MO" || eventit->code == "MC" || eventit->code == "MO." || eventit->code == "MC.")
                        {
                            char the_sign = eventit->code[1];
                            mensuration_sign->addAttribute("sign", std::string(&the_sign,1));
                            if (eventit->code.size()==3 && eventit->code[2]=='.') {
                                mensuration_sign->addAttribute("dot", "true");
                            }
                            //also able to set attribute 'orient' to reversed for reversed signs; and slash attribute for cut signs
                        }
                        if (eventit->code == ".D." || eventit->code == ".Q." || eventit->code == ".SI." || eventit->code == ".P." || eventit->code == ".N." || eventit->code == ".O." || eventit->code == ".I.") //also .SG.?
                        {
                            //these are wholly new to the MEI schema; the whole dot-letter-dot sign is encoded
                            mensuration_sign->addAttribute("sign", eventit->code);
                        }
                        break;
                    }
                    case code_t::barline:
                    {
                        BarLine* barline = new BarLine;
                        foster->addChild(barline);
                        if (eventit->code == "QBAR") {
                            
                            barline->addAttribute("rend", "quarter"); //non-standard data type for rend.
                        }
                        if (eventit->code == "HBAR") {
                            
                            barline->addAttribute("rend", "half");
                        }
                        if (eventit->code == "WBAR") {
                            
                            barline->addAttribute("rend", "single");
                        }
                        if (eventit->code == "DBAR") {
                            
                            barline->addAttribute("rend", "dbl");
                        }
                        
                        //modern bar editorial - ignore?
                        if (eventit->code == "MBAR") {
                            
                            barline->addAttribute("barplace", "takt");
                            barline->addAttribute("taktplace", std::string(9,1));
                        }
                        
                        //also able to see rend attribute
                        
                        break;
                    }
                    case code_t::clef:
                    {
                        //NB. old clefchange element superceded; clefGrp used for simultaneous clefs
                        loc_clef.clef_line = *(eventit->pitch_num.begin());
                        loc_clef.clef = *(eventit->code.c_str());
                        Clef* clef = new Clef;
                        clef->addAttribute("line", std::to_string( ((loc_clef.clef_line + 1)/2) - 1));
                        clef->addAttribute("shape", std::string(&(loc_clef.clef),1).c_str());
                        foster->addChild(clef);
                        break;
                    }
                        //The MEI accidental names are not used: diesis, b-rotundum and b-quadratum are. Other variants may be added. All ms accidentials in Scribe (as they should be in NeoScribe) are independent elements
                    case code_t::accidental:
                    {
                        Accid* accid = new Accid;
                        accid->addAttribute("accidental", scribe_data.GetCodes()->code_to_name(eventit->code));
                        if (!eventit->pitch_num.empty()) {
                            char ploc = loc_clef.get_pitch_name(eventit->pitch_num[0]);
                            int oloc = loc_clef.get_octave(eventit->pitch_num[0]);
                            accid->addAttribute("ploc", std::string(&ploc,1));
                            accid->addAttribute("oloc", std::to_string(oloc));
                        }
                        foster->addChild(accid);
                        break;
                    }
                    case code_t::other:
                        //lucunae
                    default:
                        break;
                }
                
            }
            
        }
    }
    
    return staff;
}
Ejemplo n.º 28
0
int main( int argc, char* args[] )
{
    //Quit flag
    bool quit = false;

    //The dot that will be used
    Dot myDot;

    //Keeps track of time since last rendering
    Timer delta;

    //Initialize
    if( init() == false )
    {
        return 1;
    }

    //Load the files
    if( load_files() == false )
    {
        return 1;
    }

    //Start delta timer
    delta.start();

    //While the user hasn't quit
    while( quit == false )
    {
        //While there's events to handle
        while( SDL_PollEvent( &event ) )
        {
            //Handle events for the dot
            myDot.handle_input();

            //If the user has Xed out the window
            if( event.type == SDL_QUIT )
            {
                //Quit the program
                quit = true;
            }
        }

        //Move the dot
        myDot.move( delta.get_ticks() );

        //Restart delta timer
        delta.start();

        //Fill the screen white
        SDL_FillRect( screen, &screen->clip_rect, SDL_MapRGB( screen->format, 0xFF, 0xFF, 0xFF ) );

        //Show the dot on the screen
        myDot.show();

        //Update the screen
        if( SDL_Flip( screen ) == -1 )
        {
            return 1;
        }
    }

    //Clean up
    clean_up();

    return 0;
}
Ejemplo n.º 29
0
void ParticleEngineApp::draw()
{
	gl::clear( Color( 0, 0, 0 ) ); 
	mDot.draw();
}
Ejemplo n.º 30
0
int main(int argc, char* args[]) {
	//Quit flag
	bool quit = false;

	//Make the dot
	Dot myDot;

	//The frame rate regulator
	Timer fps;

	//Initialize
	if (init() == false) {
		return 1;
	}

	//Load the files
	if (load_files() == false) {
		return 1;
	}

	//While the user hasn't quit
	while (quit == false) {
		//Start the frame timer
		fps.start();

		//While there's events to handle
		while (SDL_PollEvent(&event)) {
			//Handle events for the dot
			myDot.handle_input();

			//If the user has Xed out the window
			if (event.type == SDL_QUIT) {
				//Quit the program
				quit = true;
			}
		}

		//Move the dot
		myDot.move();

		//Fill the screen white
		SDL_FillRect(screen, &screen->clip_rect,
				SDL_MapRGB(screen->format, 0xFF, 0xFF, 0xFF));

		//Show the dot on the screen
		myDot.show();

		//Update the screen
		if (SDL_Flip(screen) == -1) {
			return 1;
		}

		//Cap the frame rate
		if (fps.get_ticks() < 1000 / FRAMES_PER_SECOND) {
			SDL_Delay((1000 / FRAMES_PER_SECOND) - fps.get_ticks());
		}
	}

	//Clean up
	clean_up();

	return 0;
}