Hot answers tagged

86

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


75

Give the ball a height value. Draw a shadow at the ball's actual 2D position; the shadow will help spatially orient the ball for the player. When you draw the ball itself, offset the Y position by the "height" of the ball. If you want to implement more than just an illusion, use this height value in computations as well -- for example, you can implement the ...


74

Shadow and texture. Texturize the ball to show it rotating. This helps give the illusion of rotation of a sphere, which is more than 2 dimensions. A shadow can trick your brain into believing all sorts of things. Making flat things look like they have a third dimension. You don't even have to change the height of the ball, you just need to change ...


62

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


46

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


40

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


37

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


35

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


33

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


29

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 }


28

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


23

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


22

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


21

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


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


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


19

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


19

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


19

Card shuffling is an algorithm which is easy to write intuitively, and get entirely wrong by doing so. There's a good reference for implementing card shuffling correctly on Wikipedia. What I'm presenting here is a very slightly simplified version of the algorithm covered on that page under The modern algorithm. Here's the basic idea, in plain english: ...


19

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


19

Storing the completion information in a local file is a simple and perfectly acceptable method of doing so. Fundamentally, this is what every game will do to track progress (in some fashion, although the specific formats used for the data and the storage mechanism will differ). Protecting the file from tampering is more difficult. If there's no compelling ...


18

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


18

You're moving the circle by one pixel per frame. It should not come as a big surprise that, if your rendering loop runs at 30 FPS, your circle will move 30 at pixels per second. You basically have three possible ways to deal with this issue: Just pick one frame rate and stick to it. That's what a lot of old-school games did — they'd run at a fixed ...


18

To answer your question directly, no Steam doesn't notify the purchaser that the game needs Oracle's Java Runtime Environment installed to play the game. That's because there shouldn't be any need to, any game that has a dependency on the JRE will download and install it as part of the normal Steam installation procedure. This is no different than games that ...


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

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



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