Jump to content

  • Log In with Google      Sign In   
  • Create Account


Member Since 09 May 2010
Offline Last Active Jul 04 2016 04:32 AM

#5258435 OOP inheritance structure

Posted by on 21 October 2015 - 04:14 PM

I would still like to have a comment on the code I posted.


Then I guess I'm on the right pad by reading Avoiding the Blob since that is pretty much what I am creating, I document and structure it very well but it remains a blob.. Sometimes I am giving some code it's own place but it pretty much stays in the realm that many people call the blob. But the article about avoiding it stretches it far, I mean it has a separate component for health, this might be great for a asteroids clone but is it still common sense for "deeper" games?


Should I be creating a Interfaces / components for each and every stat or does it make more sense to combine it? I would say the latter but I still might be thinking in "blobs". Anyway while soaking up all the information regarding this I am presented with 4 options:


  1. Using Map<K, V> to store various data. This seems the most simplistic but is kinda error prone since I need to provide strings manually.
  2. Using a single interface Entity that holds a ton of things. This really seems wrong to me, yet the article uses it for the Asteroids game.
  3. Using a interface for each functionality. This could mean interface Health that implements the methods regenerate(int amount) and damage(int amount). But I still have to define these methods in the class it belongs too and thus generating a blob again. I could of course have these as normal classes instantiated within my creatures.
  4. A full component system like Unity uses. Where I use a component manager for each object and access these components by someObject.getComponent("componentX") but that seems like overkill for anything other then a engine to me.

So I guess I have to go with option 1, what was suggested earlier by Krohm. Or with 3 but make the "components" there own accessible classes from the entity holding it. I have been looking for examples but have not found any yet. If anyone can point me to some examples, preferably C# or Java, I would much appreciate it. For now I will prototype both options and play with the idea.

#5251312 Popular languages for networking for games

Posted by on 09 September 2015 - 05:15 AM

I am no expert on the subject but I do not think there is a "most popular" language for networking. As long as you have access to sockets you will be fine. As with everything, the more control you have the better you can create something that fits and works best with what you are planning. Therefor I guess C++ would be the language of choice. However if you are here to make games rather then building a framework or engine keep reading.


You mentioned Java and LibGDX and I'm a great fan of LibGDX. Nathan, the top contributor to LibGDX also made a Networking framework called KryoNet designed for Java. KryoNet works perfectly with LibGDX Android, Desktop and HTML modules, I'm not sure about OS. You can setup a client to server connection in a matter of minutes.


Put this in your core dependencies of "build.gradle" and you are ready to go.

        compile "com.esotericsoftware:kryo:3.0.1"
        compile ("com.esotericsoftware:kryonet:2.22.0-RC1") {
            exclude module : 'kryo'

I currently have a server running on a Raspberry Pi using a regular Java Application. You basically only need this as the server to connect a client.

    public static void main(String[] args) throws IOException
        final Server server = new Server();
        server.bind(tcpPort, udpPort);

Now for the client which could be your LibGDX game.


    private void connectToServer()
        Client client = new Client();
        try {
            client.connect(5000, "mydomain.com or localhost/", tcpPort, udpPort);
        } catch (IOException e) {
            Gdx.app.log("Main", "Failed connecting to server.");
        if (client.isConnected())
            Gdx.app.log("Main", "Connected to server.");

Run both and you will connect. If you run the server from your desktop and want connect from outside instead of local(host) you need something like noip.com which is a free service that links your dynamic IP to a DNS. Of course you need to forward your ports to make this work over internet. Otherwise you could pay for hosting the server elsewhere.


To sent data back and forth you need to register so called "packets" in both client and server. A packet could look like this:

public class MessagePacket {
String name;
String message;
Add and register that class in both client and server:
server.getKryo().register(MessagePacket.class); //in server program
client.getKryo().register(MessagePacket.class); //in client program
Now we can sent stuff back and forth between server and connected clients. Let's send a message from the client to the server:
MessagePacket message = new MessagePacket();
message.name = "Menyo"
message.message = "Hello everyone!"
And off it goes to the server. Now let's intercept it at the server.
    server.addListener(new Listener() {
        public void received (Connection connection, Object object) {
            if (object instanceof MessagetPacket) {
                 //cast object to correct packet.
                 MessagePacket message = (MessagePacket) object;

                 System.out.println("Received message from client: " + message.name + " with connection ID: " + connection.getID);

                 //Check the message for bad words if you want here :)

                 //Sent it back to other connected clients.
                 server.sendToAllExceptTCP(connection.getID(), message);


The server has received the message and sends it to all other clients. The last step is to listen for the Message on the client side and show it to the user. To receive a message at the client side you do the same as the previous step. Just listen for "received", cast it to the proper class and do you magic on it.


Since you now know how to sent and receive data on both server and client side nothing can stop you to make some amazing networking games! Well that's only partly true, creating a client/server structure requires different thinking and things can get more complicated faster then a offline game. But luckily, practice makes perfect.

#5250538 Alternatives to Hit Points.

Posted by on 04 September 2015 - 01:20 AM

You already kinda named it.

C) Independent limbs having health (Vagrant Story / Deus Ex)

But I love the way Dwarf Fortress is doing it. Limbs do not have health but there is a chance armor get pierced and a limb gets damaged in a certain way (bruced, muscle torn, bone broke, severed, etc). It all depends on the type of impact (slashing, piercing, bashing) and the quality of the material.

#5191920 Adding item modifiers

Posted by on 09 November 2014 - 06:29 AM

I want to implement modifiers for special items. But I cannot figure out a good way to implement this. Let's say I have this item class structure:

public class Item
    String name;
    int strengthReq;
    int dexReq;
    int wisdomReq;

public class Weapon extends Item
    int maxDamage;
    int minDamage;
    int durability;

Now i want to add modifiers to this, the best way i can think of besides directly altering the item itself is a modifier class that uses a Enum to tell what has been modified. Adding a modifier object to an item and use statements every time a modifier might have been used and act accordingly. Currently my game uses a simple action system, for instance: when someone attacks source and target get passed to a static method and all the damage will be resolved according to the weapon damage/type.

public class Modifier
    enum ModifierType()
    ModifierType modifierType;
    int modifierValue;

Looking for pointers to make my item system more dynamic and fun with modifiers.

#5189504 Do i really need to deep copy this?

Posted by on 27 October 2014 - 03:42 PM



I come from a C# and i'm trying to get my Astar implementation working on java for Android. Since Java is pass by value I need to make a copy of this Array[][] each time I request a path. This feels awkward for me and perhaps unnecessary.


So what i actually do in my Astar method, instead of iterating over a closed and open list many time, or putting new nodes into it in a ordered fashion I am creating a 2D map resembling my map in nodes. These nodes hold a open and closed boolean so all i need to do is check directly on this map if this tile belongs to the open/closed list, see move cost and if it is walkable. Instead of searching for it in a potential huge open list each time. I create this map when a new map is loaded, so with C# this actually got created only once.


Anyway, I did the same in Java but when I passed this NodeMap as a parameter it actually alters the base object instead of making a copy to work on. Now my (crude?) solution was to implement a constructor for my Node class so i can deep copy the complete NodeArray[][].

public Node(Node copy)
            this.G = copy.G;
            this.H = copy.H;
            this.position = copy.position;
            this.parent = copy.parent;
            this.closed = copy.closed;
            this.open = copy.open;
            this.walkable = copy.walkable;

And here i copy it, every time i need a path, i pass the actual Array[][] that needs to stay unaltered as nodeMapRef.

Node[][] nodeMap = new Node[nodeMapRef.length][nodeMapRef[0].length];
        for (int y = 0; y < nodeMapRef[0].length;y++)
            for (int x = 0; x < nodeMapRef.length;x++)
                nodeMap[x][y] = new Node(nodeMapRef[x][y]);

It really loses it's charm this way but i cannot think of a good way to handle this. And i can imagine if my map size grows and need much more paths this might slow things down significantly.

#5187984 Inexperienced Programmer looking for Help

Posted by on 19 October 2014 - 08:23 AM

Seems to me your idea is too ambitious for the experience you have. Like Frob mentioned you need to nail the basics of programming and the framework or engine you use. Then i asvice you to cut your idea into pieces and practise/prototype these ideas in a framework or engine that can do the job. I am not a Unity user but there should be plenty of resources for it to get you started. Apart from cutting up the game into pieces you need to know exactly what is needed for your game. As for cutting down your project is smaller pieces:


  • Screens, you need at least a main screen, options and a game screen at first. Within the game you will probably need much more screens and smooth transitions between them.
  • Map, this is the biggest challenge as it is going to hold 90% of your game. Try to render a simple isometric grid first.
  • Camera movement, with most frameworks and engines this should be easy.
  • Tilepicking, you need to know what tile you are pointing/clicking at. Isometric maps are a bit harder then regular tilemaps but some basic math will get you trough.
  • Map interaction, try to implement something like pressing "b" a city is created at the mouse pointer. When a city is double clicked you go into a city screen which you are already comfortable with since that was the first piece you did. This function can later be transferred to a unit.
  • Units, make them clickable/selectable.
  • Pathfinding AI, something like A* will do.
  • Create actions for your units, here you can derive a "Build city" from and paste in the code you had ad pressing "b". 


All of the above is perfectly doable for a beginner on it's own, there is plenty of documentation around. Weaving them together is a much bigger challenge and all up to you. Creating NPC AI is going to be an even bigger challenge. Again, you really need to know your OOP basics like inheritance to make things efficient.

#5183805 New to gamedev – questions about mobile games

Posted by on 29 September 2014 - 10:57 AM

If you want to create games you should use every framework that helps you reach your goals. Building a engine from the ground up to make another game is just silly in 99% of the cases, the other 1% is a AAA+ title that needs every inch of juice to pull out those insane graphics.


Either way, LibGDX, unity or unreal you need to learn to code. LibGDX requires the most coding, its no engine but a framework, it grants the most freedom as well. It also ports to android for free. You can buy the additional framework to port to IOS.


Unity has a complete 3D interface and you can drag and drop stuff onto the scene (game world) then you can add premade code snippets to add functionality. But if you need something specific for your game you need to code it yourself. Unity is definitely easy, i had some kind of buggy FPS with my own 3D gameworld up and running in a couple of hours.


Not sure about unreal engine 4, i have dabbled in UDK and it is a nice engine you need to learn unreal script which should not be that hard i suppose.

#5183248 Source control with git hub/lab?

Posted by on 27 September 2014 - 01:05 AM

Thanks for all the good information. I still, and probably will for a while, work on my project alone. But I got very comfortable with git in a couple of hours reading and testing. This thread helped me a lot better then the tutorials i found out there. I will be adopting the git workflow by Vincent Driesen, although that might be overkill for my current project it will help me organize future project as well.

#5183154 Source control with git hub/lab?

Posted by on 26 September 2014 - 10:29 AM

So i installed github power shell and opened a account at gitlab. I even got my existing project into my gitlab repository. But there are still some question remaining, how do i actually use this to backup my working project or version control?


My assumptions and questions:

- I need to create a branch and work that branch, if that branch fails to work i can fall back on the master.

- If that branch works i can merge it to the master project.

- If i still want to fall back on a previous branch can i still access those after i merged?


Am I on the right track? Or can I actually find revert every change in any file committed and pushed? Imho the tutorial i have seen are vague about how this exactly works they show you how to start and stop there.

#5157292 RPG Maker - Free weekend on Steam

Posted by on 01 June 2014 - 04:10 AM

About the Humble Bundle pack, I was just digging trough all the assets, each asset creator has a readme.txt in it's folder which says:

"You may **NOT** use the resources in this pack for creating games made with engines/programs other than RPG Maker series.".


This is really crap, i just thrown away $25. They could have informed us a bit better on this, assets are assets imho, however we use it is up to our self if we pay for it.

#5149819 Random map with prebuild pieces

Posted by on 27 April 2014 - 04:37 AM



I am looking for ways to generate a random tile map out of prebuild pieces, much like diablo 2 and Dungeons of Dredmore do. I have prebuild sets of 8x8 for corridors and small rooms, and for larger rooms i need 16x16, 24x24 and perhaps 32x32 sets. Some rooms will hold quest pieces like bosses or artifacts, most probably i will do this with color values on images. The picture below shows just entrances in pink and passable area in black.


I have been looking into mazes and translate these mazes to these prefab pieces. So if i generate a 16x16 maze it will give me a 128x128 map. Each maze tile will translate to a corresponding prefabricated piece.


Some characteristics:

 - I do not want to many dead ends since this might frustrate the player.

 - The mazes i looked for are "dense", every tile is used. This is ok for some maps but some need to be less dense.

 - I need some maps to have the entrances/exits at the edge and some within the map but some distance appart.

 - I need to insert special rooms that hold treasure, quest items, bosses, etc.


Basically what i am looking for now is a partially braid maze algorithm that let's me pick the entrance and exit area's, insert some larger rooms and generates some larger rooms occasionally. I could also just pop in my entrance, exit, special room and multiple larger rooms then run a braid maze algorithm and restrict it on those area's but taking there entrances into account to connect properly.


How would you take on a problem like this? I would love to read some ideas so i can look at this from another angle since i am stuck on this for days.


I used to have a website bookmarked that explained exactly what i am looking for, unfortunately i lost that bookmark. It used much smaller "connection" rooms but i think i can easily translate this into bigger ones i have. So if anyone has this i bookmark i would already be very happy.

Attached Thumbnails

  • prefab.png

#5145002 How to make a Game Engine For Super Beginners?

Posted by on 07 April 2014 - 06:34 AM

Can someone explain to me what all the fuss about 'engine' is, and why there is so much magic and mysticism around it?  In my world, an engine is what you naturally create while you are making a game, not necessarily a ready made 'system' made by some other company/person.


Not an uncommon game loop (details may of course vary):

    while (!quit)
        //Manage inputs from the user (joystick, keyboard, mouse, etc...)
        //Do some calculations
        //Draw your scene/graphics based on the previous steps

To me, this is an engine.  It arises naturally from the process of creating a game.  Yes, it looks simplistic, but might not necessarily be.  Please explain if I am wrong?


While OpenGL or Direct3D might be hard to learn initially, it is an important process in learning to make games, and if you can make one textured quad output to the screen, it is not hard to expand to that so you can make your own class to plot a lot of tiles to the screen either.  If you want to postpone on that, you can of course use one ready made APIs to render 2D graphics, or if you are more adventurous, try to make some simple 3D graphics.  How about running around in a maze?  That would be a nice challenge if you are going for 3D.  My point is that you have to start somewhere, and it is just to dive into it.  Make something really bad, and refactor and make better as you go.  Start with something that is so easy that you think you can manage to do it.  (I wouldn't really recommend 3D, if you are an absolute beginner, though.)


Sorry if I am way off with my thoughts.


EDIT: I also disagree that you need to be an expert to make an engine.  When you are learning, you are allowed to fail.  Actually, failure is what you will learn from.  Your first 'engine' need not be perfect in any way - just work.  Knowledge is what you gain by doing.


That is just a while loop with some comments in it. An engine is what you create to make everything work together. You could make an engine and not have a game but having an engine will simplify making a game. Hence we advice you to rather choose a existing engine (like Unity or UDK) or library (Like XNA or SFML). With all these tools out there you do not need to know the inner workings of OpenGL or DirectX, you do not need to know how to ask a graphics card to draw a quad. There will be ready made classes for you. To draw a quad in Unity you just drag one into the scene with the mouse and voila. With XNA you just have to setup the indices/vertices and throw it in your draw class. So why botter creating the inner workings, unless of course you are really interested in that part and do not want to make games.


Most bakers do not know how to grind wheat into flower but they can make amazing things with flour.

#5144227 Path as an Artist in Game Development.

Posted by on 03 April 2014 - 08:09 PM

I dabbled with 3D art for many years but because of my bad drawing skills i could not develop a proper feel for forms quickly. Where you could draw dozens of quick sketches on a single page you pretty much was working on a single head for many hours if not days in 3D. Drawing is pretty much mandatory for any form of art since you will learn a lot quicker about forms, anatomy, shading, etc. But nowadays we have Zbrush which is a amazing tool and i have seen amazing full detailed speed sculpts done within an hour. Still i think drawing would help, but practice makes perfect. At one time in my life i put a lot of effort in drawing and my skills really improved. So i would really suggest to pickup a pen and paper and just practice. That goes for pretty much anything in life.



We would love to see some of your models/sculpts

#5144220 How to make a Game Engine For Super Beginners?

Posted by on 03 April 2014 - 07:25 PM


Unless you really want to spent a lifetime creating a efficient engine You should just pick one of the dozens of amazing engines out there. Creating an engine requires you to already be a expert game developer. And if you where an excellent game developer you would not have posted this question here. So take my advice and just pick an engine to create your 2d rpg.

If you want to become an expert some day, you must go this way and reinvent something every time.



To create an engine you need a lot of knowledge of game development. To create a proper and efficient engine you need to be expert on the subject. These are the first steps to take imo. For learning purpose reinventing is good, for developing anything it is a absolute no go, you should already have that knowledge. If you want to sent the OP straight into C++ engine design you clearly missing the point of the beginners topic.

#5144217 Is the era of C# for game programming gone?

Posted by on 03 April 2014 - 07:11 PM

C# is a perfect language for creating games and XNA is still a amazing and very useful tool to develop games.  There are still plenty of other popular game development tools that use C# like Monogame (A open source port of XNA), SlimDX and SDL.Net or engines like Unity or torgue that accept C# scripting.


However, Java is something to look out for, it can be easily ported to many platforms. The syntax is very much like C# so the step to java is just a small one and you can do it anytime you wish.


Unlike many others I would not recommend C++, you need to do twice the work for half the result and it is a very unclear and unforgiving language. I dabbled in C++ after some good experience with C++ but left it for what it was pretty fast. SFML is a nice platform though. 


The most important thing is; You just need the right tool for the job. If you want to make a FPS or top down shooter pick a existing engine like UDK or Unity. If you need a bit more freedom further down the mechanics go with C# or java and add some handy libraries yourself. If you want to make the next best AAA title and need all the power you can get then go C++. Profesional AAA title companies use C++ usually, at least to lay the backbone of there engine. However, since the mobile game market is booming Java has become a lot more popular but you can also build android games with C# for example with: http://xamarin.com/android it ports easily between IOS, android and windows devices. Long story short: pick the right tool you comfortable with.