Page 3 of 25 FirstFirst 123456713 ... LastLast
Results 21 to 30 of 248

Thread: The LaserBoy Thread

  1. #21
    Join Date
    Mar 2012
    Location
    Akron, Ohio USA
    Posts
    1,345

    Default

    There is mouse support in libSDL. But it doesn't tell you anything but button events and X Y coordinates.

    There are some really nice GUI environments out there that will compile in any OS as well.

    I would have to completely rip LB apart from the guts up to use one.

    LB makes a whole bitmap with everything you see inside of that window, every time you tap a key.

    Tap the F3 key some time and look in the same folder as the LaserBoy executable.

    The only thing libSDL gives me is the address of the first pixel of the window and what key just got hit.

    Everything else is in my code. That's why it is so generic and compiles in so many environments.

    I manage the entire display memory in my own bitmap class. I would have to give that over to a GUI API.

    Why not get a cheapo keyboard just for LaserBoy?

    That would be your total cash investment in the application!

    Plus you'd have something to smash and throw across the room.

    James.
    Creator of LaserBoy!
    LaserBoy is free and runs in Windows, MacOSX and Linux.
    http://laserboy.org/code/LaserBoy_Current.zip
    http://theamerikans.org/LaserBoy

    http://laserboy.org/formatt/
    Ask me about my LaserBoy Correction Amp Kit for sale!

    Either do or do not do. There is no undo!

  2. #22
    Join Date
    Dec 2010
    Location
    DC/VA metro area, USA
    Posts
    554

    Default

    Quote Originally Posted by BlueFang View Post
    Welcome to the age old religious war between C++ and Java. Well, it's not so much of a war anymore, but definitely operator overloading is one of the "features" of C++ that are frowned upon by many developers. I am pretty much agnostic with respect to this feature of C++, however as you rightfully point out, it can be the cause for lots of confusion and misuse.
    Could have quoted James or BlueFang on this one, but just picked one that was handy. Overloading confusion like Jame's pipe operator example isn't a language problem... it's a design problem. C and C++ give us lots of rope to build elegant, highly maintainable solutions. If we use the same rope to construct a semantically impenetrable fog of confusion by making things counter-intuitive to 99% of the educated programming community, well, that's a reflection of the designer, not the language.

    I do a lot of Java and C++ coding. You want something to gnash your teeth about? How about Java's lack of an unsigned datatype and the fact that it WILL NOT parse 0x80000000 or higher as an Integer without lots of ridiculous gymnastics. This is not an issue if you're isolated in the Java world, but as soon as you try to exchange some kinds of data with C/C++ programs that produce or consume human-readable files... BAM!

  3. #23
    Join Date
    Mar 2012
    Location
    Akron, Ohio USA
    Posts
    1,345

    Default

    Eeeeiiiiiwww!

    No unsigned integers!

    I would hate that.

    I also don't like the idea that I cannot write any code unless it is encapsulated in an object.

    Nor do I like the idea of having no choice but to use exception handling.

    Overloaded operators are always in use in C++ anyway!

    cout << "text" << endl;

    cin >> data;

    That's an overload of the bit shift operators!

    It's actually many overloads of the same operator because it's type specific.

    In LB I also overloaded the comparison operators of > < >= <= == and != where ever I felt they applied.

    If you overload > and == on a class and make an SDL <vector> of that class, you can use the built-in sort function on the vector.

    James.
    Last edited by james; 12-10-2014 at 16:17.
    Creator of LaserBoy!
    LaserBoy is free and runs in Windows, MacOSX and Linux.
    http://laserboy.org/code/LaserBoy_Current.zip
    http://theamerikans.org/LaserBoy

    http://laserboy.org/formatt/
    Ask me about my LaserBoy Correction Amp Kit for sale!

    Either do or do not do. There is no undo!

  4. #24
    Join Date
    Mar 2012
    Location
    Akron, Ohio USA
    Posts
    1,345

    Default

    The worst code mangling one can do in C++ is macro functions that rely on stringification in the preprocessor.

    If you really want to write code that no one else can modify, that's how you do it!

    James.
    Creator of LaserBoy!
    LaserBoy is free and runs in Windows, MacOSX and Linux.
    http://laserboy.org/code/LaserBoy_Current.zip
    http://theamerikans.org/LaserBoy

    http://laserboy.org/formatt/
    Ask me about my LaserBoy Correction Amp Kit for sale!

    Either do or do not do. There is no undo!

  5. #25
    Join Date
    Dec 2010
    Location
    DC/VA metro area, USA
    Posts
    554

    Default

    Don't get me wrong, there's plenty of excellent uses for overloading, and operator overloading. But if someone overloads ++ to subtract 5 from the value of something, that someone will not earn any respect or make any friends when someone has to maintain his code!

    You'd get over the "everything's an object" pretty quick. It's not really a limitation. Same with exception handling. Exceptions occur; if you don't write any exception handling your app will die a grisly death just like it does in C++. Unlike C++, you'll usually be told where and why though, even if you don't want to know.

  6. #26
    Join Date
    Mar 2012
    Location
    Akron, Ohio USA
    Posts
    1,345

    Default

    I try to keep it real in my code. I have to read it too you know!

    Some of the bitmap and wave stuff in LB goes back to the late 90s!

    I have to be able to make sense of it all.

    If I see something I wrote some time ago and I don't quite get it right away, I usually add a comment.

    I also try to use very good text indentation so that things line up both horizontally and vertically for clarity.

    It's amazing how this can make a single keystroke that is out of place stick out.

    LaserBoy is all art to me. I even want to make the code a thing of beauty.

    That's for real.

    James,
    Last edited by james; 12-11-2014 at 11:00.
    Creator of LaserBoy!
    LaserBoy is free and runs in Windows, MacOSX and Linux.
    http://laserboy.org/code/LaserBoy_Current.zip
    http://theamerikans.org/LaserBoy

    http://laserboy.org/formatt/
    Ask me about my LaserBoy Correction Amp Kit for sale!

    Either do or do not do. There is no undo!

  7. #27
    Join Date
    Mar 2012
    Location
    Akron, Ohio USA
    Posts
    1,345

    Default

    As far as exception handling goes. I kinda' get why it exists. But I always stay away from it because there are other ways to hadel run-time errors.

    I have had to use them as a professional programmer, because the application I was writing an interface for used them.

    Overall, I think they break the structured nature of C++. It's right up there with using goto statements with labels.

    Yuk.

    James.
    Creator of LaserBoy!
    LaserBoy is free and runs in Windows, MacOSX and Linux.
    http://laserboy.org/code/LaserBoy_Current.zip
    http://theamerikans.org/LaserBoy

    http://laserboy.org/formatt/
    Ask me about my LaserBoy Correction Amp Kit for sale!

    Either do or do not do. There is no undo!

  8. #28
    Join Date
    Mar 2010
    Location
    Raleigh, NC
    Posts
    2,063

    Default

    Quote Originally Posted by james View Post
    As far as exception handling goes. I kinda' get why it exists. But I always stay away from it because there are other ways to hadel run-time errors.

    I have had to use them as a professional programmer, because the application I was writing an interface for used them.

    Overall, I think they break the structured nature of C++. It's right up there with using goto statements with labels.

    Yuk.

    James.
    Exceptions are awesome if used correctly. They let you bubble up error information from deep within to the surface where they can be handled at that level. For example, if there is an error accessing a file somewhere in some long function chain, it can throw an exception and it can be handled several layers up and show a message. When an exception is thrown code clean up automatically happens if things are written correctly. Bjarne would be sad that you don't like them.

  9. #29
    Join Date
    Mar 2012
    Location
    Akron, Ohio USA
    Posts
    1,345

    Default

    Bjarne, Ha!

    I'm dealing with exactly that right now.

    I'm re-writing the code that reads LaserBoy Formatted Text files.

    I have several layers of objects doing the job.

    GUI -> space -> frame set -> frame -> vertex...
    GUI -> space -> palette set -> palette -> color...

    I just write the txt read functions at every level to set an error flag in an unsigned 32 bit int as either part of the class, the return type or both. Then I know what happened at the highest level (GUI) after I call the text read at that level.

    There are only so many things that can go wrong.

    It does't handle a meteor strike for example.

    James.
    Creator of LaserBoy!
    LaserBoy is free and runs in Windows, MacOSX and Linux.
    http://laserboy.org/code/LaserBoy_Current.zip
    http://theamerikans.org/LaserBoy

    http://laserboy.org/formatt/
    Ask me about my LaserBoy Correction Amp Kit for sale!

    Either do or do not do. There is no undo!

  10. #30
    Join Date
    Dec 2010
    Location
    DC/VA metro area, USA
    Posts
    554

    Default

    So James, I'm curious... hopefully you have something to handle an out-of-memory condition (std::bad_alloc). Do you repeat or explicitly link to this handler code in every place you allocate memory? Or do you define an out-of-memory exception handler at a high level and recover gracefully? If I'm working on a file, and I begin some operation which can't be completed successfully due to some exception or other, I want the app to abort that operation and return to its previous state, not suddenly exit to the command prompt with some untold amount of unsaved work.

    Structured exception handling has its purposes and its place. For that matter so does goto. :-) If you work in assembly (or disassembly!)... it's all goto, all the time.

Posting Permissions

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