Is there any way to speed up seperate graffics in a program?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • PyroPenguin
    New Member
    • Jun 2010
    • 2

    #1

    Is there any way to speed up seperate graffics in a program?

    Hello,
    I have been teaching myself c++ for the last 2 weeks through various online tutorials. I always have liked programming and recently decided to teach myself some things of c++ because i will be taking a Programming 1 next semester at the college i attend. I'm basically just having fun writing code right now; not really into any major projects yet. Anyways this is what i would like to ask: is there any way to speed up certain vector graphics without speeding up the other?

    here's my code:
    Code:
    void movement(){
         x_X=x;
         y_Y=y;
         if (key[KEY_UP]){
               if (y<100){
                  ++y;
                  }
               if (y>=100){
                  --y;
                  }
               }                
         if (key[KEY_DOWN]){
               if (y>300){
                  --y;
                  }
               if (y<=300){
                  ++y; 
                  }
               }
         if (key[KEY_RIGHT]){
               if (x<400){
                  ++x;
                  }
               if (x>=400){
                  --x;
                  }
               }
         if (key[KEY_LEFT]){
               if (x>=200){
                  --x;
                  }
               if (x<200){
                  ++x;
                  }
               }
               
         acquire_screen();  
         rectfill( buffer, x_X, y_Y, x_X-5, y_Y-5, makecol ( 0, 0, 0));
         rectfill( buffer, x, y, x-5, y-5, makecol ( 0, 255, 0));
         draw_sprite( screen, buffer, 0, 0);         
         release_screen();
         rest(20);
    and i would like this set to move a little faster:
    Code:
    void enemy(){
         XkX = Xk;
         YkY = Yk;
         
         if (Xk == 200 && Yk == 100){
            direction = rand() %2+1;
            locator = 1;
            }
         if (Xk == 200 && Yk == 297){
            direction = rand() %2+1;
            locator = 2;
            }
         if (Xk == 395 && Yk == 100){
            direction = rand() %2+1;
            locator = 3;
            }
         if (Xk == 395 && Yk == 297){
            direction = rand() %2+1;
            locator = 4;
            }
         if (locator == 1 && direction == 1){
            ++Yk;
            }
         if (locator == 1 && direction == 2){
            ++Xk;
            }
         if (locator == 2 && direction == 1){
            --Yk;
            }
         if (locator == 2 && direction == 2){
            ++Xk;
            }
         if (locator == 3 && direction == 1){
            ++Yk;
            }
         if (locator == 3 && direction == 2){
            --Xk;
            }
         if (locator == 4 && direction == 1){
            --Yk;
            }
         if (locator == 4 && direction == 2){
            --Xk;
            }
         acquire_screen();
         circlefill ( buffer, XkX, YkY, 7, makecol( 0, 0, 0));
         circlefill ( buffer, Xk, Yk, 7, makecol( 128, 34, 200));
         draw_sprite( screen, buffer, 0, 0);
         release_screen();
         }
    if i set rest(10) in the enemy section it speeds up movement too. Any help would be greatly appreciated!
  • PyroPenguin
    New Member
    • Jun 2010
    • 2

    #2
    nevermind i slept on it an fixed it :) thanks for the help!

    Comment

    Working...