69 votes
Accepted

When is it appropriate to introduce a new layer of abstraction into a class hierarchy?

I've built a 2D roguelike from pretty much scratch, and after lots of experimentation, I used an entirely different approach. Essentially an entity component architecture. Each game object is an ...
user avatar
47 votes
Accepted

What's the proper way to model this real-world activity that seems to need circular references in OOP?

I've been wrestling with a problem in a Java project about circular references. Java's garbage collector doesn't rely on reference counting techniques. Circular references do not cause any kind of ...
user avatar
  • 1,217
47 votes

When is it appropriate to introduce a new layer of abstraction into a class hierarchy?

This is why we often like interfaces over inheritance: Many real-world problems cannot be modeled in an object hierarchy. interface IMove { // returns an intermediate location chosen with // ...
user avatar
  • 2,797
22 votes

What's the proper way to model this real-world activity that seems to need circular references in OOP?

Granted, circular dependencies are a questionable practice from a design point of view, but they are not prohibited, and from a purely technical point of view they are not even necessarily problematic,...
user avatar
  • 31.4k
14 votes
Accepted

Is it a good idea to experiment with design patterns?

People have experimented with different mechanics of implementing a design pattern in the past with differing results. For example, the definition of a singleton is that there is only one instance of ...
user avatar
13 votes
Accepted

TCP or UDP for a multiplayer game?

Depends on if you're talking about peer-to-peer, client/server with the users running the server, or client/server with a data center running the server. Only in the latter-most case is the internet ...
user avatar
  • 2,817
12 votes
Accepted

Test Driven Development for Complex Games

Unit tests don't test gameplay. There's no programmatic criteria to see if a game is fun, or a level is the right difficulty. Unit tests will test that your roguelike mapgen actually produces a level ...
user avatar
  • 107k
12 votes

Is it a good idea to experiment with design patterns?

No. Design patterns are not building blocks. If you are trying to 'experiment' with them, you are most likely trying to apply them in situations that don't make any sense. Instead, you should ...
user avatar
  • 27.2k
11 votes

Is software testing different when we are dealing with game development?

Modern games are actually a ton of creative art content developed using an in-house or proprietary game engine. The engine itself is unit testable for most part (rendering, geometry, physics, AI ...
user avatar
  • 803
10 votes

Enemy AI for classic game Bubble Bobble

"The best algorithm to achieve this"? Define "best". A simple A* algorithm will generate the most efficient possible path for an enemy to take to reach the player, but would you really want to play ...
user avatar
10 votes

What's the proper way to model this real-world activity that seems to need circular references in OOP?

Game theory treats games as a list of previous moves (value types including who played them) and a function ValidMoves(previousMoves) I would try and follow this pattern for the non UI part of the ...
user avatar
  • 64.9k
9 votes

How to pick a random move/action/element non-probabilistically?

Maintain and update the list of possible moves to pick from. Changes to this list will be small per move on average and often localized to where the piece was put.
user avatar
9 votes
Accepted

Algorithm for calculating a bullet path to a target with max. 2 ricochets

Given a direct line of sight, the problem is obviously trivial. However, we are dealing with reflection. Properly finding out which parts of the scene can be seen is challenging when implementing ...
user avatar
  • 125k
9 votes

How to convert a possibly ever-increasing number to a finite scale?

Simple: you start with f(x)=1/x, which goes down to zero when x goes to infinity. Now you want this approximate a constant c from below, utilize it this way: f(x)= c - 1/x From your example I guess ...
user avatar
  • 186k
9 votes

How to ensure a user isn't using a hacked client

NEVER TRUST THE CLIENT! No seriously NEVER TRUST THE CLIENT! Third time so you remember NEVER TRUST THE CLIENT! Customer service corollary: The customer is lying! You need to do all important ...
user avatar
  • 3,779
9 votes

When is it appropriate to introduce a new layer of abstraction into a class hierarchy?

I would follow your first option, but then use the strategy pattern for the different move styles. This will allow you to swap move styles and alter moves styles easier moving forward. So you’d have ...
user avatar
  • 1,476
8 votes

Distributed game development and security of source code

Rights and capabilities are very different. In fact, legal rights were invented largely because access issues couldn't be solved by enforcing technical capabilities. Sure, we put locks on our cars and ...
user avatar
8 votes

What's the proper way to model this real-world activity that seems to need circular references in OOP?

The standard way of removing a circular reference between two classes in object oriented programming is to introduce an interface that can then be implemented by one of them. So in your case, you ...
user avatar
  • 17.3k
8 votes
Accepted

Is this OOP class hierarchy too deep?

I would have your objects implement interfaces like ICharacter, IEnemy, IHorizontalMover. The relevant design guideline is known as Favor Composition over Inheritance, and it should allow your design ...
user avatar
  • 649
8 votes

When to lock an object in a game

Whenever two or more threads need to change the same object and potentially at the same time, you need to ensure that the object remains in a consistent state making it synchronized. Apparently, it'...
user avatar
  • 68.5k
8 votes

Why don't audio engines already process audio more realistically?

There's no technical reason why any of this couldn't be done. Processing of this depth is already done on the images the game displays (although not in quite the same way). The problem is not so ...
user avatar
8 votes

How can a html 5 game made licensed?

The usual solution is to put part of your game logic on a server somewhere and have your game communicate with it using AJAX or similar. In the server code you can check for license keys. In short, ...
user avatar
8 votes
Accepted

Optimal Immutable Data Structure for Highly Dynamic Particle System

Immutable data structures are best suited for systems where the majority of data managed by an application stays unchanged (or can be modeled in a way so it stays unchanged) the changes to the data ...
user avatar
  • 186k
8 votes

When is it appropriate to introduce a new layer of abstraction into a class hierarchy?

The answer to your main question: in general, when is it appropriate to introduce a new layer of abstraction at the cost of complicating the program architecture? is relatively simple and ...
user avatar
  • 2,232
7 votes
Accepted

Handing Off A Unity Project

With the exception of people sunk in the real programmer syndrome, no one is going to disregard you for using Unity. Unity is a framework, like many others, that helps you make software. Saying that ...
user avatar
  • 11.8k
7 votes

Algorithm for calculating a bullet path to a target with max. 2 ricochets

Just extending Karl Bielefeldt idea for a 2 walls reflections: A and B are given (the tanks). You first must list all walls that A can see and a list of all walls B can see. Then you make pairs where ...
user avatar
  • 517

Only top scored, non community-wiki answers of a minimum length are eligible