• Lucid Dreaming - Dream Views




    Page 6 of 7 FirstFirst ... 4 5 6 7 LastLast
    Results 126 to 150 of 165
    1. #126
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Well if you're using glut, you can register a callback for that. Otherwise, you have to have a loop that continually check for it.

      Code:
      #include <pthread.h>
      pthread_t keyboard_thread;
      void * keyboard(void * argument){
         char mychar = '\0';
         while(mychar != 'x'){  loop until an x is pressed
            fflush(stdin);
            scanf("%c",&mychar); 
            switch (mychar){
               case ' ':
                  cout << "Space bar pressed" << endl;
                  break;
            }
         }
         return 0;
      }
      
      int main(){
         pthread_create(keyboard_thread, NULL, keyboard, NULL);
      
         //Do whatever you want
      
         return 0;
      }


      That's threading though, which is a little more complicated.
      Last edited by ninja9578; 01-20-2010 at 12:12 AM.

    2. #127
      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
      That'll only get input characters, though, like space and a, b, c, (...). The arrow keys and enter and all of those won't be registered, right? Also, pthreads doesn't work on windows.
      April Ryan is my friend,
      Every sorrow she can mend.
      When i visit her dark realm,
      Does it simply overwhelm.

    3. #128
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      pthreads works on windows I use it all the time.

      And yeah, then you use glut or another library with keyboard callbacks built in like wxWidgets or Qt or the Windows API
      Last edited by ninja9578; 01-20-2010 at 12:24 AM.

    4. #129
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      intercepting keystrokes is non-trivial
      as it's highly dependent on the environment (including whether the input stream is buffered or not)

      Best bet is to use a curses library
      (that's what all the text adventure games use)
      http://en.wikipedia.org/wiki/Curses_...ing_library%29
      (\_ _/)
      (='.'=)
      (")_(")

    5. #130
      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
      Jesus shitter, it sure is complicated for such a simple thing.

    6. #131
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      Well, intercepting keystrokes straight off the device isn't simple
      The OS has hooks to the keyboard device, and you're overriding them

      But the complexity of many things boils down to the desire to remain platform & architecture neutral

      I'm sure there's a simpler Windows specific hook you could tap into to intercept keyboard characters, but then you're hamstrung to a specific platform
      (and at the mercy of the platform to maintain the hook across future versions of the OS)
      (\_ _/)
      (='.'=)
      (")_(")

    7. #132
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Hooks are abstracted, Windows can change them and the APIs should still all work fine. Oh, abstraction is something that should be added to that list that I made.

    8. #133
      Member
      Join Date
      Feb 2004
      Posts
      5,165
      Likes
      709
      I have taken a bunch of different programing classes, and really the key is getting into the right frame of mind. Once you know one program its a lot easier to learn most others. Even entirely different programs use the same basic concepts.

    9. #134
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      I find that's true only if it's in the same paradigm. Knowing a procedural language it hard to go into a OOP language, and an assembly language is really weird.

    10. #135
      Member
      Join Date
      Feb 2004
      Posts
      5,165
      Likes
      709
      That is probably true. The ones I have worked with is java and c++ which are very alike. And the oracle programing language which is used for databases and stuff, I forget what it is called but its a lot like them too. As is HTML, which is like an entirely different area making webpages and stuff, but interactive websites uses a very similiar method.

      Also the small programs you download for like games and stuff. A lot of time they got their own languages for using inside the game(like games that lets you make maps and stuff). A lot of time they are based off this same type of stuff.

      There can be big changes at time. But once you learn one it defenitly helps you with learning all the related ones.

    11. #136
      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 ninja9578 View Post
      I find that's true only if it's in the same paradigm. Knowing a procedural language it hard to go into a OOP language, and an assembly language is really weird.
      I don't know about that. I first learned "programming" in PHP (which I reckon as a procedural language), which in turn helped me when I learned javascript (which is object oriented).
      April Ryan is my friend,
      Every sorrow she can mend.
      When i visit her dark realm,
      Does it simply overwhelm.

    12. #137
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Just js is a very very simple object oriented language. java and C++ are insanely complex and powerful.

      khh, you are refering to scripting languages, I've written 5 of them myself for various reasons. Yeah, those can be weird sometimes.

    13. #138
      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 ninja9578 View Post
      Just js is a very very simple object oriented language. java and C++ are insanely complex and powerful.
      Yeah, I know but the stuff you learn is transferable :p

      Quote Originally Posted by ninja9578 View Post
      khh, you are refering to scripting languages, I've written 5 of them myself for various reasons. Yeah, those can be weird sometimes.
      Aye, that's why I wrote "programming" in quotation marks.
      But did you really write 5 complete scripting languages? Why on earth would you need five of them?
      April Ryan is my friend,
      Every sorrow she can mend.
      When i visit her dark realm,
      Does it simply overwhelm.

    14. #139
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      php has had a full object model since v5 (2004)
      http://uk3.php.net/manual/en/oop5.intro.php
      (\_ _/)
      (='.'=)
      (")_(")

    15. #140
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Gemini BASIC - A very simple calculator BASIC language for a GUI that I wrote for a Dev Engine
      Cardinal BASIC - A more advanced BASIC language for Gemini's replacement
      Inspiration Script - A scripting language for a game engine that I never released
      Mini MIPS - For a class in college, based on MIPS Assembly
      LiveScript - Scripting language for my company's engines, I also now use it for personal project

      Quote Originally Posted by Ynot View Post
      php has had a full object model since v5 (2004)
      http://uk3.php.net/manual/en/oop5.intro.php
      It's still very primitive when compared to java or C++.

    16. #141
      FBI agent Ynot's Avatar
      Join Date
      Oct 2005
      Gender
      Location
      Southend, Essex
      Posts
      4,337
      Likes
      14
      Quote Originally Posted by ninja9578 View Post
      It's still very primitive when compared to java or C++.
      Oh absolutely,
      I'm just saying though

      (plus OOP somehow seems wrong with web development - I don't know it just doesn't feel right somehow)
      (\_ _/)
      (='.'=)
      (")_(")

    17. #142
      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 Ynot View Post
      (plus OOP somehow seems wrong with web development - I don't know it just doesn't feel right somehow)
      But you can use php as a scripting language on your computer, though, like python or perl or whatever. It's actually surprisingly suited for it.

      Quote Originally Posted by ninja9578 View Post
      Gemini BASIC - A very simple calculator BASIC language for a GUI that I wrote for a Dev Engine
      Cardinal BASIC - A more advanced BASIC language for Gemini's replacement
      Inspiration Script - A scripting language for a game engine that I never released
      Mini MIPS - For a class in college, based on MIPS Assembly
      LiveScript - Scripting language for my company's engines, I also now use it for personal project
      Why so many BASIC languages? And why did you have to invent your own language each time? For some of the projects, like the game engine, wouldn't it be better to just implement LUA or something?
      April Ryan is my friend,
      Every sorrow she can mend.
      When i visit her dark realm,
      Does it simply overwhelm.

    18. #143
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Quote Originally Posted by Ynot View Post
      Oh absolutely,
      I'm just saying though

      (plus OOP somehow seems wrong with web development - I don't know it just doesn't feel right somehow)
      Not really, the DOM is object based

      Quote Originally Posted by khh View Post
      But you can use php as a scripting language on your computer, though, like python or perl or whatever. It's actually surprisingly suited for it.


      Why so many BASIC languages? And why did you have to invent your own language each time? For some of the projects, like the game engine, wouldn't it be better to just implement LUA or something?
      Because the first two were a long time ago when I didn't have understanding of how compilers worked.

      And LiveScript is designed for graphic designers to understand, so it has to be simple and not be too "programming languagy," which python and perl are.

    19. #144
      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
      Does all this shit become more clear when taught by someone in university?

      I fucking hope so... or else I applied to the wrong dam course.

    20. #145
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      It depends on the teacher. Some of the teachers learned C++ 15 years ago and never bothered learning the new stuff.

      And yes, when you're immersed in it, it will make much more sense. C++ is a weird language compared to some of the other ones.

    21. #146
      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
      Oh cool. I certainly hope it will make more sense (if I get accepted), the course looks extremely good. (Includes other things too)

    22. #147
      Member
      Join Date
      Feb 2004
      Posts
      5,165
      Likes
      709
      The more advanced a programming language is, the easy it is to program with it. Basically, the makers of the program already did a lot of the work for you.

      However advanced programs with a lot of prebuilt commands in it, has more data that has to be read. If your not actually using all the prebuilt commands and stuff, there is wasted code, and thus the final program will run slower than if the commands weren't there.

      The reason there are so many languages, is because people have difference needs. Normally its based around time. Either the time it takes to code, or how fast it will run.

      If you were making a basic calculator, then speed probably isn't an issue. You would use a language with all the math commands built in already, because its silly to reinvent that code. In this case, your personal time is more valuable.

      If however, you are making a really advanced game, or doing the kind of math that involves solving for pi out to a billion numbers, then you want the program to run as fast as possible.

    23. #148
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Not true. -s strips unused code, so unused parts of libraries are pulled out.

    24. #149
      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 ninja9578 View Post
      Not true. -s strips unused code, so unused parts of libraries are pulled out.
      I thought that was standard behaviour even without specifying a special parameter?
      April Ryan is my friend,
      Every sorrow she can mend.
      When i visit her dark realm,
      Does it simply overwhelm.

    25. #150
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      Some of it is, but not all of it. Here's why. Libraries can be loaded dynamically, meaning outside programs and libraries might use functions within it, even if nothing does internally. These can't be stripped out.

    Page 6 of 7 FirstFirst ... 4 5 6 7 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
    •