View Poll Results: What do you think of my game ?

Voters
10. You may not vote on this poll
  • It Rocks

    2 20.00%
  • It Sucks

    1 10.00%
  • It is moderate. (Not so bad)

    6 60.00%
  • Who cares ?

    1 10.00%

What do you think of my new game?

This is a discussion on What do you think of my new game? within the Game Programming forums, part of the General Programming Boards category; I recently wrote my first game in C As I dont know any graphics, all the graphics that I used ...

  1. #1
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282

    What do you think of my new game?

    I recently wrote my first game in C

    As I dont know any graphics, all the graphics
    that I used are based on text.

    Please tell me your comments/suggestions.

    www.akilla.tk
    Attached Files Attached Files

  2. #2
    I'm Back
    Join Date
    Dec 2001
    Posts
    556
    The game is jerky. Paddle movement can be a bit smoother.

    Overall I'll say its nice considering that no graphics stuff was used.


    How many ids are you going to create,dude??

    akilla, learner007, moonwalker. I dont understand why you need so many of them??

  3. #3
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282

    yeah

    You're right about the paddle movement.. but I am unable to increase it (too fast) or decrease it (too slow)
    I think something is wrong with my code... I used the delay command for the ball to fall slowly, but that command is above the while loop of the input, this is slowing it down... you know what i mean ?

    yeah, I have 2 IDs. 'Akilla' was just a guest name. I am settling with this one 'cause I like this better .

  4. #4
    Seven years? civix's Avatar
    Join Date
    Jul 2002
    Posts
    605
    Pretty good overall, exept you might want to make it fullscreen, and the paddle movement smoother

  5. #5
    Intranasal Heroin User Xterria's Avatar
    Join Date
    Sep 2001
    Location
    Buffalo, NY
    Posts
    1,035
    awsome game! It's great considering your new and it's console.
    nice job!

  6. #6
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282

    help

    How can I make it full screen ?

    I'll try to do it right away!!!

  7. #7
    Pursuing knowledge confuted's Avatar
    Join Date
    Jun 2002
    Posts
    1,916
    pretty cool...but I agree with everyone, the paddle movement is kind of jerky
    Away.

  8. #8
    Registered User
    Join Date
    Jul 2002
    Posts
    94
    Very nice! My only complaint: not the jerkiness, I'm fine with that, but the speed at which the paddle moves. it's much to difficult to catch up with that ball. If you don't mind, could you please post the source code? I've been trying a console thing like that and I can't get the collision detection to work. Brilliant work!

    Brendan

  9. #9
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282

    Here's the source

    If I increase the speed, it becomes more jerky (as this is wholly text and not graphics)

    Here's the code anyway:
    PHP Code:
    #include <stdio.h>
    #include <conio.h>
    #include <windows.h>
    #include <time.h>

    #define paddlelength 7

    struct gameinfo
    {
        
    int score;
        
    int lives;
    gameboard;

    struct gamecomponent
    {
        
    int bufxbufy;            //buffer coordinates
        
    int oldxoldy;            //old coordinates
        
    int newxnewy;            //new coordinates
        
    int xspeedyspeed;        //speed in x, y directions
        
    void resetcoords();        
    ballpaddle;

    void gamecomponent :: resetcoords()    //function to reset coordinates whenever they change
    {
        
    oldx bufx;
        
    oldy bufy;
        
    bufx newx;
        
    bufy newy;
    }

    void waitforkeypress()            //waits for a key press
    {
        while (!
    kbhit())
        {

        }
        
    fflush(stdin);
    }

    void changecoordball()            //changes the coordinates of the ball
    {
        if (
    ball.newy == paddle.newy && ball.newx >= paddle.newx && ball.newx <= (paddle.newx paddlelength))
        {
            
    //if ball hits the paddle

            
    if (ball.newx >= paddle.newx && ball.newx <= (paddle.newx 3))
            {
                
    //if it falls on the left half of the paddle

                
    if (ball.xspeed 0)
                {
                    
    ball.xspeed = -ball.xspeed;    //changes direction to -ve (goes left)
                
    }
                
                if (
    ball.yspeed 0)
                {
                    
    ball.yspeed = -ball.yspeed;    //changes y direction to -ve (goes up)
                
    }
            }

            if (
    ball.newx > (paddle.newx 3) && ball.newx <= (paddle.newx paddlelength))
            {
                
    //if it falls on the right half of the paddle

                
    if (ball.xspeed 0)
                {
                    
    ball.xspeed = -ball.xspeed;    //changes x direction to +ve (goes right)
                
    }
                
                if (
    ball.yspeed 0)
                {
                    
    ball.yspeed = -ball.yspeed;    //changes y direction to -ve (goes up)
                
    }
            }
        }

        if (
    ball.newx >= 79)
        {
            
    //if it hits the right border

            
    if (ball.xspeed 0)
            {
                
    ball.xspeed = -ball.xspeed;        //changes x direction to -ve (goes left)
            
    }
        }

        if (
    ball.newx <= 1)
        {
            
    //if it hits the left border

            
    if (ball.xspeed 0)
            {
                
    ball.xspeed = -ball.xspeed;        //changes x direction to +ve (goes right)
            
    }
        }

        if (
    ball.newy <= 1)
        {
            
    //if it hits the top wall

            
    if (ball.yspeed 0)
            {
                
    ball.yspeed = -ball.yspeed;        //changes y direction to +ve (goes down)
            
    }
        }

        
    //based on the above changes, the coordinates are affected as:

        
    ball.newx ball.newx ball.xspeed;
        
    ball.newy ball.newy ball.yspeed;
        
    }

    void changecoordpaddle(int direction)        //changes coordinates of paddle
    {
        
    int delx;

        if (
    direction == 1)
        {
            
    //if direction is right

            
    delx paddle.xspeed;
        }
        else
        {
            
    //if direction is left

            
    delx = -paddle.xspeed;
        }

        if (
    paddle.newx delx >= && paddle.newx delx paddlelength <= 80)
        {
            
    //if paddle is free to move

            
    paddle.newx paddle.newx delx;
        }
    }

    void initialize()        //initializes most variables
    {
        
    int tempposition rand()%40;        //temporary position of the ball during start

        
    ball.bufx tempposition;
        
    ball.bufy 1;
        
    ball.newx tempposition;
        
    ball.newy 1;
        
    ball.oldx tempposition;
        
    ball.oldy 1;
        
    ball.xspeed 1;
        
    ball.yspeed 1;

        
    paddle.bufx 35;
        
    paddle.bufy 25;
        
    paddle.newx 35;
        
    paddle.newy 25;
        
    paddle.oldx 35;
        
    paddle.oldy 25;
        
    paddle.xspeed 2;
        
    paddle.yspeed 1;
    }

    void placeball()        //places the ball
    {
        
    gotoxy(ball.oldxball.oldy);
        
    printf(" ");                    //places a space at old coordinates
        
    gotoxy(ball.newxball.newy);
        
    printf("o");                    //places ball at new coordinates
    }

    void placepaddle()        //places the paddle
    {
        
    gotoxy(paddle.oldxpaddle.oldy);
        
    printf("       ");                //places spaces at old coordinates
        
    gotoxy(paddle.newxpaddle.newy);
        
    printf("=======");                //places paddle at new coordinates
    }

    int checkbounce()
    {
        
    int bounceval 1;                //bounceval = 1 assumes ball will bounce

        
    if (ball.newy == paddle.newy)
        {
            if (
    ball.newx paddle.newx || ball.newx > (paddle.newx paddlelength))
            {
                
    bounceval 0;            //happens when ball falls off
            
    }
            else if (
    ball.newx >= paddle.newx && ball.newx <= paddle.newx paddlelength)
            {
                
    gameboard.score++;        //increases when ball hits paddle
            
    }
        }

        return 
    bounceval;                //lates bounceval is returned
    }

    void cursor (int yn)        //function hides/brings back the cursor. 0 to hide and 1 to bring back
    {
      
    CONSOLE_CURSOR_INFO c;
      
    c.dwSize   1;
      
    c.bVisible yn;
      
    SetConsoleCursorInfo GetStdHandle STD_OUTPUT_HANDLE ), &);  
    }

    void my_delay (int milliseconds)    //delays in milliseconds
    {
        
    time_t endnow clock();
        for ( 
    end now millisecondsnow endnow clock() )
        continue;
    }

    int getpressedkey()        //gets instant input
    {
        
    char c;
        
    getch();
        
        switch ((int)
    c)
        {
            case 
    27:            //Escape key - returns 2
                
    fflush(stdin);
                return 
    2;
            case 
    75:            //left key - returns 0
                
    fflush(stdin);
                return 
    0;
            case 
    77:            //right key - returns 1
                
    fflush(stdin);
                return 
    1;
        }
        
        
    fflush(stdin);    
        return -
    1;
    }

    void showscore()        //shows latest score
    {
        
    gotoxy(11);
        
    printf("Score: %d"gameboard.score);
        
    gotoxy(731);
        
    printf("Lives: %d"gameboard.lives);
    }

    void showtitle()        //title
    {
        
    my_delay(1000);
        
    clrscr();
        
    gotoxy(124);
        
    printf("\nProgrammed by Mahurshi Akilla\nhttp://mahurshi.tripod.com\n");
        
    waitforkeypress();
        
    cursor(1);
        exit(
    1);
    }


    void showgameover()        //shows game over
    {
        
    gotoxy(3513);
        
    printf("Game Over!");
    }

    char playagain()        //asks if he/she wants to play again
    {
        
    char yesorno;
        do 
        {
            
    showgameover();
            
    gotoxy(1,24);
            
    cursor(1);
            
    printf("Do you want to play again? (y/n): ");
            
    scanf("%c", &yesorno);
            
    fflush(stdin);
        } while (
    yesorno != 'y' && yesorno != 'Y' && yesorno != 'n' && yesorno != 'N');
        return 
    yesorno;
    }

    void main()
    {
        
    randomize();

        
    int pressedkey;
        
    int bouncer;
        
    char yesorno;
        
        do
        {
            
    gameboard.lives =3;        //setting lives to 3
            
    gameboard.score 0;        //setting score to 0

            
    clrscr();
            
    initialize();            //initializing all the variables
            
    cursor(0);

            
    showscore();            //show score
            
    placeball();            //place ball
            
    placepaddle();            //place paddle

            
    waitforkeypress();        //wait a key to start

            
    while (gameboard.lives >= )    //as long as there's atleast 1 life, the following code runs
            
    {
                if (
    checkbounce() == 1)    //as long as the ball hasn't fallen off
                
    {
                    
    changecoordball();    //change the coordinates of the ball
                    
    ball.resetcoords();    //reset the old/new coordinates
                    
    placeball();        //places the ball at new coordinates
                    
    placepaddle();        //places the paddle at new coordinates
                    
    my_delay(65);        //delays for a while. This can be increased to increase the ball speed
                    
    showscore();        //shows the latest score
            
                    
    while (kbhit())        //as long as a key is pressed, the following code runs
                    
    {
                        
    pressedkey getpressedkey();
                    
                        if (
    pressedkey != -&& pressedkey != 2)
                        {
                            
    //if it's left or right arrow key only

                            
    changecoordpaddle(pressedkey);    //changes coordinates based on arrow key pressed
                            
    paddle.resetcoords();        //resets the old/new coordinates
                            
    placepaddle();            //places the paddle in new coodinates
                        
    }
                        else if (
    pressedkey == 2)    
                        {
                            
    //if Esc is pressed
                            
    showtitle();
                        }
                    }
                }
                else if (
    checkbounce() == 0)    //if the ball has fallen off
                
    {
                    
    gotoxy(3813);
                    
    printf("CRASH!");    //prints CRASH
                
                    
    waitforkeypress();    //waits for a key
        
                    
    clrscr();        //clears the screen
                    
    fflush(stdin);        //clears the input buffer
                    
    initialize();        //initializes all the variables again (except lives & score)
                    
    gameboard.lives--;    //lives are reduced
                
    }
        
            }

            
    yesorno playagain();            //asks if he/she wants to play again
            
    fflush(stdin);

        } while (
    yesorno == 'y' || yesorno == 'Y');    //if answer is yes, lives and score are reset and the game begins

        
    showtitle();                    //shows title
        
    cursor(1);                    //brings back the cursor


    This may not be a very good code to learn from. I am a newbie and I pretty much suck when compared to most people here.

    Anyway, I hope this will be of some use to you.
    GOOD LUCK!
    Attached Files Attached Files
    Last edited by moonwalker; 07-23-2002 at 04:27 PM.

  10. #10
    Registered User moonwalker's Avatar
    Join Date
    Jul 2002
    Posts
    282

    and...

    as far as the collision is conserned, just think about it..

    1) the ball and the paddle should have the same y co ordinates

    2) the x co-ordinate of the ball should be >= the x coordinate of the paddle and <= the x coordinate of the paddle + paddle length

  11. #11
    Registered User red_baron's Avatar
    Join Date
    May 2002
    Posts
    274
    try using buffered screen should be better.
    research it before you ask!
    ¿Red Baron?

    "Imagination is more important than knowledge"
    -Albert Einstein (1879-1955)

    Check out my games!

    [code] /* dont forget code tags! */ [/code]

  12. #12
    Code Warrior
    Join Date
    Nov 2001
    Posts
    669
    I don't know why everybody are complaining about the paddle movement. It's fine.

    You should create a menu system too and some blocks for destroying them and a highscore table.
    Current projects:
    1) User Interface Development Kit (C++)
    2) HTML SDK (C++)
    3) Classes (C++)
    4) INI Editor (Delphi)

  13. #13
    Registered User
    Join Date
    Jan 2002
    Posts
    387
    Great game! (considering its console and all)

    I dotn think you can make the paddle movement less jerky, because its in the console and you cant exactly move the paddle by pixels, but characters rather.
    "There are three kinds of people in the world...
    Those that can count and those that can't."

  14. #14
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    917
    I believe that increasing paddle movement would be diffecult, because unlike in windows games, user input and ball updates (ect) are separate checks.
    What I mean is:
    Code:
            clrscr();
            initialize();            //initializing all the variables
            cursor(0);
    
            showscore();            //show score
            placeball();            //place ball
            placepaddle();            //place paddle
    
            waitforkeypress();        //wait a key to start
    Although the functions run quickly, you begin to notice it when it comes to frame rate. Hey, using time.h and and integer, try to implement a fps meter.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

  15. #15
    Kiss the monkey. CodeMonkey's Avatar
    Join Date
    Sep 2001
    Posts
    917
    while (!kbhit())


    AH HAH!!!!!!!! That function isn't very portable and is a big pain in the ass to universalize.
    "If you tell the truth, you don't have to remember anything"
    -Mark Twain

Page 1 of 2 12 LastLast
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-08-2010, 12:08 AM
  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, 11:44 AM
  3. game engine advice?
    By stien in forum Game Programming
    Replies: 0
    Last Post: 01-23-2007, 03:46 PM
  4. My Maze Game --- A Few Questions
    By TechWins in forum Game Programming
    Replies: 18
    Last Post: 04-25-2002, 12:00 AM

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