some one can help me with my game?

This is a discussion on some one can help me with my game? within the C Programming forums, part of the General Programming Boards category; the game i developed it in C, theres a problem because the ball is just sloping on the first time ...

  1. #1
    Registered User
    Join Date
    Jun 2002
    Posts
    14

    Angry some one can help me with my game?

    the game i developed it in C, theres a problem because the ball is just sloping on the first time than it stay right, i attached the binary for you see it, the GGL.h is a small lib just with sprite system that i developed

    #include <GGL.h>
    #include <stdio.h>
    #include <dos.h>
    #include <sys/nearptr.h>

    T_Sprite table;
    T_Sprite ball;
    T_Sprite column[10];

    byte table_bmp [8*16] = {
    8, 8, 8, 8, 8, 8, 8, 8,
    8, 7, 7, 7, 7, 7, 7, 8,
    8, 7, 7, 7, 7, 7, 7, 8,
    8, 7, 7, 7, 7, 7, 7, 8,
    8, 7, 7, 7, 7, 7, 7, 8,
    8, 7, 7, 7, 7, 7, 7, 8,
    8, 7, 7, 7, 7, 7, 7, 8,
    8, 7, 7, 7, 7, 7, 7, 8,
    8, 7, 7, 7, 7, 7, 7, 8,
    8, 7, 7, 7, 7, 7, 7, 8,
    8, 7, 7, 7, 7, 7, 7, 8,
    8, 7, 7, 7, 7, 7, 7, 8,
    8, 7, 7, 7, 7, 7, 7, 8,
    8, 7, 7, 7, 7, 7, 7, 8,
    8, 7, 7, 7, 7, 7, 7, 8,
    8, 8, 8, 8, 8, 8, 8, 8
    };

    byte ball_bmp [8*8] = {
    0, 1, 1, 1, 1, 1, 1, 0,
    1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1,
    1, 1, 1, 1, 1, 1, 1, 1,
    0, 1, 1, 1, 1, 1, 1, 0
    };

    byte column_bmp [8*16] = {
    6, 6, 6, 6, 6, 6, 6, 6,
    6, 8, 8, 8, 8, 8, 8, 8,
    8, 8, 6, 6, 6, 6, 6, 6,
    8, 6, 6, 6, 6, 6, 6, 6,
    8, 8, 6, 6, 6, 6, 6, 6,
    6, 8, 6, 6, 6, 6, 6, 6,
    6, 8, 8, 8, 8, 8, 8, 6,
    6, 6, 6, 6, 6, 6, 8, 8,
    6, 6, 6, 6, 6, 6, 6, 8,
    8, 8, 8, 8, 8, 8, 8, 8,
    8, 6, 6, 6, 6, 6, 6, 6,
    8, 8, 8, 6, 6, 6, 6, 6,
    6, 6, 8, 6, 6, 6, 6, 6,
    8, 8, 8, 6, 6, 6, 6, 6,
    8, 6, 6, 6, 6, 6, 6, 6,
    8, 6, 6, 6, 6, 6, 6, 6
    };

    int main ()
    {
    unsigned char ch;
    int i;
    int table_x, table_y, ball_x, ball_y, column_x, column_y;
    int slope, slope_counter, hit, direction, score;

    Init_GGL();

    set_video_mode(VGA_MODE_256_COLOR);

    set_sprite(8, 16, 1, table_bmp, &table);
    set_sprite(8, 8, 1, ball_bmp, &ball);
    for(i = 0; i < 11; i++) set_sprite(8, 16, 1, column_bmp, &column[i]);

    ball_x = SCREEN_WIDTH/2;
    ball_y = SCREEN_HEIGHT/2;
    table_x = ball_x+8;
    table_y = ball_y-4;
    column_x = 20;
    column_y = 0;

    put_sprite(table_x, table_y, 0, &table);
    put_sprite(ball_x, ball_y, 0, &ball);

    for(i = 0; i < 11; i++) {
    column_y +=16;
    put_sprite(column_x, column_y, 0, &column[i]);
    }

    hit = 0;
    slope = 20;

    while(1) {
    if(kbhit()) {
    ch = getch();

    if(ch == 'w')
    move_sprite(table_x, table_y-=3, &table);
    else if(ch == 's')
    move_sprite(table_x, table_y+=3, &table);
    else if(ch == 'p')
    break;
    }

    for(i = 0; i < 11; i++)
    if(colision_detect(&ball, &column[i]))
    hit = 1;

    if(colision_detect(&ball, &table)) {
    hit = 0;
    score++;
    slope = (table_y+8) - (ball_y+4);

    if(slope >= 0)
    direction = 1;
    else
    direction = 0;

    slope = abs(slope);
    slope -= 100;
    }

    if(ball_x > SCREEN_WIDTH || ball_x < 0 || ball_y > SCREEN_HEIGHT || ball_y < 0)
    break;

    if(hit == 0)
    move_sprite(--ball_x, ball_y, &ball);
    else
    move_sprite(++ball_x, ball_y, &ball);

    if(slope_counter == slope) {
    if(direction)
    ball_y++;
    else
    ball_y--;

    slope_counter = 0;
    }
    else
    slope_counter++;

    gdelay(50);
    }

    set_video_mode(TEXT_MODE);
    printf("Score: %d", score);
    printf("Programa teste da Lib Grafica GGL.\n");
    End_GGL();
    }
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    Jun 2002
    Posts
    14
    up, why arent you helping?

  3. #3
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    I think the problem is here:

    Code:
    for(i = 0; i < 11; i++) {
    column_y +=16;
    put_sprite(column_x, column_y, 0, &column[i]);
    }

  4. #4
    Registered User
    Join Date
    Jun 2002
    Posts
    14
    why you think the problem is there?

  5. #5
    Im back! shaik786's Avatar
    Join Date
    Jun 2002
    Location
    Bangalore, India
    Posts
    345
    It's becase this is the first place you are animating (moving the object), so I felt so!
    Just comment that piece of block, compile and check if your problem is solved.

  6. #6
    Registered User
    Join Date
    Jun 2002
    Posts
    14
    umm... my problem isnt that, its the ball, get the binarie and check by yourself

  7. #7
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    Originally posted by Bordonel
    up, why arent you helping?
    We are not your personal servents. And personally, I don't know about you, but I tend to not ever just randomly execute binary files that people give me.

    Other than that, your code is too vague. This is not the full source code, so it isn't really any help to me to figure out why it only moves one direction.


    Quzah.
    Hope is the first step on the road to disappointment.

  8. #8
    Guest Sebastiani's Avatar
    Join Date
    Aug 2001
    Location
    Waterloo, Texas
    Posts
    5,655
    Que Bravo Quzah!

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do the game engine and the api interact?
    By Shadow12345 in forum Game Programming
    Replies: 9
    Last Post: 12-07-2010, 11:08 PM
  2. Open Source / Semi Open source game idea. Help needed
    By CaptainPatent in forum Projects and Job Recruitment
    Replies: 10
    Last Post: 05-16-2007, 10:44 AM
  3. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 02:46 PM
  4. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-24-2002, 11:00 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21