Tag Info

Hot answers tagged

73

You can use int, and consider everything in cents. $1.20 is just 120 cents. At display, you put the decimal in where it belongs. Interest calculations would just be either truncated or rounded up. So newAmt = round( 120 cents * 1.04 ) = round( 124.8 ) = 125 cents This way you don't have messy decimals always sticking around. You could get rich by ...


57

Okay, I'll jump in. My advice: it's a game. Take it easy and use double. Here is my rationale: float does have a precision issue that appears when adding units to millions, so though it might be benign, I would avoid that type. double only starts getting problems around the quintillons (a billion billions). Since you are going to have interest rates, you ...


42

Yes it is, check this list for a proof. Those are some games made with Java using The Lightweight Java Game Library (LWJGL). It is a low-level framework, which provides OpenGL for high quality graphics and OpenAL for sounds. It also provides input API. With these you can quite easily get started to serious game development in Java. I am currently writing my ...


39

C# and Java are not "basically the same". A lot of basics are just similar, and it's not a coincidence: C# was influenced by Java and they were both influenced by C++. Whilst this means you'd already recognise a lot of stuff, it doesn't mean you suddenly know C#. Do you know much about its standard library? A lot of the collection classes are named ...


35

Not really. Here's the thing- firstly, there's very little in terms of existing libraries for Java compared to the virtually everything that is for C++. Secondly, Java as a language simply doesn't lend itself well to game development- I mean, for example, if you're dealing with GPU buffers then Java does not provide a language feature which will aid you in ...


31

To display hierachical data, YAML or JSON would be good options. They are far simpler and easier to parse than XML. Another option would be a "controlled" binary serialization process. Every object writes it's state out in a controlled way, i.e. void player::save(savegame &sgm) { sgm.write(this->position); sgm.write(other properties); ...


26

I'm actually one of the Don't Starve devs (Kevin on our forums). I don't usually handle the rendering stuff, but I can tell you that the game is in 3D. The ground is just a regular 2D tile map with special transition pieces to make corners look better. There's no special Deathspank-style rounding going on, although we have talked about doing that in the ...


22

So, I am really serious about game development, is Java still a viable choice? I have tried multiple times to learn C++, but I don't really like the language. I don't really know why, but usually, whenever I try to learn, I can never grasp the topics. If your reason for choosing Java is that you couldn't understand C++, your Java programs aren't going ...


21

Avoid 3D, because you would need to know how to make 3D models or find good ones, you would need to know how to load such models (often an epic task in itself, sadly), and how to draw them on the screen (e.g. OpenGL or DirectX takes a lot of work for little gain, and even an engine like jMonkeyEngine requires knowledge of how to utilize the engine, along ...


21

Floating point types in Java (float, double) are not good representation for currencies because of one main reason - there is a machine error in rounding. Even if a simple calculation returns a whole number - like 12.0/2 (6.0), the floating point might wrongly round it (due tho the specific representation of these types in memory) as 6.0000000000001 or ...


20

IMO, yes, you are likely to be hurting yourself. First of all, rightly or wrongly there is a perceived hierarchy among programming languages -- and C++ generally has a higher standing than Java or C# (e.g., questions like yours are fairly common -- the reverse is virtually unheard of). If you apply somewhere that uses C# or Java, and you know C++, they're ...


20

You should prefer to keep your rendering code separate from your game logic, as they are separate concerns. If you separate your rendering code from your client/server code, you get a couple of advantages: Creating a dedicated server will be easier, as any code that renders will be in one place. You can separate your update phase from your render phase, ...


19

Java runs in a virtual machine, while C++ is run directly on the hardware. What this means is that you have more control over where your memory goes and what is done with it in C++. Java is a garbage collected language. You do not have direct control over your memory. You can allocate new chunks of memory, but you do not have (fine) control over when it ...


18

Okay, so here is my understanding of this - coming from developing games and a constant attempt to obtain more knowledge on licensing, copyright, open-source projects, etc. You are allowed to make a Minecraft clone and open-source it with no repercussions as long as you don't use the title Minecraft, don't use any of Minecraft's source code, and don't use ...


18

Put it wherever you can to make it work. Anything else is design paralysis and just going to slow down your progress. When you start seeing patterns emerge, refactor your code. Lots of people will give you advice about the One True Way to do something, but without a breadth of experience to draw from, you'll just be parroting ideas without a true ...


17

There are two standard ways of doing this. Break up your non-standard tile sizes into standard tile sizes. So those strips of walls become a "stack" of square tiles that you just know to place together in your level editor. Games like the early Final Fantasy games worked this way. Let any tile piece be taller than your standard tile height. Align tiles ...


17

You could use an algorithm that checks near blocks, and varies the probability depending on what is there - but I think it's largely the wrong approach. What you want to be looking at is fractal noise types - in this case, perlin or simplex noise. If you generate noise, you'll get values from -1 to 1. http://en.wikipedia.org/wiki/Perlin_noise You can then ...


17

For small scale game and where process speed, memory is important issue (due to precision or work with math co-processor can make painfully slow), there double is enough. But for large scale games (for example, social games) and where process speed, memory is not limited, there BigDecimal is better. Because here, int or long for monetary calculations. ...


16

It depends on the requirements of your game and hardware. Most games are usually interested in changes to input state, i.e. user presses the fire key and their weapon starts firing, user releases the fire key and their weapon stops firing, user presses the move key and starts moving, releases the move key and stops moving, etc., so an event-driven input ...


16

Demo GameDev Meta: Henshin Main!! :D The code uses a canvas clip region and requestAnimationFrame for maximum quality and efficiency. (It's better live.) I assumed you meant HTML canvas! Even if you didn't, other rendering engines (such as Android's 2D rendering pipeline, which you might have meant) also support hardware-accelerated clip regions. The ...


15

Pools are used when the number of objects will fluctuate dramatically and are used to reduce the amount of memory allocation and garbage collecting. Using a pool the standard new Object() which allocates new memory is replaced with pulling an already allocated object from the pool. This is much faster even if you go though and reset every variable in the ...


14

According to your first requirement, you are looking for a framework rather than a library. jMonkeyEngine is a framework for 3D games (i.e. it provides the main loop as you ask for, similar to XNA) but it wouldn't be a good choice for 2D. However, a game loop isn't a hard thing to write, and existing Java libraries handle your 2nd and 3rd requirements, so ...


14

The Component (not Composite) design pattern is great for this purpose: http://gameprogrammingpatterns.com/component.html Basically, an Axe would be an instance of the Item class that contained a WeaponComponent and a ToolComponent (maybe). To test if something can be used as a weapon, check if it has a WeaponComponent attached, and then talk to that ...


14

There are lots of good choices. (I teach CS1 and CS2, as well as game programming.) First, of course, learn to think like a computer scientist. Don't get too tied up in the language, because the concepts truly are universal. Java is a pretty good language, but building a game in Java is a bit tedious. There are some interesting engines out there that ...


14

It's not terribly popular, in my experience. There's a few problems. First off, Java isn't the most efficient language around (though better than many think), but that lack of efficiency isn't really compensated for by ease of development. Second, running Java is kind of a pain - it's gotten better recently, but it's still tainted by Java's legendary growing ...


14

Start with a full list of rooms. Pick a starting room. Navigate from that room to all connected rooms. For each room you visit, remove it from the list of rooms and add it to a list A. Once you've visited all your connections, any rooms remaining on the list are not connected to the starting room or any of the rooms on list A. You can then continue by ...


14

When I created an oh-so-awesome almost-pacman clone on my TI83? calculator, the biggest problem I ran into was that the "ghosts" were far too fast. I had to slow them down somehow. So, I put in a big old sin(cos(tan(x-coordinate))) in there. Easier levels would do that calculation a few times, and harder levels would do only one of the operations. The ...


13

I would say try Windows Phone 7. Couple of reasons I say this, first and foremost, if you are already familiar with C# and XNA then you don't need to use your first couple of projects to simply learn the language even before you start learning the platform. This might only be because I personally am rather lazy, but either way I think it's worth ...


13

I highly recommend that you have a render thread (using Canvas/OpenGL ES, Canvas is probably a little bit easier to setup) and a game thread where you put your game logic. To actually "load" the game you can create a GameEngine class and make that the central point of your application. When your renderer is ready to go you can create a callback to the ...



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