• Lucid Dreaming - Dream Views




    Page 2 of 7 FirstFirst 1 2 3 4 ... LastLast
    Results 26 to 50 of 165
    1. #26
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Good start, maybe the next thing you can learn is how to save your screenshots in pngs instead of jpgs

      Ynot speaks the truth, a good design is paramount to success, every detail should be worked out before any code is written. Here is the design for the side scroller that I've started, I'll probably write it this weekend:

      Spoiler for Top Down Design:

    2. #27
      Gentlemen. Ladies. slayer's Avatar
      Join Date
      Mar 2007
      Gender
      Location
      Right here... Reputation: 9999
      Posts
      4,902
      Likes
      473
      DJ Entries
      4
      Quote Originally Posted by ninja9578 View Post
      Good start, maybe the next thing you can learn is how to save your screenshots in pngs instead of jpgs
      A haw haw

      Looks like you've got quite a bit of work to do there...

      How do I get away from the command prompt though? Like I want my own window made.

      Edit: Also, do I use C++ in other things like Aleggro or SDL?

    3. #28
      .. / .- –– / .- .-. guitarboy's Avatar
      Join Date
      Sep 2008
      LD Count
      Over 9000
      Gender
      Location
      Homeward Bound
      Posts
      1,571
      Likes
      49
      Thanks guys.
      I'm going to learn C++ first, then maybe C. Oh, Ninja, what compiler/text editor do you use? I'm using code::blocks, but I also have xcode though it's more confusing. Which do you suggest?(I'm asking you because I now you're an apple guy )

    4. #29
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Quote Originally Posted by slayer View Post
      A haw haw

      Looks like you've got quite a bit of work to do there...

      How do I get away from the command prompt though? Like I want my own window made.

      Edit: Also, do I use C++ in other things like Aleggro or SDL?
      Not really, because I've mapped it all out, I think it will be fairly easy, each of those components shouldn't take more than 50 lines of code.

      C / C++ is platform independent, so it has no support for windows natively. You have to use an external library. This could be X11, GTK, Windows API, wxWidgets, Qt, or GLUT. For games, GLUT is the easiest choice because it's an extension on OpenGL. GLUT is also the easiest for a beginner because it's C based, therefore there is no complex C++ functionality like Templates and inheritance and stuff.

      Allegro and SDL can both be used in C++, however, OpenGL has been the graphics standard for 15 years.

      Quote Originally Posted by guitarboy View Post
      Thanks guys.
      I'm going to learn C++ first, then maybe C. Oh, Ninja, what compiler/text editor do you use? I'm using code::blocks, but I also have xcode though it's more confusing. Which do you suggest?(I'm asking you because I now you're an apple guy )
      I use Code::Blocks when I'm writing code on Windows or Linux, and XCode and Code::Blocks when writing code on OSX. Code::Blocks is far simpler, however XCode is the most powerful IDE out there. So what I do for big projects is I write small components in XCode and use all of XCode's debugging tools and such to make sure it's right, then put them together in Code::Blocks.
      Last edited by ninja9578; 01-08-2010 at 02:16 PM.

    5. #30
      Gentlemen. Ladies. slayer's Avatar
      Join Date
      Mar 2007
      Gender
      Location
      Right here... Reputation: 9999
      Posts
      4,902
      Likes
      473
      DJ Entries
      4
      How exactly do I draw an image onto the screen?

      And I found a tutorial for making a window. I'm not sure if it was just the tutorial, but there is a butt load of code involved for making something as simple as that. You'd think it'd be easier right?

    6. #31
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      Quote Originally Posted by slayer View Post
      How exactly do I draw an image onto the screen?
      I'm not a graphics guy (I hardly ever program GUI apps)

      but using ninja's sugesstion of GLUT
      here's sample code from a Glut tutorial

      Code:
      #include <GL/glut.h>
      
      void renderScene(void) {
          glClear(GL_COLOR_BUFFER_BIT);
          glBegin(GL_TRIANGLES);
              glVertex3f(-0.5,-0.5,0.0);
              glVertex3f(0.5,0.0,0.0);
              glVertex3f(0.0,0.5,0.0);
          glEnd();
          glFlush();
      }
      
      void main(int argc, char **argv) {
          glutInit(&argc, argv);
          glutInitDisplayMode(GLUT_DEPTH | GLUT_SINGLE | GLUT_RGBA);
          glutInitWindowPosition(100,100);
          glutInitWindowSize(320,320);
          glutCreateWindow("3D Tech- GLUT Tutorial");
          glutDisplayFunc(renderScene);
          glutMainLoop();
      }
      This will open up a window, 320x320, with a triangle in it
      (\_ _/)
      (='.'=)
      (")_(")

    7. #32
      Gentlemen. Ladies. slayer's Avatar
      Join Date
      Mar 2007
      Gender
      Location
      Right here... Reputation: 9999
      Posts
      4,902
      Likes
      473
      DJ Entries
      4
      *sigh*

      I think I'll just go back to learning lines of text and numbers...

    8. #33
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Don't be intimidated, it's really quite simple if you know what each command does. Follow the path of the code, it always starts at main, and I've put comments around the OpenGL and GLUT stuff explaining what each function does.

      Code:
      #include <GLUT/glut.h>
      
      void renderScene(void) {
          /*
      	   glClear erases what's already stored in the drawing area,
      	   GL_COLOR_BUFFER_BIT is the colour to restore it too, by default, it's black
          */
          glClear(GL_COLOR_BUFFER_BIT);
          
          /*
      	   We want to draw a triangle, so tell OpenGL that the next drawing functions that we are doing
      	   should be done in triangle mode
          */
          glBegin(GL_TRIANGLES);
      	   /*
      		  These are the verticies of the triangles, now with the default setup on the window, the window is 1x1, so
      		  the coordinates are in relation to that.
      	   */
      	   glVertex2f(-0.5,-0.5);
      	   glVertex2f(0.5,0.0);
      	   glVertex2f(0.0,0.5);
          //This tells OpenGL that I'm done placing my coordinates and that it can draw it
          glEnd();
          /*
      	   This one is also pretty complicated, OpenGL buffers it's drawing commands for optimization purposes
      	   this glFlush command tells OpenGL that there are no more commands to come, and that it can go ahead and
      	   finish drawing whatever's still in the buffer
          */
          glFlush();
      }
      
      int main (int argc, char ** argv){
          /*
      	   This line initialized GLUT, which is the window engine and the interface to OpenGL
      	   Internally, it loads the libraries and sets everything up
          */
          glutInit(&argc, argv);
          
          /*
      	   This sets the initial display mode for OpenGL
      	   GLUT_SINGLE means that it's using a single drawing page, so everything that gets drawn goes directly onto the screen
      		  games should be double buffered to elimiate flickering
      	   GLUT_RGBA tells glut that the pixels will be rendered in Red, Green, Blue, Alpha order
          */
          glutInitDisplayMode(GLUT_SINGLE | GLUT_RGBA);
          
          //These should be obvious, they're setting the window's position
          glutInitWindowPosition(100,100);
          glutInitWindowSize(320,320);
          //Creates the actual window
          glutCreateWindow("3D Tech- GLUT Tutorial");
          
          /*
      	   This is a little advanceds, this is registering what's known as a callback function.  GLUT basically needs to know what do it
      	   if it's in a situation where it needs to draw.  This could be the intial render, or of another window is moved over it, or if
      	   it's resized.  glutDisplayFunc is given the name of the method that glut should call when it needs to redraw
          */
          glutDisplayFunc(renderScene);
          /*
      	   Start the main loop :)
          */
          glutMainLoop();
          return 0;
      }

    9. #34
      Member Achievements:
      1 year registered Veteran First Class 5000 Hall Points

      Join Date
      Sep 2004
      Gender
      Location
      Seattle, WA
      Posts
      2,503
      Likes
      217
      Quote Originally Posted by slayer View Post
      I'm learning C++ to learn how to make my own game engine. I don't really know anything about C.
      If you're just getting started with C++, I recommend a few smaller (like, MUCH smaller) projects first.

    10. #35
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      Quote Originally Posted by Replicon View Post
      If you're just getting started with C++, I recommend a few smaller (like, MUCH smaller) projects first.
      Indeed,
      first learn the language, then do something small and easy to get the hang of things
      Quote Originally Posted by Ynot View Post
      hangman is always a good first game

      pick a random word from file of possible words
      let the user guess letters
      print letters found, and underscores for not found
      keep a count of num guesses

      You've just started on your journey as a bridge-builder
      Your ultimate aim is this
      http://secretperson.files.wordpress....n-bridge-l.jpg
      but you've got to start off building a few of these first
      http://www.freeimageslive.co.uk/file...46.preview.jpg
      Last edited by Ynot; 01-09-2010 at 03:35 AM.
      (\_ _/)
      (='.'=)
      (")_(")

    11. #36
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      I agree, you saw my design right? Mario is a fairly simple game, yet it's quite a lot of classes and functionality. I could probably knock it out in a day, but I'm very experienced.

    12. #37
      Gentlemen. Ladies. slayer's Avatar
      Join Date
      Mar 2007
      Gender
      Location
      Right here... Reputation: 9999
      Posts
      4,902
      Likes
      473
      DJ Entries
      4
      I guess I made my first game!

      Simple if/else statement set up.

      Code:
      #include <iostream>
      using namespace std;
      
      int main()
      {
          int a;
      
          cout << "Please enter the number 3: ";
          cin >> a;
          if ( a == 3)
          {
              cout << "You have entered the right number!";
          }
          else
          {
              cout << "You lost the game.";
          }
          return 0;
      }
      If you enter the number 3, you win! But if you don't, then you lose!

      How would I set it up so it repeats the first line of code?

      I want to set it up so that if the player enters the wrong number, then it goes to repeat the "Please enter the number 3" part. Or, if they get it wrong, then it asks for the player "Do you want to play again? Y/N" and if they enter Y then the whole thing repeats itself, or if they enter N, then the game exits.

    13. #38
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      You need a loop. C++ has a number of loops, but the one that you want is the do/while loop Basically it's saying do {this code} while (this is true)

      Code:
      #include <iostream>
      using namespace std;
      
      int main()
      {
          int a;
          char cc;
          
          do {
      	   cout << "Please enter the number 3: ";
      	   cin >> a;
      	   if ( a == 3)
      	   {
      		  cout << "You have entered the right number!";
      		  return;
      	   }
      	   else
      	   {
      		  cout << "You lost the game." << endl << "Would you like to play again? Y/N";
      		  cin >> cc;
      	   }
          } while (cc != 'Y');
          return 0;
      }

    14. #39
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      Code:
      #include <iostream>
      using namespace std;
      
      int main()
      {
          int a;
          bool correct = false;
          char play_again;
      
          while ( ! correct )
          {
              cout << "Please enter the number 3: ";
              cin >> a;
      
              if ( a == 3)
              {
                  correct = true;
                  cout << "You have entered the right number!" << endl;
              }
              else
              {
                  cout << "You lost the game." << endl;
      
                  cout << "Play again? (y/n): ";
                  cin >> play_again;
      
                  if ( play_again != 'y' )
                  {
                      correct = true;
                      cout << "Thanks for playing." << endl << "Goodbye!" << endl;
                  }
              }
          }
          return 0;
      }
      although I'll leave you with this
      The above is not very clear to read (it's all in one function)
      your job (when you get far enough along with the language) is to clean this up with a much simpler program flow


      *edit*
      beaten to it
      (\_ _/)
      (='.'=)
      (")_(")

    15. #40
      Gentlemen. Ladies. slayer's Avatar
      Join Date
      Mar 2007
      Gender
      Location
      Right here... Reputation: 9999
      Posts
      4,902
      Likes
      473
      DJ Entries
      4
      What does the "char" do?

    16. #41
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      it's the character datatype
      meaning it stores a single character

      a sequence of character datatypes "strung" together is where the word "string" comes from
      (\_ _/)
      (='.'=)
      (")_(")

    17. #42
      khh
      khh is offline
      Remember Achievements:
      1000 Hall Points Veteran First Class
      khh's Avatar
      Join Date
      Jun 2009
      Gender
      Location
      Norway
      Posts
      2,482
      Likes
      1309
      Edit: Never mind. Note to self: Learn to see if there are more pages.

      But yeah, I also support you doing some smaller projects first.
      Last edited by khh; 01-09-2010 at 05:10 PM.
      April Ryan is my friend,
      Every sorrow she can mend.
      When i visit her dark realm,
      Does it simply overwhelm.

    18. #43
      Generic lucid dreamer Seeker's Avatar
      Join Date
      Oct 2003
      Gender
      Location
      USA
      Posts
      10,790
      Likes
      103
      Have you given any thought yet to C#?

      C is pretty much dead except for embedded solutions, C++ is still a great language and supports object oriented design, but with modern hardware, all but the most time critical tasks can be handled with C#. You also have the ability to call C++ unmanaged code from within wrappers if you have a section that needs to execute at it's fastest.

      My suggestion for a compiler is Visual Studio 2005 or 2008 (2003 is OK, but doesn't support the .NET 2.0 framework well). I've been using the Microsoft Cxx compilers since they were introduced and really like it. In fact I'm using VS2005 as we speak.
      you must be the change you wish to see in the world...
      -gandhi

    19. #44
      khh
      khh is offline
      Remember Achievements:
      1000 Hall Points Veteran First Class
      khh's Avatar
      Join Date
      Jun 2009
      Gender
      Location
      Norway
      Posts
      2,482
      Likes
      1309
      Quote Originally Posted by Seeker View Post
      Have you given any thought yet to C#?
      C# is generally just used for Windows exclusive applications, though, and they require the .NET network to run. It's harder to write cross-platform applications. It's not as elegant at making native applications, though you're saved from hunting for external libraries or writing system-call wrappers yourself.

      Quote Originally Posted by Seeker View Post
      C is pretty much dead except for embedded solutions, C++ is still a great language and supports object oriented design, but with modern hardware, all but the most time critical tasks can be handled with C#. You also have the ability to call C++ unmanaged code from within wrappers if you have a section that needs to execute at it's fastest.
      I thought C was commonly used for time-critical operations still, such as graphics modules.

      Quote Originally Posted by Seeker View Post
      My suggestion for a compiler is Visual Studio 2005 or 2008 (2003 is OK, but doesn't support the .NET 2.0 framework well). I've been using the Microsoft Cxx compilers since they were introduced and really like it. In fact I'm using VS2005 as we speak.
      I do however agree that Visual Studio is an excellent set of coding tools. I use VS2008 professional myself (no, it's not pirated... but neither is it bought).
      April Ryan is my friend,
      Every sorrow she can mend.
      When i visit her dark realm,
      Does it simply overwhelm.

    20. #45
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Even unsafe C# code doesn't run as quickly as C++.

      It's also very heavily dependent on the Windows runtime libraries. I think C# is an atrocious attempt at making C++ more like Java. C and it's derivatives are not meant to be safe, they're meant to do exactly what you tell them to do.

    21. #46
      Ex Tech Admin Achievements:
      Created Dream Journal Tagger First Class Veteran First Class 10000 Hall Points Populated Wall Referrer Gold Made lots of Friends on DV
      slash112's Avatar
      Join Date
      Nov 2008
      Gender
      Location
      Sunny Scotland
      Posts
      5,113
      Likes
      1567
      DJ Entries
      29
      Wow...
      I think I'm going to attempt to start learning C++ again...

      I gave up pretty darn quick last time. Mostly because I was trying to get code::blocks or something and it wasn't working... is code::blocks like a plugin to microsoft visual C++ or something?
      In fact, talking of which, is microsoft visual C++ the right thing to use?

      EDIT: Hold on... is code::blocks entirely seperate from windows visual?

    22. #47
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      code::blocks has nothing to do with MS
      It's a cross-platform IDE for C & C++

      I wouldn't get too hung up on IDE's to start with
      Just code in a decent text editor (eg. Vim) and compile on the CLI
      (\_ _/)
      (='.'=)
      (")_(")

    23. #48
      Ex Tech Admin Achievements:
      Created Dream Journal Tagger First Class Veteran First Class 10000 Hall Points Populated Wall Referrer Gold Made lots of Friends on DV
      slash112's Avatar
      Join Date
      Nov 2008
      Gender
      Location
      Sunny Scotland
      Posts
      5,113
      Likes
      1567
      DJ Entries
      29
      Ah yea, I had a look around google just there.

      And... hrm... by the way I see it, I would rather use code::blocks.

      I don't want to have to end up changing what I use once/if I get better at it. Besides... code::blocks looks more appealing than vim, and less complicated looking.

    24. #49
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Code::Blocks is great, it's what I use professionally on Windows and Linux. And it does all the complicated linking crap for you.

    25. #50
      Ex Tech Admin Achievements:
      Created Dream Journal Tagger First Class Veteran First Class 10000 Hall Points Populated Wall Referrer Gold Made lots of Friends on DV
      slash112's Avatar
      Join Date
      Nov 2008
      Gender
      Location
      Sunny Scotland
      Posts
      5,113
      Likes
      1567
      DJ Entries
      29
      Cool, I have downloaded and installed code::blocks. Then it asked me what compiler to use, so I used windows visual C++ since it was already on my computer from last time I tried all this stuff.

      My problem now is that it won't build or something, I click build, then I click run, and it says I need to build it. I then tried "build and run" and it just kinda does nothing. Don't know what the fuck is wrong here.

    Page 2 of 7 FirstFirst 1 2 3 4 ... LastLast

    Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •