Recent posts by EndlessSporadic on Kongregate

Flag Post

Topic: Game Programming / Trying to understand avoiding memory leak

That, and you don’t necessarily want to rely on the garbage collector unless you have to (pool your objects when you can)

I was going under the assumption that all the OP cared about was ensuring 0 leaked bytes, not how it would affect performance. But yes, garbage collection is EXTREMELY slow in every language, so you want to avoid both null pointers and having the GC run in the first place. Pools are one of the greatest ways to avoid garbage collection and memory leaks while improving the overall speed of your application.

Flag Post

Topic: Game Programming / Trying to understand avoiding memory leak

In almost all high level languages except C/C++ garbage collection is done for you. If your language of choice does not allow you to access memory directly you are safe.

Using your example, if you have a class called fighterData and pass an object as an argument to the constructor, one of two things will happen depending on whether the object is a value type or a reference type. If it is a value type, a copy of the object will be passed to fighterData and that “clone” object will delete itself at the end of the constructor method. If the object is a reference type a pointer to the object will be passed. This object is not deleted at the end of the constructor method (the pointer reference will be deleted), but instead will delete itself when the object no longer has a reference pointer to it. When it comes to the C-based languages the only language you need to worry about the latter for is C++.

Nowadays it is pretty difficult to unintentionally cause a memory leak unless you are dealing with IO (once again, except for C++ where you need to delete your own data).

Flag Post

Topic: Game Programming / Vector Images

yes, you CAN convert bitmaps to vector…. however, you don’t want to do this. they will look worse after the conversion

Which is why I said you can’t. As a basis of math, you can approximate a line by giving points, but you can get exact points by providing a line. As momoguru said, there are programs that will approximate it for you, but the results are rarely what you intended and are rarely professional quality.

Flag Post

Topic: Game Programming / Vector Images

tl;dr – there is no way to turn pixel art into vector art.

The point of hand-drawn vector art is that it can be resized before being saved as a pixel image. Only programs like Flash allow you to use vector images directly in the program. Vector images are made with math – you rasterize math, but you can’t derasterize pixels.

The way things are rendered in a 3D game engine is by using what is called a material. Ignoring things like absolute world coordinates, panners, and rotators, the texture is applied to the material through UV mapping and the material is then applied to the model.

If you find that your images are getting scaled down poorly you will need to redo your image or shrink it down in an application that has good sampling for such a thing (photoshop’s downscaling sampling method is pretty damn good [bicubic sharper]).

Unity hate incoming – Unity shaders suck and handle textures extremely poorly.

Flag Post

Topic: Game Programming / [LAG] 10 Enemies Collisions with 33 Blocks

Color me confused. From a C, object oriented perspective it would seem like all of the stuff you guys are doing is really over-complicated. It seems like the best way to do this would be event driven. Store all of your tiles (per room) in a 1D array, and whenever there is movement get the position of the tile you are entering (which should be stored in the object that is moving). Go to that location in the array (O(1) operation) and check bIsSolid.

There is no need to iterate over all blocks all the time in a 2D grid game.

Flag Post

Topic: Off-topic / Do you think New Cartoons are better than Old Cartoons overall?

Hell no. Modern cartoons can’t hold a candle up to Courage and Samurai Jack. God forbid we show any real violence or any semblance of complex thought. The best cartoon among the garbage these days is probably Adventure Time since they actually attempt to tackle some complex subject matter.

Flag Post

Topic: Game Programming / Multiplayer !

And when you’re done, make a tutorial :P

Absolutely nothing makes you learn faster than writing a tutorial on the thing you are learning yourself. While writing it you will be forced to fact check and look up whether what you are doing is actually correct. You’ll need to look up samples or think of your own.

Another good thing to do is to write a simple program, go learn some new stuff, then rewrite your program from scratch while implementing the newly learned content (where applicable). This is where I learned about performance benefits of classes and structs in C# as well as the benefits of bitwise operations.

Flag Post

Topic: Game Programming / Java Multiplayer RPG.

Originally posted by Draco18s:

Kongregate, absolutely positively, does not support Java applets out of the box.

It supports iFrame HTML, Flash, and Unity. You could probably get a Java applet to work via iFrame, but you would have to play around with it.

In response to this, it is possible to have your applet work through an iFrame. Runescape is on this website and it uses an iFrame.

Flag Post

Topic: Game Programming / Kongregate Not Replying to Emails?

How long ago did you send it? It can take up to 2 weeks depending on the volume with a minimum expected response time of 48 business hours.

Flag Post

Topic: Game Programming / How to make a 3D game without C++ (HTML, no WebGL)

The OP in this thread reminds me of my <10 year old niece. She wants something, we tell her precisely why she can’t have it, then she begins to whine and keeps begging for it and asking why she can’t have it even though we explained why she can’t have it.

OP, I can’t tell whether you are trolling or not, but if you are not trolling I will say that you are acting like a child. There is a reason why things are the way they are. This may sound untrue with the whole Ubisoft fiasco, but developers actually know the limits of the hardware they are developing for. People are trained for years, learning how to optimize and improve. While what you envision may provide graphical fidelity in your head it won’t in reality simply because the memory requirements are way too high. Moving around will also require the image be scaled which causes horrible artifacts and breaks the realism you are trying to achieve.

Have you ever heard of mipmapping? Clearly not, but mip-mapping is a better, and more realistic, version what you are arguing for. It is already a thing, and it takes up buttloads of memory.

Flag Post

Topic: Game Programming / Web development - processing on server

It depends on the type of processing you want to do on the image. For simple uploading and very basic image processing you can (and should) use PHP. For more complex stuff you will need to use C# (windows hosting) or Java (Linux hosting).

Flag Post

Topic: Off-topic / Anime Addicts Anonymous (AAA)

Originally posted by sddsdd:

Just started watching Soul Eater. It’s a fun show, but its comedy feels really off for some reason.

Has anyone watched SKET Dance? If so, what did you think of it?

I’ve heard that SKET is almost exactly the same as Gintama.

Flag Post

Topic: Game Programming / Game Idea

There are only 3 things in game programming – arithmetic, comparisons, and storage (there are 4, but 1 is the low level stuff you don’t need to worry about at this stage if you don’t even know the other three). All functions that are “DoSomething” fundamentally break down into these three categories.


Value = Value + Value2
Value = 1/Value – Value2


if (x < y)
if (x == y)
if (!x)


x = y

Classes and objects can be thought of as storage units. Operations are a combination of comparisons and arithmetic. If x is true, do some arithmetic, else do some other arithmetic. When it comes to collision detection, you have 2 colliders (storage). Think of these colliders as 2D boxes. Are these colliders overlapping (comparison)? I’ll give you some code. I expect you to understand what everything means by the end and I hope you go back to that C++ book and actually learn what is in it.

class Collider {
    int X; //the x coordinate, top left
    int Y; //the y coordinate, top left
    int Width; //the width
    int Height; //the height

    //This makes a box. Do you see why? With these four variables you know where infinite points are in the box.

class SomeClass {
    bool isCollision(PlayerCollider, OtherCollider) {
       //Get the rightmost X
       int x1 = Math.Max(PlayerCollider.X, OtherCollider.X);
       //Get the leftmost X
       int x2 = Math.Min(PlayerCollider.X + PlayerCollider.Width, OtherCollider.X + OtherCollider.Width);
       //Get the top bottom-most Y
       int y1 = Math.Max(PlayerCollider.Y, OtherCollider.Y);
       //Get the bottom top-most Y
       int y2 = Math.Min(PlayerCollider.Y + PlayerCollider.Height, OtherCollider.Y + OtherCollider.Height);
       //What we have done above is create a new rectangle that covers the entire intersection area.

       //Checking if this rectangle occupies a positive space.
       if (x2 >= x1 && y2 >= y1) {
           return true;
       return false;

Assume we are creating a new box that covers the collision area.

x1 gets the left x coordinate.
x2 gets the right x coordinate.
y1 gets the top y coordinate.
y2 gets the bottom y coordinate.

If the right X coordinate is greater than the left X coordinate &&
If the bottom Y coordinate is greater than top Y coordinate, this creates a box with positive area.

Take a look at the image below that demonstrates why this works.

The following image shifts the green block over 6 places to the right. This one has no collision. Why? While the Y creates a positive area space, the X coordinates create a negative space, meaning there is no collision.

Flag Post

Topic: Game Programming / Best Way to format numbers? (show in thousands, millions, etc.)

Originally posted by player_03:
Originally posted by Aesica:

Edit: Isn’t it considered bad practice to have multiple return statements in the same function?

Depends who you ask. In my opinion, no.

I go with no as well. Sometimes it is the only way to do things. I utilize multiple return statements quite often, actually. Let’s take a look at a simple function (C++ syntax).

//Static interface for player DoSomething()
bool StaticLibrary::DoSomething(Player* player)
    //Check for null pointer
    if (!player)
        return false;

    return player->DoSomething();

You will often need to return early if you are trying to iterate over something. Take a look at this example.

Player* StaticLibrary::FindPlayerWithTag(String tag)
    for (Player* player : PlayerList)
        if (!player)
        if (player->Tag == tag)
            return player;

    return nullptr;

As for the switch vs if-else, it all depends. Some compilers can optimize switch statements by putting them into a jump table or indexing pointers, whereas there is rarely optimization done for if-else statements. With this said, sometimes these switch statement optimizations will actually cause it to run significantly worse than if you had used an if-else.

Switch and if-else optimization is something that is so low level that I can almost say with 100% confidence that it won’t be your job to worry about that. If you ever get into a large dev team chances are there will be someone there whose job it is to optimize this kind of thing for you. I tend to use switch for comparables (comparing strings, enums, or flags) and if-else for numeric comparisons. Note that this doesn’t mean it is the right way to go about it, but it is certainly the most readable.

Flag Post

Topic: Game Programming / New to Game Development

When it comes to design there is no such thing as outdated. When it comes to actual application the only way to learn is to figure it out for yourself and do your own research. Not only will you be a better developer for it, you will prove to the rest of us that you are serious about developing games.

Start by figuring out what kind of games you want to make and what platforms you want to target. Pick an engine and read up on basic object-oriented programming (OOP) concepts.

Flag Post

Topic: Game Programming / Best game engine!

Drag and drop isn’t always a bad thing, though I do have thoughts on that topic which I don’t feel the need to express due to irrelevance.

I believe Drakim’s post went ahead and stated my thoughts.

The reason I don’t think it is a bad thing is that if you aren’t aiming to be a programmer it doesn’t matter. Flowgraph (CryEngine) or Blueprints (Unreal) are great and necessary for level designers and content creators. It allows them to hook up their stuff without having to waste their time on something they have no business doing. Programming should be strictly restricted to programmers. It is the programmer’s job to make the core systems and create interfaces that allow the other departments to use the tools they have created. It does not matter what these interfaces take the form of as long as it lets the other departments do what they need to do in a way that doesn’t bottleneck the rest of the system.

When it comes to indie development or, a step below that, Game Maker development, there is usually only one person working on it. They can drag and drop stuff, sure, but the underlying foundation is not completely there for the creator to make what they want – if that person wants to do something that isn’t supported by Game Maker they are royally screwed. The counter argument is that they could add it in manually, but if they knew how to program they wouldn’t need to use Game Maker.

As Drakim said, drag and drop, when used by a single person to make the core systems of their game, is a very bad practice and can’t be called real game development.

Flag Post

Topic: Game Programming / 3D model search engine

Very cool, though I am disappointed by the lack of texturing.

Flag Post

Topic: Game Programming / Best game engine!

it’s always going to be tainted as that “Drag and drop tool used to make video game”

Unreal Engine 4’s blueprint system is also essentially drag and drop. Drag and drop isn’t always a bad thing, though I do have thoughts on that topic which I don’t feel the need to express due to irrelevance.

Game Maker, as Pugzy clarified, is great for quick prototyping and simple 2D games. Ultimately that is all it is good for. Many devs who take themselves seriously will want to expand into unknown territory and see their ideas come to life. Game Maker just doesn’t have the framework to support this kind of thing. Game engines are trees, setting the foundation to let your ideas grow. Your game is a branch, utilizing the tree while expanding into the sky. Game Maker is a cactus. It has a core and tiny needles that reach out but don’t quite get anywhere. It may have a limb or two, but they do not touch the sky.

To clarify that metaphor, Game Maker is a tool that is only decent in one or two places and doesn’t leave much room to expand and grow. There is nothing wrong with specialized engines (cacti), but that engine is meaningless if there are versatile engines (trees) that can do the same thing better.

Flag Post

Topic: Game Programming / Need a unity fullscreen script

Google is your friend. So is the Unity Documentation.

Flag Post

Topic: Game Programming / How to make a game


Flag Post

Topic: Game Programming / Max width over 800px?

They may receive special permission. Cases outside the norms are handled on a case by case basis, so you may need to email support once your game is uploaded to have them change the accepted width. This goes double for game file size.

Flag Post

Topic: Off-topic / Ebola hypothetical question.

I’m prepared to die, but I’m not going to purposely go out just to get laid.

Flag Post

Topic: Game Programming / What's with all the hate on Unity?

Originally posted by Draco18s:
Originally posted by StallionGriefs:

I hate on Unity because it has far too many limitations, even in Unity Pro.

Just FYI, this is like saying that you hate Flash 2004 because it has too many limitations.
Seriously. Unity is a young platform.

Yet they are selling it for 77x what their competitors are selling their engines for. It’s not even the fact that nothing is implemented – it is the fact that they actually hide the functionality from us. For example, they hide almost all of the FMOD functionality. I will respond to your analogy with another – it is not OK to sell an early access game for $300.

Flag Post

Topic: Off-topic / All these newfigs...

I see nothing has changed since I left. You’d think after 4 years all of the two year olds here would have started acting like 6 year olds. I was wrong.

Flag Post

Topic: Game Programming / i need help in c++

Also of note is that if you do “>”, you want to start with the higher number first. Likewise, if you do “<”, you want to start with the lower number first.

if (a>90)
else if (a > 20)