Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 16 Jul 2004
Online Last Active Today, 03:16 PM

#5135455 Unmaintainable code

Posted by on 28 February 2014 - 02:24 PM

I also thought for sure that this was generated code...

#5125356 Is HTML5 a legit language for developing game?

Posted by on 21 January 2014 - 08:52 AM

Overall my experience using HTM5 has been positive. That being said, the issues I have experienced are due to the Canvas not cooperating with what I want it to do (for example, no way to disable min/mag filter when scaling images), JavaScript performance which is overall quite good on the desktop, but varies wildly on mobile as you could imagine. And also the difficulty in managing a large codebase in a dynamic language.

#5100823 BASIC

Posted by on 12 October 2013 - 11:02 AM

Any instructor who says "NEVER" use GOTO  may never have done much serious programming  (where they are very useful for abnormal exiting of complex subroutines,  and the horrors of number goto labels are long gone)

I've been programming for 20 years, professionally for 12, and I can say this is the first time in probably about six years that I've typed the four letter sequence "g o t o". When I did use goto, it was always preceded by "on error", because that's the exception handling idiom in VBScript - "On error goto label". I program at least 40 hours per week.

#5094440 Correctly casting serialised objects

Posted by on 16 September 2013 - 07:31 AM

Too much. You need a factory that can select the appropriate class based on the int type code. This class can instantiate the specific message class using a parameterless constructor. A switch statement is not a terrible way to go when selecting the class to create. Then the payload is given to the message class's deserialize method. That's all.

#5092744 Stick with C++ or venture into C#?

Posted by on 09 September 2013 - 10:17 AM

I would recommend using C# with one warning: Have a plan. If you know ahead of time you know what you're going to do, you'll be able to make the decision to use C++ in those narrow range of circumstances when C# would not be suitable. It sucks to have hundreds of hours into something then realize you're at a dead end.


* C# is inconvenient on your target platform: iOS, Android, Blackberry

* Some third-party library does not support .NET, or some third party tool you want to use produces files in a proprietary format, and the libraries to read the format are not available to C#.

* C# performance, for example, you need very tight control over memory allocations, layout, etc.


You can get around each of these issues if you just have to use C#, and the performance is not likely to be a bottleneck except in the most demanding of games.

#5091711 Why are static variables bad?

Posted by on 04 September 2013 - 11:31 PM


#5091654 Why are static variables bad?

Posted by on 04 September 2013 - 03:58 PM

Personally I like to make objects that can always be default constructed and design paramaters as simply ways to set specific properties on creation. I'm not really a fan of objects that do complicated behavior just by being created.


Just because you are passing dependencies to the constructor does not mean that the constructor is doing anything more than storing a reference to those dependencies. It doesn't have to use them or access them in any way.




The problem with that is you're assuming it is an object that is useless without its full set of data and useful with it. Which in reality is not the case most of the time, especially concerning games. A good example might be a game entity, say you wanted to create it and set certain data about it and then add it to a world. Should it ask for a world and add itself in the constructor? Well it could but that means you have to add it to the world the second you create it, it also means you are essentially required to pass all of the information the object needs into the constructor and to also assume it is all correct.


The constructor is not the only place to inject dependencies, it's just a convenient and fail-safe one. Obviously if you need a parameterless constructor, or otherwise need to construct an object before you have a reference to its dependencies, or that dependency is not available within the scope that it is being constructed, then you'll have to use another means. Personally, in the case of game objects, I typically require the "world" reference as an argument to any methods that depend on it, likewise for any other dependencies. The parameterless constructor is needed for deserialization and/or constructing entities to add components to via configuration files or using some sort of fluent interface.

#5091452 Why are static variables bad?

Posted by on 03 September 2013 - 06:39 PM


and every constructor will have like 5 arguments


And if you do need to pass in five dependencies to one constructor (which is extremely unlikely if you design your classes properly), you can always wrap them in an instance of a FooContext class.



There's nothing wrong with a constructor having five arguments per se, if that class has five dependencies and/or required parameters. If your class genuinely has five dependencies, passing them to the constructor is better than the alternative of global variables. If your class feels like it has too many dependencies, maybe it really does and needs refactoring. That's going to be a judgement call based on the specific situation.

#5091397 Why are static variables bad?

Posted by on 03 September 2013 - 01:47 PM

Right. Static variables are bad when used incorrectly. Making static variables globally accessible invites the programmer to access that variable at any point in the code without any clear indication from outside that code that there is a dependency on that global variable. This makes it impossible to test or reuse software components as individual units. Incorrectly used global static variables also threaten to wreak havoc all over your codebase whenever you attempt to change the way the variable is used or what it means. The alternative to using global static variables is usually to implement form of dependency injection so that any unit that depends on the variable will have its dependency clearly and explicitly indicated. Often this also has the benefit of compile-time error checking -- if you forget to pass that variable to your constructor or method that depends on it, then it won't compile.


Another potential drawback to using bare statics is that they are not thread safe. Any thread can access and modify the static without any sort of locking.

#5083956 Event Handlers In C

Posted by on 07 August 2013 - 02:52 PM

I would omit the name field for the event listeners. The only reason I can think that you'd want to have names attached to your event callbacks is so that you can identify them later for removal or to ensure that the same callback isn't registered for the same event more than once. Since this is C it's easy enough just to use the callback's address as the identifier. This will save some space in each callback, as well as spare you from having to work with strings (which in C, sucks pretty hard).

#5081689 Taking almost ALL the credit?

Posted by on 30 July 2013 - 07:03 AM

Or you could, instead of listing the actual role, just show each of your names in a font size relative to your contribution to the project. For example:



---- Credits ----

Patrick Chasco

Henchman #1

Henchman #2


Seems fair to me.

#5081687 Oh my glorious code!

Posted by on 30 July 2013 - 06:57 AM

I don't have any code from when I was that age, as around the age of 14 or so, an HDD crash had wiped out everything I had before this point


Same, only my HDD was random girly-pop cassette tapes I "found" somewhere in the vicinity of my sister's tape player...

#5078062 Emo framework for mobile games?

Posted by on 16 July 2013 - 12:17 AM

Dude, you realize that pygame's core is written on c++ right? Same is truth for most part of kivy (some of its classes are still use python).
I hardly see how its performance can be a problem on the logic of the game (it will be an incredible small performance lost if you consider the cost of rendering), and even if it is, use cython to optimize your code and you reach the C speed.
I recomend reading this: http://docs.cython.org/src/quickstart/cythonize.html


Have you written anything using pygame? Pygame is not a game engine where most of the work is coded in high performance C code. There is no "render my scene and call these functions when stuff happens." Pygame does not have a "render_mesh" function. There is no "pathfind_astar" function there for you. There isn't even a "render my 2D scrolling tile map" function. You'll be coding these tight loops in python, and they will be slow because python is slow. On top of that, most of your calls to pygame APIs will need to cross the python to native ABI bridge. Marshaling these calls from python is slow, slow, slow. Each primitive you draw, each OpenGL call, every call to blit a surface will incur significant overhead. Not to mention many mobile devices have as high and in some cases higher screen resolutions than a typical desktop, which introduces even more overhead because you will probably be doing more blitting and drawing of primitives. AND further again, using high resolution images and textures, meaning more memory pressure, meaning ultimately to even more GC stutter.

So, dude. I know all about pygame. I use it. I love it. It's not for anything other than the
simplest of mobile games.

#5077933 Emo framework for mobile games?

Posted by on 15 July 2013 - 01:05 PM

I do NOT intend to use game makers, because they are wrong. You should have to code your game and not have these "Easy Options".


If you are determined to avoid "easy options" on vague emotional notions of them being wrong, then you're going to have a bad time. Game development is hard and time consuming. My gut tells me that unless a developer is willing to cut a corner now and then, or go the easy route, she'll never see a project through to completion. Besides, how easy is too easy? Where's the line drawn? Personally, I don't think you're a real programmer unless you do it all in assembly. All these "programmers" using C or C++ to code are amateurs. I'm talking to you, John Carmack. happy.png


More seriously, I would encourage you to not to immediately discredit "easy options," because no matter how much easier a game maker is to use over straight-up coding, game development is still hard. 


I can't speak to all of the options you've listed above, but I know something about a few of them:


Android SDK - It's only "hard to use" in that it is not a framework designed for game development. It provides access to the hardware and operating system services. Java code running against the SDK will be slower than well written C or C++ code, sometimes significantly. Carefully written Java can be fast on Dalvik (Android's Java VM), but it's not easy to do right. Just like in C or C++ you need to be very aware of how you're allocating memory in Java otherwise you'll have to deal with the garbage collector causing stutters in your framerate. I think this is why many iOS usually feels smoother than Android, but that's just a gut feeling. I have no evidence and don't have the inclination to look for some.


Kivy - Kivy is built on python and I think for anything beyond a simple game you will hit the performance wall.


MonoGame - You do not need to buy Xamarin studio to use MonoGame. MonoGame is free of cost to use. People are having success with MonoGame, but keep in mind you will have some of the same performance issues as you would if using the Android SDK. Mono runs on a virtual machine with a generational garbage collector. If you're not nice to it, it will bite you.


PyGame - Love pygame on the desktop, but, again, I think it would be too slow for anything but simple games. Also not very polished.

#5069427 Procedural Content Generation. Please Help

Posted by on 13 June 2013 - 08:27 AM

That's a pretty good way of doing it. I would recommend also implementing scaling on some of your cookie cutter rooms, that way you can randomly change their sizes. This will make it less obvious that each floor of your dungeon is just a puzzle of the same rooms.


Also I would avoid the "rooms connected by very long hallways" type of random generated content that you see in roguelikes like angband, rogue or nethack, unless it's intentional for a specific section, like a cave or somesuch. No one would ever build a structure this way, so it makes no sense to do it in your game. But that's just a pet peeve of mine.