Eek

This is a discussion on Eek within the C Programming forums, part of the General Programming Boards category; I did some code for that Pong-thing yesterday. It just freezes at the screen. It starts working after you press ...

  1. #1
    Registered User
    Join Date
    Aug 2001
    Posts
    100

    Eek

    I did some code for that Pong-thing yesterday.
    It just freezes at the screen.

    It starts working after you press any key.

    I even remembered to add up -lbgi, and -lgdi32 commands to the project options.
    I'm using Dev-c++ and <winbgim.h>

    Here comes a lot of code:
    (It looks weard, 'couse I tryed out some weard things).

    Code:
    #include <winbgim.h>
    #include <stdlib.h>
    #include <iostream.h>
    #include <time.h>
    
    void itBECOMESBLUE(void);
    void createwalls(int,int);
    void createball(void);
    void createpad(void);
    void moveball(void);
    void movepad(void);
    void eraseoldball(void);
    void setlocation(void);
    void gotohell(void);
    void makepad(void);
    
    char pressme;
        int r=3, hitcounter=0, padcenter, oldpadcenter, ballx=320, bally=240, oldballx=ballx,
        oldbally=bally, padx, gameonoff=0, leftwall, rightwall, counter, centerx=320, centery=240;
    
    int dirx=1, diry=2, ballgox, ballgoy;
    
    main()
    {
     initwindow(640,480);
     createwalls(2,2);
     itBECOMESBLUE();
     createball();
     createpad();
     while(!kbhit());
     while(!ismouseclick(WM_LBUTTONDBLCLK))
     { 
      ballx = oldballx;
      bally = oldbally;
      eraseoldball();
      itBECOMESBLUE();
      moveball();    
      if(gameonoff==1)
       goto outtaloop;
      movepad();
     }
     outtaloop:
     closegraph();
    }
    
    void createwalls(int leftwall, int rightwall)
    {
     setcolor(COLOR(141, 249, 136));
     rectangle(leftwall,1,leftwall+1,480);
     rectangle(640-rightwall,1,640-rightwall+1,480);
     rectangle(leftwall,1,640-rightwall,2);
     return;
    }
    
    void createball(void)
    {
     circle(centerx,centery,r);
     return;
    }
    
    void createpad(void)
    {
     padcenter=centerx;
     setcolor(WHITE);
     rectangle(padcenter-3,460,padcenter+3,461);
     return;
    }
    
    void itBECOMESBLUE(void)
    {
     setcolor(COLOR(20,10,250));
     return;
    }
    
    void eraseoldball(void)
    {
     setcolor(BLACK);
     circle(oldballx,oldbally,r);
     return;
    }
    
    void moveball(void)
    {
     itBECOMESBLUE();
     if(ballx==leftwall+3)
      ballgox=1;
     if(ballx==rightwall-3)
      ballgox=0;
     if(bally==4)
      ballgoy=1;
     if(bally==457)
      {
       if(padcenter+3>ballx && padcenter-3<ballx)
        ballgoy=0;
        counter++;
      }
     if(bally==450)
      {
       goto hell;
      } 
     if (ballgox==1)
      ballx++;
     if (ballgox==0)
      ballx--;
     if (ballgoy==1)
      bally++;
     if (ballgoy==0)
      bally--;
     circle(ballx,bally,r);
     return;
    hell:
     gameonoff=1;
     return;
    }
    
    void movepad(void)
    {
     oldpadcenter=padcenter;
     setcolor(BLACK);
     rectangle(oldpadcenter-3,460,oldpadcenter+3,461);
     padcenter=mousex();
     if(padcenter<=5 || padcenter>=674)
      padcenter=oldpadcenter; 
     setcolor(COLOR(141,249,136));
     rectangle(padcenter-3,460,padcenter+3,461);
     return;
    }
    Thanx for being so patient with reading this...
    But remember, I'm a newbie.
    Sauron a few seconds before his defeat:
    "What? A 'division by 0' error?!?"

  2. #2
    Registered User
    Join Date
    Aug 2001
    Posts
    100

    ---

    Oh, by the way!
    You could also teach me how to use sprites.
    Or how to do some multitasking...
    Sauron a few seconds before his defeat:
    "What? A 'division by 0' error?!?"

  3. #3
    Registered User
    Join Date
    Aug 2001
    Posts
    247
    OH NOOOOOOOOOOOOO. More C++ on the C Board..............................AAAAAAAHHHHHHHH H!
    hoping to be certified (programming in c)
    here's the news - I'm officially certified.

  4. #4
    Just one more wrong move. -KEN-'s Avatar
    Join Date
    Aug 2001
    Posts
    3,230
    it is C...it just belongs on the windows board.

  5. #5
    Registered User
    Join Date
    Aug 2001
    Posts
    100

    Talking Oops!

    Sorry, guys.

    I wasn't thinking about that...

    By the way! I triplechecked it and found A LOT of bugs!
    Shouldn't do anything after midnight...

    But why it belongs on the Windows-board? I'm just using winbgim, but there's nothing related to Windows®©™...

    Does anyone know how to use "multitask"-thing?
    Sauron a few seconds before his defeat:
    "What? A 'division by 0' error?!?"

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. VC++ 6 & MASM (eek)
    By cboard_member in forum C++ Programming
    Replies: 2
    Last Post: 07-16-2005, 11:00 AM
  2. eek a virus
    By MisterSako in forum Tech Board
    Replies: 17
    Last Post: 06-08-2005, 04:29 PM
  3. Survival Football, ongoing! (GENERIC EXCITED TITLE)
    By PJYelton in forum A Brief History of Cprogramming.com
    Replies: 179
    Last Post: 12-14-2004, 10:19 AM
  4. class eek! problem
    By Kohatian 3279 in forum C++ Programming
    Replies: 1
    Last Post: 03-16-2002, 03:39 AM
  5. Replies: 3
    Last Post: 01-22-2002, 12:22 AM

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