69

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 Entity, and an Entity has many attributes which control how it responds to stimuli from the player and the environment. One of these components in my game is a ...


47

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 problem in Java. Time spent eliminating perfectly natural circular references in Java is time wasted. I coded this up [...] but the problem is that it's full ...


47

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 // the intention to move toward destination Point Move(Point currentLocation, Point destination) } Now we can inject an IMove, or we can write a "move this ...


39

From The Digital Antiquarian's article on "The Hobbit": Megler [1] recruited a partner to work with her on the game, Philip Mitchell [2], a fellow senior with whom she had already worked on a number of group projects and whom she knew to be both easy to get on with and a skilled programmer. Milgrom [3] himself added a third member to the team specifically ...


35

Okay, theres a lot of misinformation in this thread. I know the game business extremely well, having been in it for 25 years. I also know Java in games extremely well having been Sun's Java Game technical evangelist and lecturing Java performance programming expert. In terms of computational speed, Java beats C++ in many scientific computing benchmarks ...


22

It's actually quite an easy choice. Right now, you have zero users, and scalability is not a problem. Ideally, you want to reach the point where you have millions of users, and scalability becomes a problem. Right now, you don't have a scalability problem; you have a number-of-users problem. If you work on the scalability problem, you will not fix the ...


22

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, as you seem to regard them to be: they are perfectly legal in most scenarios, they are inevitable in some situations, and on some rare occasions they can even ...


18

Every Valve product is developed using their own in-house game engine called Source. The Source Engine is written in C++. The source engine contains both an OpenGL and a DirectX renderer which helps it in being cross platform, but the key is SDL. The open source Simple Direct Media Library is used by a team inside Valve which is tasked almost exclusively ...


16

I come from the ancient era of "we had to code all by ourselves" and that is what I still do. So, I do not know these new "next-generation" 3D engines/environments where you just apply a bit of code here and there and it miraculously turn into a game. (no, its not really like that, just the way I see them) That is why I am offering my opinionated answer for ...


14

Sure you can - I learnt a lot about Java when I started by writing a simple game. Just be sure to start with something simple so that you can focus on the basics and don't get discouraged - which is a risk if you take on an ambitious project too soon.. You will probably find it easier to write a simple 2D game (using a library like Slick2D) rather than ...


14

Since Tic-Tac-Toe is a solved game, I would recommend simply playing a perfect game every time. The following algorithm will allow you (or the AI) to always deny your opponent victory: Win: If you have two in a row, you can place a third to get three in a row. Block: If the opponent has two in a row, you must play the third to block the opponent. Fork: ...


14

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 a class for your entire application. There is nothing in that definition that requires you to implement it with a static accessor, even though that's how the ...


13

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 really fast and reliable. Your users' computers are not guaranteed to be fast, and certainly won't be reliable. UDP allows you greater control over the sort of ...


12

Your example sounds similar to Bridge. Top Bridge-playing systems use Monte Carlo methods to select moves. At a high level: Determine the probabilities of each card being in a given hand. You know with certainty which cards are in your hand and which cards have been played. Determine the probability of all other cards based on cards that have been played ...


12

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 with a stairs up and a stairs down. It will test that your encumberance rules are setup that your character actually moves slower when weighted. It will make ...


12

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 experiment by trying to build a wide variety of programs that solve a wide variety of problems. In doing so, you'll find various techniques you used in some programs ...


10

"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 against a perfect computer? That's a recipe for frustration right there. The Pac-Man "AI" was actually 4 very simple algorithms that told the 4 ghosts where ...


10

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 game and treat things like board setup as moves. the UI can then be standard OO stuff with one way ref to the logic Update to condense comments Consider Chess. ...


10

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 modules etc). Similarly, simple tests can also be attached to individual parts of developed content. This means unit and white-box testing is indeed feasible and ...


9

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.


9

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 reflection as part of a ray tracer, since this might miss some openings. A “binary search” between two promising angles is also not viable: due to the reflections, ...


9

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 you want to allow x=0, and f(0)=0, so try: f(x)= c*(1 - 1/(x+1)) If the slope of that function does not suffer your needs, there are further ways to modify ...


9

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 calculations, dice rolls, etc. on the server side. only input should be taken from the client, and that should be suspect (design your input so that its less abuse-...


9

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 an interface called MoveStyle and then several classes implementing it for each kind of movement.


8

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 houses; but that's really only a first level of defense to deter casual vandalism - a career criminal isn't deterred, and not much hindered either. There is ...


8

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 could have RuleBook referring to State which then refers to an InitialPositionProvider (which would be an interface implemented by RuleBook). This also makes ...


8

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 to be more flexible. One difference is that interfaces tend to specify behavior and any given object can implement as much or as little as it needs. If you ...


8

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's not only about the object, but also its containing object, because you mention "if the user made a change to an object while the tick was deleting it". ...


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