Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (522)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (590)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
   Home   Help   Search   Login   Register   
  Show Posts
Pages: [1] 2 3 ... 5
1  Java Game APIs & Engines / OpenGL Development / Re: What is the field of view in gluPerspective? on: 2013-09-19 14:23:52
You've got to have some type of 3D rendering and 3D physics first. How you create levels depends on that. Voxels, height maps, free form static terrain, and free form destructable terrain all need different tools. Many games probably use a custom editor.
2  Discussions / General Discussions / Re: PathFinding with gravity on: 2013-09-16 23:07:43
If you ignored the other web pages because they didn't mention your specific case, then go back and learn them. Learn what the breadth first search is then learn what makes A* faster while still preserving optimality. Also learn what optimal path means.

The generic grid method still works if you are sufficiently constrained. (To discrete grid location, with no jumping, and with constant speed when not stationary.) If take away constraints then you increase the search space. That basically just means your search nodes contain an extra variable, but it could multiply the size of your search space by the number of values your third variable could take - in the worst case scenario. If the character is free moving, then it gets much harder.

A* is fast enough to do once per update cycle if your search space is small. Complexity grows faster then search space, so don't use tiles that are only one pixel. Tiles are typically big, so there are only so many that can fit on the screen that are also reachable. There is no practical reason to recompute paths every frame anyway. It's not as if it will change each moment.
3  Discussions / General Discussions / Re: Do you customize your IDE (Eclipse?) on: 2013-09-16 03:45:40
That would be personal preference. I find having braces on separate lines messy and distracting. I use extensive syntax highlighting and that makes it easy to read the code.

Okay, but you admit that my syntax coloring preferences and naming schemes are 100% objective. I forgot to mention my indent size is two. When the indent size is ridiculously, impractically large, there is much less marginal utility to one style versus the other. Although to be honest I prefer BASIC style grouping to no-free-line style brackets. In my method you can use the nearly blank line as a "bookmark" and there is a structural symmetry that makes it easy to scan. BASIC syntax also makes it clearer which blocks belong to which initial line, but it's not my favorite.




What the fuck is it with people and dark background when coding ?
Is it just me or don't you get blind by looking at white text on black background. It burns into my retina and I can't see anything else anymore for a minute D:

I would not use white on black for anything. Orange is much nicer since it's the least intense color while still providing readable contrast. (Try bright yellow on dark blue if you want to hurt your eyes. Apparently certain color combinations cause eye strain but also make the contrast seem more intense.) Of course for programming the dark background is not usually pure black (either a dark shade or gray) and the foreground is a mix of pastel colors. For monospace fonts, light on dark seems at least as readable as dark on light for some reason. On the other hand non-monospace fonts use different techniques to make text more readable, so you can't compare websites and paper to IDE colors.

@kpars: How does the side output window work for you? Doesn't the text get cut off or wrapped a lot?
4  Discussions / General Discussions / Re: Do you customize your IDE (Eclipse?) on: 2013-09-15 22:51:19
Syntax coloring is not nearly as useful for identifying code at a glance as white space is. I put brackets on separate lines so that they are alined. It makes control flow structures easier and methods to see. Code that takes more than one line is indented by a slightly amount than the normal indent so it is visually obvious what is and isn't a continuation of a previous line. I also break the rule about CONSTANT_VARIABLES because, really... we have character sets with both upper AND lower case letters. Camel case is superior because it's easier to read and doesn't have underscores. Underscores introduce negative space that looks like white space which makes it harder to "visually parse" code while holding down the page down button or at a glance.

I also made new templates for things like System.out.println, the millesecond time, the nano second time, and System.exit. I plan to consolidate my commonly used utility methods and classes and find a way to automatically import and static import them, as well as the Math functions. I don't know where to start with that. I use templates a lot but only for a few specific things. I don't always consciously think about what to add, so I am sure I am missing good ones.

My preferred color system is light text on dark blue or black. I haven't "optimized" my syntax highlighting yet, but these styles seem to cause the least eye strain.
5  Discussions / Miscellaneous Topics / Re: RAM size on consoles: How did they make those old awesome games? on: 2013-09-15 18:30:56
The missing no glitch as well as many other glitches in Pokemon Red and Blue are examples of how limited memory was utilized. The same space that was used in a battle might be used for something else in a menu or in the overworld. This was why using Escape Rope in the Safari Zone let you catch Pokemon exclusive to that area in the Cinnabar Island water. Variables were only properly initialized if you got to the island without flying or teleporting. Its also why missing no corrupted your hall of fame records, why glitch Pokemon depended on your name, and why it only worked if you didn't surf to get to the island. Its also how you could catch Mew in game if you used a glitch while carrying a Pokemon with the right stats (or any other pokemon with different stats).

Variables were very tightly packed into memory. I don't know if space was located manually or done algorithmically. (Modern compilers essentially do the same thing with algorithms called register allocation. The number of registers are limited (and are faster to access), the same way RAM was, even though there is lots of RAM now, so similar methods can be used to move the location of variables as needed. Luckily good compilers for good languages spare us from register allocation while also guaranteeing correctness.)
6  Game Development / Newbie & Debugging Questions / Re: this. - code consistency and readability on: 2013-09-15 18:03:29
As a NetBeans user I take full advantage of warnings, autocompletion, and templates. You can make scope errors or redundant assignments (x = x instead of this.x = x) get highlighted as warning or errors, so it is not a practical problem. You can automatically generate getters, setters, and constructors if you declare your fields first, so it's not a problem. The default parameter name is the same as the field name and it uses this.

I prefer that parameter names, field names, and method names following "get", "set", and "is" all be the same. It's more readable when other people do it because it is consistent. It also helps NetBeans guess what variables to use as parameters if the names are similar.  If you don't want to use this for some reason, the style below can be an alternative. (I think it just makes code more confusing.)
1  
2  
3  
4  
public void setColor(Color newColor)
{
  color = newColor;
}


"this" should be avoided where its redundant because long code just creates more work for yourself and other programmers. An exception might be for equals and compareTo methods. I usually have code like "if(this.color != other.color) return false;"

If you prefix (or postfix) anything, then do so with the parameter names. Prepend "new" or _ or append a 0 or _.
7  Game Development / Shared Code / Re: The perfect solution to handling circle and rectangle collisions on: 2013-09-15 17:43:53
There are two types of collision tests. One where you move everything and say, "Since I didn't overlap with any objects before I moved and did not overlap with any objects after I moved, there must not be any objects between my last position and my next position to impede me." The other says "I know where I am and how fast I am relative to other object. I should see how far I can move before colliding with something."

Wikipedia refers to the former as a posteriori and the latter as a priori. Personally, I only consider a priori to be collision detection, though I know this is not the standard vocabulary. Collision is something that involves moving objects. If both objects are stationary, then it's an intersection test. (The special case of a point against another shape is called a hit test.)

If you use "intersection" or "hit test" in your search terms you will always get your intended topic (a posteriori). It's entirely different from collision tests and the strengths of the algorithms are different. It has applications in GUIs (non-games included) and may give you information you can't find / don't need from collision tests (like overlapping areas). Unfortunately people do not use the same vocabulary I wish every else did, so "collision test" yields a posteriori tests as well as a priori. A posteriori works for large, slow moving objects with short time steps. There are lots of serious flaws so common that players know them when they see them, like falling through floors, walking through walls, getting stuck in geometry, and unrealistic rebounds. There are work arounds, but it's like adding duct tape to a machine trying to do something it was never made to do. Eventually the work arounds are ten times as complex as an a priori algorithm and are usually slower. It leads to hard to track down bugs for programmers, mandatory hacks for level designers, and glitchy games for players.

Looking at collisions a priori saves a lot of development time in the long run and makes the game run smoother.
8  Game Development / Newbie & Debugging Questions / Re: User Controls dependent on graphic rendering loop? on: 2013-09-15 16:56:00
Use discrete time steps. Logic and rendering should be completely decoupled. It is not necessary to use separate threads to do so. Choose a graphics update rate (frame per second) and logic update rate (ticks per second). If TPS is greater than 30Hz or 20Hz, then just redraw every time you update. If TPS is less than 20Hz or FPS is at least twice as fast as TPS, then measure the time between updates (normalized to the range 0.0 to 1.0) to use for interpolation. I use complete integration of position, velocity, and acceleration when I need to, but linear interpolation works well enough. Interpolation may not be necessary at all if your FPS is high enough. The purpose is just to add extra frames if things do not look smooth. Whatever you choose, your rendering strategy should not affect the game's logic.

A single loop is enough to do rendering and updates. Just check to see if the current time is later than the next scheduled render or update time. (Make sure to use a while loop that adds time to the previously scheduled time and not an if statement that updates once and adds to the current time, or else you will lose time and update less than your normal rate. See the topics here about game loops.)

If you buffer/log input events (look at the relevant classes in LWJGL JavaDoc for an example) then you can do any operation like measure how long a key was pressed, know how early it was pressed, and know how many times it was pressed and released. It's a better solution than polling in your game logic. It can be done with Java2D as well since it is event based and gives you a timestamp of each event.
9  Game Development / Shared Code / Re: The perfect solution to handling circle and rectangle collisions on: 2013-09-13 17:46:45
I see that you're using the law of sines. That's pretty clever, I assume, but it's a long source excerpt so I will have to read and think about it for a while. I imagine that there is a shorter way, but it's not a collision type I have had to use recently, so I don't know how I would solve it either.

I noticed a user named ClickerMonkey asked, "I assume it's safe to say that the rectangle is stationary?" If I had an account at StackOverflow I would remind that user that collision between two moving objects can be solved by subtracting the velocity of one object from both objects' velocities and using a dynamic/stationary collision test with the new velocities. (Since one object's velocity becomes zero and the motion of the two objects are relative to each other.)
10  Discussions / General Discussions / Re: Eclipse Kepler automatic semicolon on: 2013-09-13 00:06:30
Dear god, it even puts in a semicolon if there is already one there. Idiots! It's seriously enough to make me try a different IDE.

It's a feature not a bug. Insert unnecessary condescending comment about programming skill. Flaunt 1337 skill in archaic computer environment. Insert another whiny condescending remark about good for nothing users not understanding what it's like to be a programmer.

Deer god, indeed. What's the purpose of the broken feature? I would like to know what makes whole teams of people think updates like that are ready for deployment while more useful and stable experimental features are normally disabled by default or at least treated more conservatively. IDEs, too, of all things!

Luckily you have the option to use an older version. And you don't have security or compatibility problems like web browsers force upon you if you choose to downgrade.
11  Discussions / General Discussions / Re: PathFinding with gravity on: 2013-09-12 23:50:42
What kind of path finding? Optimal or non-optimal? Do you need true path finding or just hazard avoidance?

Path finding with forces is hard because you have to account for velocity, increasing two or three dimension spaces to four or six. If you have a platformer where you can jump with no mid air control, then you can still use A* by treating jumps as graph edges and starting/landing places as nodes. Grid based solutions don't work because there is more than one way to get to a physical location and thus different places you could land by passing through a space at different speeds. This is why the search space has a higher dimension and the extra dimensional search space is what makes it more complex.

Rapidly exploring random trees can be used for path finding in higher dimensions. There is a good example on the web page documenting them. They give non-optimal and are non-deterministic, but are simple.

There is also the Mario AI contest. Some of the algorithms are based on A*. Much of the code is in Java as well as the "Infinite Mario" game it works with. There is a "famous" website and YouTube videos for one competitor in a previous year that illustrates how it works. I don't have the link but it is searchable.
12  Games Center / Showcase / Re: Logic Bomb on: 2013-09-12 23:22:32
The beginning levels are too easy. OR gates are easy because you just need to click really fast and AND gates are easy because one wire can be cut in addition to the same strategy that works for OR gates. Adding NOR, NAND, and XNOR gates would make the game much more challenging. One time a level began with 2 seconds remaining on the timer. I think it was lag but I did not experience 8 seconds of it. Combining not gates with gate inputs (and outputs) would also make the game more challenging because you would have to think about whether to cut a given wire instead of just jumping to cut everything.
13  Discussions / Miscellaneous Topics / Re: I HATE coffee on: 2013-09-12 00:53:04
If you want to be healthy you want to know what makes you gain weight, not what makes you lose it. (For simplicity, I say weight here when I mean unwanted unhealthy fat.) Calories are obtain through fat, sugar, and carbs. The difference is how they are digested and metabolized. You will gain weight by eating lots ice cream and soda no matter what the carb content is. Consuming a deficit of anything to induce weight loss is not healthy for everyday life. For it to be sustainable, you need to gain the weight back.

There is something wrong with a weight loss diet that doesn't force you to give up whatever you're dreading to give up, as attractive as it seems, when an everyday diet would. People either quit those diets or have to change how they eat. It's great if you're selling books or ads because it "works" at first, forces people to stop, and then people are eventually in need of a weight loss diets again. It would be one thing if you were to switch to a new diet when the first one ended, but people don't.

The second diet would necessitate people giving up whatever they were so relieved not to have to do so in the first diet. (Treat the cause, not the symptom.) No one gives things up because they convince themselves something else is the problem. (Disclaimer: There could be many problems; One change may not be enough; And, switching problems is not an improvement.) A serious cultural problem is that people associate weight loss diets with "healthy" and they do not associate bad things that are not the focus of a weight loss diet with being unhealthy. Just don't confuse yourselves by thinking whatever is advised/unadvised for weight loss is necessarily healthy/unhealthy.
14  Discussions / General Discussions / Re: SQL or Hashmaps for data storage? on: 2013-09-12 00:01:42
Sorry for saying SQL is easy to learn. What I meant was that it has a shallow learning curve for the basic features, sort of like JavaScript. All the disadvantages you listed are absolutely true, especially the clumsy syntax. (Exactly like JavaScript.) Select, insert, set, and delete get you very far, but not necessarily in an optimal way. A lot of open source web applications seem(ed) to primarily use those constructs. The exception was for projects like MediaWiki where complex queries were crafted for each specific database, presumably to get the best performance on each one. (Portability isn't good in SQL and performance requires knowledge of database specific voodoo.)

Different SQL databases have huge feature sets and it would take a whole career to know just one database inside in out. Some databases even let you define your own "functions", but that is something you can ignore until you get a teacher or mentor. Advanced features vary in function and syntax. Plus the syntax is really bad because some features were developed ad hoc. Select, set, and delete are conceptually simple if you understand the concept of an SQL query (the table specification, column specification, and where clause.) Insert doesn't involve many parameters, if any, besides the data you want to add.

The ability of SQL databases to index columns/keys could greatly improve performance over custom naive indexed data structures even if the user is a SQL novice (for certain applications). (Though SQL does make it easy to make security mistakes which is a good reason for novices to avoid it.) The difference would sort of be like switching from CPU rendering to (non-intermediate-mode) GPU rendering. Just utilizing the basic feature set may make it easier to process tons of data by making more efficient techniques more accessible. This is the reason I do not recommend it for game programmers, though. People think it's absolutely necessary for things like save files, where there would be less overhead to use a text format like JSON, CSV, or an ini-style properties file. Games just don't tend to involve record oriented data, so adding SQL doesn't have the same automatic benefit you might have for certain web applications.
15  Discussions / General Discussions / Re: SQL or Hashmaps for data storage? on: 2013-09-11 01:45:14
I am split because I want to say two opposing things without confusing anyone.

First, SQL is easy to learn. It is good for certain things, eg. deleting items associated with an ip range, finding items in a range, finding posts in a thread, returning the top N players, etc. It probably is better than trying to design your own system with an indexing system. HashTables and Lists won't suit you well because they won't be structure the same way a table can be. Just don't trust StackOverflow.

On the other hand, SQL doesn't seem to fit games well. You don't want to read and write to it during gameplay. Normally you want to structure your program to perform in a RAM cache conscious way. Uncached RAM access is slow, SQL is even slower because it involves IO. You definitely don't want it in a single player game. (JSON is my recommendation; not because it's my favorite format, but because it is a good choice when there is no obvious requirement that demands XML or something else, works well in most scenarios, and looks like Java/C++/C#.)

You probably don't want it in a real time game even if it is multiplayer. A lot of people jump to using databases because they think its What You're Supposed to Do (TM). They're clearly ignorant and just go to it automatically. When they try to fake knowledge, you can tell that they're just throwing jargon around. If you're not a database "expert", then stray on the side of not using them in critical routines. If you're neither a database expert nor an "expert" on hardware performance concerns, then definitely do not use a database. Try to handle everything in RAM. Avoid hard drive IO (and indirect IO through a database) until it's absolutely required.

A lot of big servers (in the general computing world) work by storing their entire database in RAM. If you think that defeats the purpose of a database because it's not persistent, then you shouldn't use a database. It's not the purpose and there are work arounds. I do not think most online games work on a single machine. There are several game servers that have to communicate just to maintain consistency. If there is a place for SQL that is probably it. However the SQL server probably runs on a dedicated machine. When the game is running, most of the data stays on the server the player is logged in to and user caps are used to prevent overload.

Got one computer? Don't know what the benefits of SQL? You don't need to learn SQL unless you want to. And, as with all performance related advice, performance isn't a concern until your computer runs out of time where its sleeping or until you hear grinding noise coming from non-solid-state hardware if you have any. Both of which probably won't happen unless you're very ambitious. If using your own method is easier in the medium time range, then it's a good idea.
16  Game Development / Game Play & Game Design / Re: [LibGDX] 2D (top down) procedurally generated terrain. on: 2013-09-10 21:19:05
At least find out which reference is null. Use a debugger or print something.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
      for (int x = x0; x < x1; x++) {
         for (int y = y0; y < y1; y++) {
            try{
                  tiles[x][y].getTile().draw(batch);
            }
            catch(NullPointerException e)
            {
                  System.out.println(x + ", " + y);
                  System.out.println(Objects.toString(tiles));
                  System.out.println(Objects.toString(batch));
                  System.out.println(tiles == null ? "..." : Objects.toString(tiles[x][y].getTile());
                  e.printStackTrace();
                  System.exit(1);
            }
         }
      }


Also, Hugo Elias's "Perlin noise" is not Perlin noise. Read Ken Perlin's presentation if you care what Perlin noise actually is. Simplex noise was also made by Perlin. Different types of gradient noise are often interchangeable and the concept behind the algorithms are simple, yet it is not necessary to know it. It is absolutely important to know what "Perlin noise" is NOT, so you can wrap your mind around the various totally different concepts people describe which people think are related to Perlin noise. Then you can look at the algorithms as something totally unrelated and just disregard the Perlin part, docking points based on how absurdly they get the terminology wrong.
17  Discussions / General Discussions / Re: AMD HSA... interested? on: 2013-09-10 00:31:30
Path finding cannot be parallelized on the GPU. Every thread has to execute the same instructions. Only the data can vary, not the control flow. (Though conditional instructions enable if/else by treating whatever branch that isn't taken is executed as a NOOP.)

I did not comprehend what the article was trying to say Java 9 would have. Would it be an API or would it work with old code where things like for loops are vectorized?
18  Games Center / Showcase / Re: Ten Second Sketch [Ludum Dare Jam Entry] on: 2013-09-10 00:17:44
My thoughts while playing this: Well this is fun. Okay I'm just holding the arrow keys down a lot but the levels will get harder. Oh, a tunnel level. More levels with lots of simple left/right turn sequences... This is more frustrating than I thought it would be.

It's not praise but here are the parts I think frustrated me: All jumps were the same height. There was no challenge to steering. (It was all about lining up the level or holding a button down in a spiral area.) The boost mechanism is hard to take advantage of and confusing. (The flame was not very visible.) There was only one way to "solve" a level. (Basically it is really frustrating if it feels like the game is about getting timing right rather than reacting in real time. If a level can be beat with your eyes closed after you beat it the first time, then the level is not very fun.) Finally, there are lots of levels with poor visibility.

The graphics were nice.
19  Games Center / Contests / Re: Discuss the future of 4k contest on: 2013-09-09 23:47:42
It was never a race. OEM and browser vendors choose who "wins".

(Although surprisingly my most recent laptop did not have Flash preinstalled even though it came with all kinds of other junk. So its not as if there is a perfect consensus.)
20  Game Development / Newbie & Debugging Questions / Re: [Java2D] How would I go for making buttons? on: 2013-09-09 23:37:03
The mouse location is a point. The button [is/should be] a rectangle. Search for point-rectangle intersection tests. A button can (but likely shouldn't) be any other shape, so infer what word you would change in the search terms if the button wasn't a rectangle.
21  Game Development / Newbie & Debugging Questions / Re: UDP and TCP on: 2013-09-09 23:28:28
I think there is a problem with with using TCP and UDP where using TCP delays or causes UDP packets to drop more frequently or something. If someone knows what that reason is I would also like to know.

Also, if you have the infrastructure to use acks in your UDP game what benefit does TCP give you?
22  Discussions / Miscellaneous Topics / Re: I HATE coffee on: 2013-09-09 23:21:13
I heard artificial sweeteners cause your body to store more calories as fat. Someone's summary of an article was that the brain thinks it tastes sugar, expects a dose of calories, finds out its scarce, so it stores more calories when you get them from other things. - That could also mean people think that because the soda is calorie free they don't have to watch other sources. Or it could just be statistical correlation between weight and diet soda drinkers. Journalism is sometimes the worst hop in the telephone game.

I stopped drinking soda a few years ago. I used to drink one or more soda a day. Then it got hot, so I brought soda and water with me for lunch so I wouldn't double my soda intake. Then it stayed hot and I did not have space for both. I happened to chose water because the bottle was bigger. It wasn't cold turkey. I just happened to stop by chance and did not even recognize it was bad to drink soda frequently. I didn't do anything radical, it wasn't painful for me to give up at the time, and it only took a couple weeks to lose interest in sweetened brown chemical liquid, but in retrospect the reason I drank soda was still addict behavior.
23  Game Development / Newbie & Debugging Questions / Re: removing objects when off-screen on: 2013-09-08 17:14:57
Load the entire level all at once. It will fit in memory unless your game is much, much bigger than I imagine it is. 1000 blocks should be around the order of several kilobytes. A megabyte is 1000 times larger than that and a gigabyte of RAM is 1000 megabytes of RAM. Collision detection and drawing will be the problem if you try to do it all at once. (Especially since collision detection could be O(n^2).) To narrow down the number of items to visible and nearby items, test if each items AABB overlaps a rectangle slightly larger than the visible area of the level. Items won't need to be discarded until the end of the level. You can leave them wherever they are when they go outside the rectangle or reset their position to where they started. You could sort items by their x position or divide the level into grids/chunks, but it might not matter. (Awesome name btw.)
24  Game Development / Newbie & Debugging Questions / Re: Why is java application running smoother when moving mouse over it? on: 2013-09-08 02:55:27
Whether a window has focus does not affect whether it receives mouse move events or not, so it would not change the effect whether your window had focus or not. Are you using the example in the first post? One problem I notice with it is that it uses outdated an interpolation value because repaint does not trigger painting immediately. Interpolation time should be calculated when the screen is painted, not later. I do not know if that is a problem in practice.

What type of "lag" is it?
25  Discussions / General Discussions / Re: Why is java not like heaven for AAA game companies? on: 2013-09-07 20:58:29
I don't disagree that LLVM is a better IR. I said there are flaws in the JVM and the same is true for the Java language.

If you wanted to make JIT compilation or run time profiling part of your final distribution, just do it before it reaches your customer. Supposing your game was deterministic, why could you not what technical constraint prevents you from hypothetically reusing trace information from a PC and sharing it with a different PC, a tablet, or a console? Testing and profiling is part of the development process, why not make it part of the build process? The same statistics could be reused on multiple machines. You could put compiler hints in comments or annotations or in a type of byte code.

You could do what Microsoft did to address long boot times. (The first time you run Windows on new hardware it takes a long time to boot. After it successfully boots it dumps RAM to the hard drive and loads certain parts the same way it would as restoring from hibernate.) You could have console game programmers (or PC programmers since Java for consoles would presumably still be cross platform) do incremental stress tests and dump the results of JIT compilation to a format that a console can read. You could even strip away the dynamic portions of the JRE the same way you do with support structures with clay and plastic 3D printing models while they are still being built and before they harden. (You would have to get rid of reflection and disable the optimistic HotSpot optimizations that require deoptimization if an exceptional case is found, but those aren't used in console games anyway.)

Normally people insist that AOT compilers are a more practical way to do anything a JIT does. You don't hear people argue very often that if given the amount of compilation time that console developers get you could not reproduce with AOT what JIT gives you.

If console developers collectively wanted to use Java they probably could make something happen. There are flaws in every language and Java's are mainly things that can be avoided if you are willing for your performance critical code to look more like C code than clean Java code. Of course it still might not be worth it. Personally I would invest the energy in a new language because there is still lots of room for improvement over all existing languages.
26  Game Development / Newbie & Debugging Questions / Re: Weird render glitch? on: 2013-09-07 17:37:57
Your scaled image is not a multiple of three pixels wide or tall.
27  Discussions / General Discussions / Re: Why is java not like heaven for AAA game companies? on: 2013-09-07 17:06:54
Java programs do not run in a VM any more.

Patent nonsense.  The JIT compiles methods that have run several thousand times, and it uses the tracing information it collects during bytecode execution in order to do so.  That's why it methods in the server VM require more calls as bytecode before they're ever compiled.  And it's still designed to back out to bytecode whenever it needs to, such as in the face of new overloads appearing.

JVM Bytecode is starting to resemble something like an IR, but that doesn't mean it is one.

Okay, you're right because there is an interpreter in HotSpot. That said, the majority of the time it won't be in use and really doesn't need to be used at all. Its not that much different than having a scripting engine and 1000 is a small number in the computer world. Of course that is how HotSpot treats Java bytecode. Not every platform, device, or compiler does it that way. You wouldn't just port HotSpot and call it good.

For future reference I will try to look to see if the interpreter works on an instruction level or method level. For tracing information you only need to watch which branch is taken, so you do not necessarily need to emulate a CPU to get that information. How IR is used does in one part of one program does not change the fact it is IR. LLVM has an interpreter and bytecode may be used as IR for Android and GCJ.
28  Game Development / Shared Code / Re: Printing Matrices on: 2013-09-07 16:11:20
That is pretty cool. In case anyone does not realize, you can define a custom variable formatter for use in your debugger or watch window. You just need something that returns a String instead of printing it.
29  Game Development / Newbie & Debugging Questions / Re: Using System.gc on: 2013-09-07 03:37:11
I just called System.gc() because im scared of android memory cap Tongue

It won't help. Available memory is either there or not. If there is no slot known to be reclaimable then garbage collection gets triggered, at the moment you call new, to find such a space. Space does not need to be free ahead of time. GC is normally done on demand.
30  Game Development / Newbie & Debugging Questions / Re: Creating my own Timer ( libgdx) on: 2013-09-07 01:26:34
Thanks for the responses. I will read them more thoroughly later.

Common scenario for beginner programmers:
You want to hide a sprite after N time. You end up writing some timer code to do that:
1  
2  
3  
if (mysprite.isVisible() && myspriteTimeElapsed > myspriteDuration) {
   mysprite.setVisible(false);
}


As your game grows, you want to apply this to other sprites. Then, maybe you want to affect other attributes over time, like color or position. Eventually you end up with a lot of "spaghetti code" and lots of copy-pasting.

Well I would not use static variables. I already have a entity class that stores other instance specific state data.

1  
2  
3  
4  
public void update(long ticks)
{
  if (isVisible() && ticks > scheduledInvisibleTime) setVisible(false);
}

Of course it is not spaghetti code at all. There is no change in control flow beyond an if or while statement. There are no function calls to a function or callbacks unlike with additional objects. There is also no spooky action at a distance effect, so it would be much easier to debug.
 
If you decide to change your timing function later on (for example, to support easing functions) then you will have a lot of tedious refactoring ahead of you.

On the other hand, if you had just used classes from the beginning, you would only have to change a few lines of code.

The point is to think abstractly when designing a game architecture. If you are implementing a feature, like fading a sprite out over 1.0 second, think about how you can abstract it. Then, the abstraction can be re-used through other parts of your application.

Here is a practical example of a basic timer with easing functionality:
https://github.com/mattdesl/cisc226game/blob/master/SpaceGame/src/space/engine/easing/SimpleFX.java

(In LibGDX it would be best to use their Interpolation, Actions, or Timer utilities depending on your needs.)

If I chose a unit of time I would never change it in the middle of my project. I use ticks for state updates and floating point (delta) time for graphics. I integrate velocity and acceleration to get interpolated sprite positions between updates. draw(tick, 0.0f) draws the object where it is as of the last update and draw(tick, .9999999f) draws it where it will be at the beginning of the next turn. If an easing function can be expressed as a function of time I just take the difference between the current time and a timeStamp which gives me t for f(t).

If I want to make a satellite fly across the sky, blink, and change color I do this, what would you do?

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
public class Satellite extends Entity
{
  private final long startTime;
  private final double colorPeriod;
  private final double blinkPeriod;

  public Satellite(double x, double y, double colorPeriod, double blinkPeriod, long tick)
  {
    this.x = x; this.y = y;
    this.vx = 4;
    this.vy = 1;
    startTime = tick;
    this.colorPeriod = colorPeriod;
    this.blinkPeriod = blinkPeriod;
  }

  public void update(long tick)
  {
    x += vx; y += vy;
  }

  public void draw(long tick, double delta)
  {
    // If either of these were not a one liner, it would go in a static function or enum.
    double hue = 360.0 * ((tick + delta) % colorPeriod) / colorPeriod;
    double lightness = square(sin((tick + delta) / blinkPeriod));
    // Not functions from a real library. I will eventually stop using Java2D.
    setHSLColor(hue, .75, lightness);
    drawImage(x + vx * delta, y + vy * delta);
  }
}
Pages: [1] 2 3 ... 5
 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

trollwarrior1 (29 views)
2014-11-22 12:13:56

xFryIx (71 views)
2014-11-13 12:34:49

digdugdiggy (50 views)
2014-11-12 21:11:50

digdugdiggy (44 views)
2014-11-12 21:10:15

digdugdiggy (38 views)
2014-11-12 21:09:33

kovacsa (62 views)
2014-11-07 19:57:14

TehJavaDev (67 views)
2014-11-03 22:04:50

BurntPizza (65 views)
2014-11-03 18:54:52

moogie (80 views)
2014-11-03 06:22:04

CopyableCougar4 (80 views)
2014-11-01 23:36:41
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!