Jump to content
  • Advertisement


GDNet+ Basic
  • Content count

  • Joined

  • Last visited

Community Reputation

4544 Excellent

About Aldacron

  • Rank

Personal Information

Recent Profile Visitors

27875 profile views
  1. Aldacron

    Is Sublime Text a valid option for C++ development?

    I use Sublime Text for most of my programming (C, C++ and D). I use Premake to manage the builds. I generally develop on Windows with MinGW and keep an MSYS 2 window open in the background. You can can configure Sublime to build from short-cut keys in the editor, but my fingers are so used to `alt-tab` followed by the up arrow once or twice for the command I want (to generate a new makefile if I've added any new source modules, otherwise to build & run the program) that it's second nature to me now. That, and I don't like how the output looks inside Sublime when building from within it. Now and again, I'll generate a Visual Studio project to make sure it all still builds there. So yes, it's a perfectly fine option for C and C++ programming if you don't mind working with the command line. I also like VS Code, especially its built-in terminal (`ctrl-~` to open/close). I would probably prefer it if it were as snappy as Sublime, now that there's little separating them feature-wise. And the fact that I actually paid for Sublime 2 and upgraded to 3 makes me feel somewhat compelled to put it to use :-)
  2. Love the idea of sending feedback in the game world. To keep your inbox free of spam, then instead of sending an email directly to your inbox, you could set up a server for it and send it in any format you'd like. Then it could be stashed in a database, viewed on a web page, exported to a spreadsheet, filtered for keywords, or whatever. Anyway, enjoyed the post.
  3. I doubt the error message is coming from SDL_QueryTexture (it shouldn't be attempting to load any DLLs). I see two problems with your code that you need to correct before reaching that conclusion. First, you aren't checking the return value of the function call. The function is documented to return zero on success and a negative error code on failure. Second, based on your usage of w and h in textRender, it seems you've declared both as pointers. This is likely the source of your segfault. SDL_QueryTexture does not store pointers to ints in the width and height parameters. It stores the actual values of the width and height. That means you have to pass it the addresses of actual int variables, not uninitialized int pointers. In other words: // This is certain to cause a segault int *w, *h; SDL_QueryTexture(tex, NULL, NULL, w, h); The correct way to do this is like so: int w = 0, h = 0; if(SDL_QueryTexture(tex, NULL, NULL, &w, &h) < 0) { fprintf(stderr, "Error on texture query: %s", SDL_GetError()); }
  4. Aldacron

    Try Catch Statement Question [2]

    No, that's not quite right. You can throw an exception from inside any class method, but the object you throw has to be in the java.lang.Throwable hierarchy. For instance, you can't, for example, do "throw new Integer(1)" because the class Integer is not a subclass of Throwable. The compiler sometimes inserts instructions into the generated byte code that check certain operations and throw exceptions if you've done something the language spec says you aren't supposed to. For example, accessing a null class reference will cause a NullPointerException to be thrown, or you get an ArrayOutOfBoundsException if you try to access an array with an invalid index. ArithmeticExceptions are thrown when you do something like divide by zero, or some other invalid operation. Conceptually, it's no different than if you were doing the check yourself, perhaps something like this: int divideInts(int lhs, int rhs) { if(rhs == 0) { throw new ArithmeticException("Divide by zero!"); } return lhs / rhs; } Except the compiler inserts the check for you. This is not "throw" but "throws". It's called an Exception Specification and tells both the compiler and the programmer which exceptions a function might possibly throw. Your Java book should have told you that there are two types of exceptions in Java: checked exceptions and runtime exceptions. Any checked exceptions a method might throw must be specified in an exception specification in the method signature. Any methods calling that method must either catch and handle those exceptions, or also include an exception specification. Runtime exceptions are exempt from these rules. They may still be caught, but they are not required to be and they are never included in exception specifications. NullPointerException and ArithmeticException are examples of runtime exceptions (as is any exception type that extends java.lang.RuntimeException). If you have a method that includes a "new ServerSocket", then you need to either wrap that up in a try..catch and handle any IOException that is thrown or add a "throws IOException" specification to your method signature, since IOException is a checked exception. Any other checked exceptions your method might throw, either because you choose to throw them or because you call a method that throws them and you don't catch them, will also need to be added to the specification. I don't know which book you're reading, but I feel I should recommend Core Java by Clay Horstmann. He goes into a lot of detail and covers a number of corner cases that most books don't. He explains exception handling particularly well.
  5. Aldacron

    Try Catch Statement Question [2]

    This is the kind of thing you can figure out in two minutes. Knock up a simple test program like this one: class Foo { public static void main(String[] args) { try { throwIfLessThan(5, 10); System.out.println("After function call"); } catch(Exception e) { e.printStackTrace(); } System.out.println("Outside the catch block!"); } static int throwIfLessThan(int i, int n) throws Exception { if(i < n) { throw new Exception("i is less than n!"); } return i + n; } } Then javac Foo.java followed by java Foo should answer your question. Spoiler alert: The first println is never executed if the exception is thrown. Yes. For one, it gives you the freedom to move the error handling from the lowest level call site to the most appropriate place for it to be handled, without worrying that error codes are checked appropriately all along the chain. For another, it provides a mechanism for resources to be automatically cleaned up regardless of whether or not the exception is thrown (in Java, via the AutoClosable interface, in C++, by ensuring destructors are called as the stack unwinds).
  6. Aldacron

    SDL 2: Implementing Sprite Clips

    I strongly recommend you pick up a copy of Understanding and Using C Pointers. It covers a lot of ground, even some that intermediate C and C++ programmers might be ignorant of. If you grok the material in that book, you'll be much more able to recognize any self-inflicted pointer-related bugs (and they almost always are self-inflicted) when they pop up.
  7. Aldacron

    GameDev.net Turns 18!

    Somehow this makes me feel much older than I am. But happy birthday!
  8. Aldacron

    OpenGL 2D RPG examples/source code

    In the "In Practice" section at learnopengl.com, you'll find a tutorial for a 2D Breakout game.
  9. You're already doing that anyway, so how does using Kyronet mean you can't continue? You can use Kyronet or any other networking library to implement the server and then use any language + library combination you want to implement the client. All the client has to do is open a single socket, connect to the server, and start parsing packets. It need neither know nor care how the server is implemented.  
  10. Aldacron

    How to use namespaces in structuring a project

    In my experience, there are generally three camps on this. One says that namespaces should never be used as an architectural device, but solely to disambiguate symbols and avoid collisions. Another says that the namespace is a great tool for creating a modular hierarchy. Those in the third camp take no position either way and do just whatever feels right at the time.   So the advice I give to you is: do whatever you'd like. Companies that use C++ will have in-house coding guidelines that will (or should) specify how they want you to use namespaces. On your own time, as there's no One True Way here, you can do as you please. If that means not using namespaces at all, that's fine, too. Though, I do advise that if you're considering releasing a library for general consumption and the user experience is important to you, then you should first take a look at existing popular libraries in that domain to see what they do.
  11. Aldacron

    In-Game GUI Libraries for C?

    I don't touch the OMF stuff anymore. With DMD, it's all -m64 for me now. That's what prompted me to add support to some of the Derelict packages to be used as static bindings -- it's feasible now without the OMF/COFF headache. Unfortunately, until DUB supports -m32mscoff fully, it's still an annoyance for 32-bit.
  12. Aldacron

    In-Game GUI Libraries for C?

    There are some static and dynamic D bindings for Nuklear already, so you can jump right in. 
  13. Aldacron

    Isometric RPG devlog #2

    I always liked the gridless inventories. What's the issue about stacking items? It can still done automatically when items are added to the inventory, but it can also be done manually through drag and drop. I never had a problem with it in Ultima Online.
  14. Platforms are incidental. Your primary goal should be focusing on the underlying fundamentals of game development. In the beginning, it's difficult to separate one from the other, since it's all new, but once you get the fundamentals down you can put them into effect on any platform you want. Since you are already familiar with Java, you might as well just keep with it while you learn what you need to know about game development. libGDX is fine for that. So is JavaFX, or even Swing.   If you can fork out a little bit of money, 'Mastering LibGDX Game Development', despite the 'Mastering' in the title, gets the best reviews of any book I've seen on getting started with LibGDX (and it's fairly recent). It expects the reader to already be comfortable with Java, so if you're good on that score it should be money well spent. 'Beginning Java 8 Games Development' is also a decent introduction to 2D game programming with JavaFX. If you can afford it, I would recommend you get both. It will help you in mentally separating the platform from the game concepts.
  15. Aldacron

    ASCII C++ Graphics Library

    You might try libtcod.
  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!