C++

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • #1
    FFR Player
    IAMTHEEVILBEAN
    • Jun 2003
    • 3078

    C++

    Hey anyone know c++...i am starting to learn it now and wondered if I could get any pointers....
  • #2
    Retired Staff
    87x
    • Dec 2002
    • 4379

    umm study.... lol.. and no i dont know it.. just stick to your book and give up your whole non computer life to keep trying to learn it


    RAVEnHEXa: Lip ring is because I want to be a professional piercer.
    87x: more like.. professional goth.

    Comment

    • #3
      FFR Player
      IAMTHEEVILBEAN
      • Jun 2003
      • 3078

      Hmmmm give up whole non computer life.....*thinks* what is this non computer life you speak of

      Comment

      • #4
        FFR Player
        • May 2002
        • 1088

        I think you should start out easy...like with VB becuase C++ is hard.

        Comment

        • #5
          FFR Player
          SotN
          • Dec 2002
          • 1159

          What other languages do you know?
          209

          Comment

          • #6
            FFR Player
            Valek
            • Jun 2003
            • 30

            I agree with Yoshimaro, learn VB since it's a lot easier than C++, then go to C++. Or, if you just master C++, Visual Basic is just going to seem like childs play, so whatever.

            Comment

            • #7
              FFR Player
              makaveli121212
              • May 2003
              • 3823

              i think c++ is easy; devlop a personal style and stick with it, that will help alot; you could ask vxdx he wrote snake and pong in c++, probably the best at c++ that i know
              Originally posted by VxDx
              Stick it in her butt and pee.

              Comment

              • #8
                FFR Simfile Author
                FFR Simfile Author
                Freak83
                • Feb 2003
                • 3281

                I want to know C++ so badly... you see, Natural-Selection was made with C++

                Comment

                • #9
                  FFR Player
                  flipmaster99
                  • Feb 2003
                  • 79

                  C++ isn't that hard to learn.. in my opinion Java is better, C++ is too lenient in the things you can do sometimes (which can be good or bad).

                  If you have any general questions about C++, i can help you out there.

                  Comment

                  • #10
                    FFR Player
                    FFRdaveg
                    • Jun 2003
                    • 68

                    When your learning c++ it's good to look at the code in the book and understand whats happening for example
                    Some C++ books are heavy n useless information so when you get the basic idea of what something does I recommend you right it down so you don't forget with all the other stuff in the book.
                    cout and cin are important for beginners. it's not that hard to learn if your in algebra or above thats all i have to say
                    Anime, DDR, and a coke.

                    Comment

                    • #11
                      FFR Player
                      VxDx
                      • May 2003
                      • 1871

                      Code:
                      #include<conio.h>
                      #include<iostream.h>
                      #include<dos.h>
                      #include<mem.h>
                      #include<stdlib.h>
                      #include<math.h>
                      
                      //---------------------------------
                      //video
                      unsigned char *vga = &#40;unsigned char *&#41; MK_FP&#40;0xA000, 0&#41;;
                      
                      void setTEXT&#40;&#41;
                      &#123;
                      		_AX= 0x0003;
                            geninterrupt&#40;0x10&#41;;
                      &#125;
                      
                      void setMCGA&#40;&#41;
                      &#123;
                          _AX = 0x0013;
                          geninterrupt &#40;0x10&#41;;
                      &#125;
                      
                      void MEMPutpixel &#40;int x, int y, unsigned char Col&#41;
                      &#123;
                          memset&#40;vga+x+&#40;y*320&#41;,Col,1&#41;;
                      &#125;
                      //video
                      //------------------------------
                      
                      
                      
                      void menu&#40;&#41;;
                      int igmenu&#40;&#41;;
                      void drawball&#40;&#41;;
                      void drawpaddle1&#40;int&#41;;
                      void drawpaddle2&#40;int&#41;;
                      void drawtable&#40;&#41;;
                      void hitproj&#40;&#41;;
                      void supar&#40;&#41;;
                      void calcbpos&#40;&#41;;
                      
                      
                      const int
                      		xboardlimleft=40,
                      		xboardlimright=280,
                            yboardlimtop=40,
                            yboardlimbottom=160,
                            paddlewalldist=10,
                            paddlemovedist=4;
                      
                      int 	color,
                      		randcolor = 0,
                            speed,
                            bx=160,
                            by=100,
                            p1y=100,
                            p2y=100,
                            quit=0,
                            dir=-1,
                            x=0,
                            y=0;
                      float proj=1,
                      		tempx=160,
                      		tempy=100;
                      
                      ////////////////////////////////////////////////////////////////////////////////
                      //MAIN//////////////////////////////////////////////////////////////////////////
                      void main&#40;&#41;
                      &#123;
                      	int key=72;
                      while&#40;igmenu&#40;&#41;&#41;
                      &#123;
                         	bx=160; by=100;
                         	p1y=100; p2y=100;
                         	quit=0;
                         	dir=-1;
                         	x=0; y=0;
                         	proj=1;
                         	tempx=160; tempy=100;
                      
                      	menu&#40;&#41;;
                         setMCGA&#40;&#41;;
                         drawtable&#40;&#41;;
                         drawpaddle1&#40;2&#41;;
                         drawpaddle2&#40;2&#41;;
                         delay&#40;2000&#41;;
                      
                      bx=160;  x=160;
                      by=100;  y=100;
                      while&#40;bx!=xboardlimleft && bx!=xboardlimright&#41;
                      &#123;
                         if&#40;randcolor==1&#41;color=random&#40;16&#41;;
                         drawball&#40;&#41;;
                      
                      	if&#40;kbhit&#40;&#41;&#41;
                         &#123;
                         	key = getch&#40;&#41;;
                         &#125;
                            switch&#40;key&#41;
                            &#123;
                            	case 72&#58;p2y-=paddlemovedist;   drawpaddle2&#40;1&#41;;   break;
                               case 80&#58;p2y+=paddlemovedist;   drawpaddle2&#40;0&#41;;   break;
                               case 97&#58;p1y-=paddlemovedist;   drawpaddle1&#40;1&#41;;   break;
                               case 122&#58;p1y+=paddlemovedist;  drawpaddle1&#40;0&#41;;  break;
                               case 27&#58;igmenu&#40;&#41;;
                            &#125;
                         key=0;
                         hitproj&#40;&#41;;
                      
                         delay&#40;3*speed&#41;;
                         calcbpos&#40;&#41;;
                      
                      &#125;
                      randcolor=0;
                      &#125;
                      
                      getch&#40;&#41;;
                      &#125;
                      //END MAIN//////////////////////////////////////////////////////////////////////
                      ////////////////////////////////////////////////////////////////////////////////
                      
                      
                      
                      
                      void menu&#40;&#41;
                      &#123;
                      cout<<"Color 1 - 16...";
                      cin>>color;
                      if&#40;color ==0&#41;&#123;randcolor=1;color = 15;&#125;
                      color-=1;
                      cout<<"\n\nSpeed 1-15 &#40;15 = slow&#41;...";
                      cin>>speed;
                      &#125;
                      
                      
                      
                      
                      
                      void supar&#40;&#41;
                      &#123;
                      	int c=0 , x=160 , y=100 , vect=0 , colo=10 , key;
                         randomize&#40;&#41;;
                      
                         while&#40;key != 27&#41;
                         &#123;
                      
                         switch&#40;vect&#41;
                         &#123;
                         	case 0&#58;	x=x+1;   break;
                         	case 1&#58;	y=y-1;   break;
                            case 2&#58;	x=x-1;   break;
                            case 3&#58;	y=y+1;   break;
                         &#125;
                      
                         if&#40;c==0&#41;colo=10;
                         if&#40;c==30000&#41;colo=0;
                      	MEMPutpixel&#40;x,y,colo&#41;;
                         c++;
                         switch&#40;random&#40;7&#41;&#41;
                         &#123;
                         	case 0&#58; vect=random&#40;4&#41;;
                      	&#125;
                         if&#40;kbhit&#40;&#41;&#41;key = getch&#40;&#41;;
                         &#125;
                      
                      &#125;
                      
                      
                      
                      
                      
                      int igmenu&#40;&#41;
                      &#123;
                         int ch;
                      	setTEXT&#40;&#41;;
                         cout<<"1&#58; Continue\n";
                         cout<<"2&#58; Quit\n";
                         cout<<"666&#58; FOR A SUPAR TIME\n\n";
                         cin>>ch;
                      
                         if&#40;ch==2&#41;exit&#40;0&#41;;
                         setMCGA&#40;&#41;;
                         if&#40;ch==666&#41;supar&#40;&#41;;
                        	return 1;
                      &#125;
                      
                      
                      
                      
                      void drawball&#40;&#41;
                      &#123;
                      	MEMPutpixel&#40;bx,by,color&#41;;
                      
                         //for&#40;int xx=bx-10;xx<=bx+10;xx++&#41;&#123;
                         //for&#40;int yy=by-10;yy<=by+10;yy++&#41;&#123;
                         //MEMPutpixel&#40;xx,yy,color&#41;;&#125;&#125;
                      
                         //for&#40;int xx=x-10;xx<=x+10;xx++&#41;&#123;
                         //for&#40;int yy=y-10;yy<=x+10;yy++&#41;&#123;
                         //MEMPutpixel&#40;xx,yy,0&#41;;&#125;&#125;
                         MEMPutpixel&#40;x,y,0&#41;;
                      &#125;
                      
                      void drawpaddle1&#40;int ud&#41;
                      &#123;
                         int e;
                      
                         if&#40;p1y>yboardlimtop && p1y<&#40;yboardlimbottom-16&#41;&#41;
                         		for&#40;e=0 ; e<16 ; e++&#41;&#123;MEMPutpixel&#40;&#40;xboardlimleft+paddlewalldist&#41;,&#40;p1y+e&#41;,color&#41;;&#125;
                      
                         if&#40;ud==1 && p1y>yboardlimtop && p1y<&#40;yboardlimbottom-16&#41;&#41;
                             for&#40; int jig=1;jig<5;jig++&#41;MEMPutpixel&#40;&#40;xboardlimleft+paddlewalldist&#41;,p1y+16+jig,0&#41;;
                      
                         if&#40;ud==0 && p1y>yboardlimtop && p1y<&#40;yboardlimbottom-16&#41;&#41;
                             for&#40; int jig=1;jig<5;jig++&#41;MEMPutpixel&#40;&#40;xboardlimleft+paddlewalldist&#41;,p1y-jig,0&#41;;
                      &#125;
                      
                      void drawpaddle2&#40;int ud&#41;
                      &#123;
                         int e;
                      
                      	if&#40;p2y>yboardlimtop && p2y<&#40;yboardlimbottom-16&#41;&#41;
                         	for&#40;e=0 ; e<16 ; e++&#41;&#123;MEMPutpixel&#40;&#40;xboardlimright-paddlewalldist&#41;,&#40;p2y+e&#41;,color&#41;;&#125;
                      
                         if&#40;ud==1 && p2y>yboardlimtop && p2y<&#40;yboardlimbottom-16&#41;&#41;
                         	for&#40; int jig=1;jig<5;jig++&#41;MEMPutpixel&#40;&#40;xboardlimright-paddlewalldist&#41;,p2y+16+jig,0&#41;;
                      
                         if&#40;ud==0 && p2y>yboardlimtop && p2y<&#40;yboardlimbottom-16&#41;&#41;
                         	for&#40; int jig=1;jig<5;jig++&#41;MEMPutpixel&#40;&#40;xboardlimright-paddlewalldist&#41;,p2y-jig,0&#41;;
                      &#125;
                      
                      void drawtable&#40;&#41;
                      &#123;
                      	for&#40;int y=yboardlimtop ; y<yboardlimbottom ; y++&#41;
                         	&#123;MEMPutpixel&#40;xboardlimleft,y,color&#41;;  MEMPutpixel&#40;xboardlimright,y,color&#41;;&#125;
                         for&#40;int x=xboardlimleft ; x<xboardlimright ; x++&#41;
                         	&#123;MEMPutpixel&#40;x,yboardlimtop,color&#41;;  MEMPutpixel&#40;x,yboardlimbottom,color&#41;;&#125;
                      &#125;
                      
                      
                      
                      void hitproj&#40;&#41;
                      &#123;
                      	// |  add 2
                         // |  add 2
                         // |  add 2
                         // |  add 1
                         // |  add 1
                         // |  add .5
                         // |  add .5
                         // |  add 0
                         // |  add 0
                         // |  sub .5
                         // |  sub .5
                         // |  sub 1
                         // |  sub 1
                         // |  sub 2
                         // |  sub 2
                         // |  sub 2
                      
                         //dir  <- = -1   1 = ->
                         //when hit, ball changes direction and slope to the opposites
                      
                         x=bx;
                         y=by;
                         if&#40;by == &#40;yboardlimtop+1&#41; || by == &#40;yboardlimbottom-1&#41;&#41; proj = -proj;
                         if&#40;bx == &#40;xboardlimleft+1+paddlewalldist&#41; && dir == -1&#41;
                            	switch&#40;by-p1y&#41;
                               &#123;
                               	case 0&#58;
                                  case 1&#58;dir=1;  proj+=2; break;
                                  case 2&#58;
                                  case 3&#58;dir=1; proj+=1; break;
                                  case 4&#58;
                                  case 5&#58;dir=1;  proj+=.5; break;
                                  case 6&#58;
                                  case 7&#58;dir=1;  proj+=.2; break;
                                  case 8&#58;
                                  case 9&#58;dir=1;  proj-=.2; break;
                                  case 10&#58;
                                  case 11&#58;dir=1;  proj-=.5; break;
                                  case 12&#58;
                                  case 13&#58;dir=1; proj-=1; break;
                                  case 14&#58;
                                  case 15&#58;dir=1;  proj-=2; break;
                               &#125;
                      
                         if&#40;bx == &#40;xboardlimright-1-paddlewalldist&#41; && dir == 1&#41;
                               switch&#40;by-p2y&#41;
                               &#123;
                               	case 0&#58;
                                  case 1&#58;dir=-1;  proj-=2; break;
                                  case 2&#58;
                                  case 3&#58;dir=-1; proj-=1; break;
                                  case 4&#58;
                                  case 5&#58;dir=-1;  proj-=.5; break;
                                  case 6&#58;
                                  case 7&#58;dir=-1;  proj+=.2; break;
                                  case 8&#58;
                                  case 9&#58;dir=-1;  proj-=.2; break;
                                  case 10&#58;
                                  case 11&#58;dir=-1;  proj+=.5; break;
                                  case 12&#58;
                                  case 13&#58;dir=-1; proj+=1; break;
                                  case 14&#58;
                                  case 15&#58;dir=-1;  proj+=2; break;
                               &#125;
                      
                      
                      &#125;
                      
                      
                      
                      void calcbpos&#40;&#41;
                      &#123;
                         /*
                         if&#40;dir == 1&#41;
                         &#123;
                         	if&#40;proj==1&#41;&#123;bx++;by--;&#125;
                         	else&#123;bx++;by++;&#125;
                         &#125;else&#123;
                         	if&#40;proj==1&#41;&#123;bx--;by++;&#125;
                         	else&#123;bx--;by--;&#125;
                         &#125;   */
                      
                      
                        	if&#40;dir == 1&#41;
                         &#123;
                      
                      		if&#40;proj>0&#41;
                            &#123;
                            	if&#40;proj>=1&#41;
                         		&#123;tempx+=1/proj;tempy-=1;&#125;
                            	else &#123;tempx+=proj;tempy-=1;&#125;
                            &#125;
                            if&#40;proj<0&#41;
                            &#123;
                            	if&#40;proj<=-1&#41;
                            	&#123;tempx-=1/proj;tempy+=1;&#125;
                            	else &#123;tempx-=proj;tempy+=1;&#125;
                            &#125;
                            if&#40;proj==0&#41;tempx+=1;
                      	&#125;
                      
                         if&#40;dir == -1&#41;
                         &#123;
                         	if&#40;proj>0&#41;
                            &#123;
                            	if&#40;proj>=1&#41;
                         		&#123;tempx-=1/proj;tempy+=1;&#125;
                            	else &#123;tempx-=proj;tempy+=1;&#125;
                            &#125;
                            if&#40;proj<0&#41;
                            &#123;
                            	if&#40;proj<=-1&#41;
                            	&#123;tempx+=1/proj;tempy-=1;&#125;
                            	else &#123;tempx+=proj;tempy-=1;&#125;
                            &#125;
                            if&#40;proj==0&#41;tempx--;
                         &#125;
                      
                         bx=tempx;
                         by=tempy;
                      &#125;
                      that's an early version of pong I wrote.

                      As for tips, make sure you know why what you write works, it will help in the long run. Also, if you ever think of a problem that you wish could go faster (lets say for a math class or something) write a program for it. It will help you get comfortable with the basic ideas.[/code]

                      Comment

                      • #12
                        FFR Player
                        flipmaster99
                        • Feb 2003
                        • 79

                        Wow, nice job on the Pong program. You say that's an earlier version of it.. does that mean you have a more efficient way or what?

                        Out of curiosity, how old are you?

                        Comment

                        • #13
                          FFR Player
                          makaveli121212
                          • May 2003
                          • 3823

                          i told u the guys a fucknig wiz
                          Originally posted by VxDx
                          Stick it in her butt and pee.

                          Comment

                          • #14
                            FFR Player
                            VxDx
                            • May 2003
                            • 1871

                            Originally posted by flipmaster99
                            Wow, nice job on the Pong program. You say that's an earlier version of it.. does that mean you have a more efficient way or what?

                            Out of curiosity, how old are you?
                            Later versions were more efficient, had more features, more accurate ball physics and such.

                            I'm 16.

                            I have a pretty good snake too. I just don't know where it is.

                            Comment

                            • #15
                              FFR Player
                              makaveli121212
                              • May 2003
                              • 3823

                              ...fucking wiz
                              Originally posted by VxDx
                              Stick it in her butt and pee.

                              Comment

                              Working...