Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Pong game problem need some help!! ....

Status
Not open for further replies.

RISCIT

Junior Member level 1
Junior Member level 1
Joined
Dec 30, 2011
Messages
15
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Visit site
Activity points
1,441
Hello


I encounter a problem with my code, When i push the button RB1 on my PIC16F887 TO make move the battle of my pong game while the ball move also, the screen is decrease in speed and the velocity become very weak, when i release it, everything is ok, but when i want to move the battle, it moving slowly even as the ball?


What is the problem on my code?



Code:
 {
       for(;;){

            // Deplacement_Balle();
            Raquette_Droite ();
            Raquette_Gauche ();
            Collision_Raquette();

        }

    }
}



void Fake_Loading()
{

    T6963C_write_text("LOADING", 4,2 , T6963C_ROM_MODE_OR);
    T6963C_box(10, 30, 118, 40, T6963C_WHITE);

}



void Menu()
{

    T6963C_rectangle(4, 4, 124, 60, T6963C_WHITE);
    T6963C_write_text(" Pong Game!", 2,2 , T6963C_ROM_MODE_OR);
    delay_ms(500);
    T6963C_write_text(" Design", 3,4 , T6963C_ROM_MODE_OR);
    T6963C_write_text("  ", 0,6 , T6963C_ROM_MODE_OR);

}



void  Raquette_Droite ()
{

    if(PORTB.F1==1)
    {

        x0=x0+3;
        x1=x1+3;
        T6963C_line(x0, 56, x1,56, T6963C_WHITE);
        T6963C_line(x0-3, 56, x1-3,56, T6963C_BLACK);

        if(x1>118)
        {
            x1=118;
            x0=96;
            T6963C_line(118, 56, 122,56, T6963C_BLACK);
            T6963C_line(96, 56, 118,56, T6963C_WHITE);
        }

        if(PORTB.F1==0)
        {

           T6963C_line(x0, 56, x1,56, T6963C_WHITE);

        }
    }
}



void  Raquette_Gauche ()
{


    if(PORTB.F2==1)
    {

        x0=x0-3;
        x1=x1-3;
        T6963C_line(x0, 56, x1,56, T6963C_WHITE);
        T6963C_line(x0+3, 56, x1+3,56, T6963C_BLACK);

        if(x0<10 && x1<122)
        {
            x1=32;
            x0=10;
            T6963C_line(10, 56, 32,56, T6963C_WHITE);
            T6963C_line(x0+3, 56, x1+3,56, T6963C_BLACK);
        }

        if(PORTB.F2==0)
        {

            T6963C_line(x0, 56, x1,56, T6963C_WHITE);

        }

    }
}



void Deplacement_Balle()
{

    T6963C_circle((int)x_c, (int)y_c, 2, T6963C_BLACK);
    x_c = x_c+ vx;
    y_c = y_c+ vy;
    delay_us(100);
    T6963C_circle((int)x_c, (int)y_c, 2, T6963C_WHITE);

    if(y_c > 58)
    {
        vy = -vy;
    }

    else if(y_c < 14)
    {
        Sound_Play(600, 10);
        vy = -vy;
    }

    else if(x_c <9)
    {
        Sound_Play(600, 10);
        vx = -vx;

    }

    else if(x_c > 117)
    {
        Sound_Play(600, 10);
        vx = -vx;

    }

}


void Collision_Raquette(){

 if(x_c >= x0 && x_c <= x1 && y_c >= 52)    vy = -vy;

 else  if(y_c >= 58)    {

 vx=0;
 vy=0;
 T6963C_circle((int)x_c, (int)y_c, 2, T6963C_BLACK);
 T6963C_panelFill(0);
 T6963C_write_text(" GAME OVER", 2,2 , T6963C_ROM_MODE_OR);


 }

}




thanks
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top