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


58

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


36

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


30

It will cause one CPU core to always run on 100%. This usually doesn't cause any harm to the system. CPUs are designed to run on 100% for hours. But on a mobile device it will drain the battery quickly and heat up the device, which will likely cost you about a stars in your store ratings. On a desktop computer this is less of a problem, but it will consume ...


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

You don't need to master any language before jumping right in an making something. Jump right in and learn on the way. It's likely your best option for learning the relevant parts of the language anyway.


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


17

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


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

I think you're after Application querying switch(Gdx.app.getType()) { case ApplicationType.Android: // android specific code case ApplicationType.Desktop: // desktop specific code case ApplicationType.WebGl: /// HTML5 specific code }


15

It sounds like your goal here is just to make games. Use LibGDX. With this Library you can test it and deploy it to Windows/Linux/Android/HTML5. It's also free.


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


15

Think of the problem like this: How does a snake move in the original game? The snake moves towards its current direction. The behavior looks like the head appears out of nothing, and the last tail part disappears. You can have a list of snakeparts. What you want to do is remove the last item in the list which represents the last tail part. Then you want ...


14

Unity is actually using Mono in its back end. Though a lot of its scripting tutorials use JavaScript, you can actually program Unity completely in C# / Mono.


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



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