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 ...


66

You write a program to solve a problem. That problem is accompanied by a specific set of requirements for solving it. If those requirements are met, the problem is solved and the objective is achieved. That's it. Now, the reason that best practices are observed is because some requirements have to do with maintainability, testability, performance ...


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 ...


44

Give each Room coordinates (start would be (0,0)) and store each generated Room in a dictionary/hashmap by coordinates. It's trivial to determine the adjacent coordinates for each Room, which you can use to check if a Room already exists. You could insert null values to represent locations where it is already determined that no Room exists. (or if that's ...


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 ...


29

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 ...


19

2072-rated chess player here. I made this website in pure JavaScript over a weekend. It's not a chess engine (I designed it to create entertaining opening positions as sort of a perverse Chess960 engine), but it's a starting point. The source code is here. There are a lot of complications involved in making a functional board. These include: First, ...


18

There is no clear-cut answer, and class design for games is a very broad topic. I can hint you at two very common pitfalls though: It is tempting to use inheritance to model polymorphism on your game entities, so that you have a BaseEntity, a PlayerCharacter, etc., and give them a dozen or so methods to model how they move, draw, decide what to do, and ...


18

There's a wise old quote: "Do not follow in the footsteps of the wise men of old. Seek what they sought." There are reasons for all of the rules of 'proper' coding. Knowing why those rules exist is more important than knowing what those rules are. There is a rule that you shouldn't put a test that could be repeatedly recalculated in a for loop like ...


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

The Component-Entity-System architecture for game engines works for games because of the nature of game software, and its unique characteristics and quality requirements. For example, entities provide a uniform means of addressing and working with things in the game, which may be drastically different in their purpose and use, but need to be rendered, ...


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 ...


15

In most cases, what you're describing sounds like a graph. Given some of your requirements (the growing aspect) I'd probably choose an adjacency list as the implementation (the other common option would be an adjacency matrix). I'm not sure what language you're using, but a good tutorial/explanation with implementation details for a graph implemented with ...


15

Except OpenGL, I never used those libraries, but I'm going to try to guess, by reading wikipedia pages, like you did. You seem right about Mesa. Here is the additional info we have : "The X window system is a computer software system and network protocol that provides a basis GUIs for networked computers. It creates a hardware abstraction layer." "GLX ...


14

The problem with "chess program" as a concept is that there are many pieces which can absorb a lot of time, and not necessarily interest you at the moment. You can spend years just working on graphics, or an alpha-beta search, or a visualization to help develop for the search engine, or... well, there are lots of pieces. I recommend finding an open source ...


14

I'd personally go for many small libraries. Discourages developers from creating dependencies between otherwise unrelated packages. Smaller more manageable libraries that are much more focused. Easier to break up and have separate teams manage each library. Once you have a new requirement that's sufficiently complex, its better to add a new module rather ...


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

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

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

There are many different kinds of computer games and, correspondingly, many different appropriate sizes and structures of development teams. Some examples: A simple game can be developed by a single idealistic amateur or hopeful indie game developer who does everything, perhaps outsourcing graphics and sound. Many mobile games are of this type. I believe ...


12

Disclaimer: I am not a video game developer. But I do have a "hobbyist" interest in it. Most of the AAA games you see are made using Engines. They aren't written from the ground up. Think of an engine like a framework. You have .NET framework, Java SDK, Cocoa toolkit. All things to make your job of creating software easier and abstracting away the kitchen-...


12

You might be trying to do too much in the model. If the model has to care about screen size, I would say the design is breaking some rules of MVC. Instead, why can't the controller (or "presenter") know the screen size and adapt the model data to match? The Controller is technically the correct place for any logic requiring knowledge of both the view and the ...


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 ...


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