Java-Gaming.org Hi !
Featured games (85)
games approved by the League of Dukes
Games in Showcase (616)
Games in Android Showcase (173)
games submitted by our members
Games in WIP (659)
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 ... 44
1  Game Development / Newbie & Debugging Questions / Re: Better way to store a massive amount of variables on: 2015-09-05 06:46:03
Few hundred lines of code of getters and setters is messy? At my work there is a C++ class, and the header is like 800 lines of code, while the implementation is like 5k or even more. It is pretty much a getter setter class, but I guess you would call it whole other level. I wouldn't call it hard to maintain, because all it is one huge file and nothing more. If you actually need to add / modify something, you are only probably going to look at functions that are no more than 50 lines of code.

There is another class though which is also like 5k lines of code. That class is impossible to maintain if you happen to need to edit something that you shouldn't have. If after you edited something you start getting assserts (thank God at least the class has some of those), you can prepare to go on a long hours journey fixing code that was written assuming no one would ever again touch it. All the code is spaghetti and all the functions depend too much on each other, so in the end it seems like it is few very very big function, even though it has like 100 functions. It has all kinds of code - 2D point path to 3D point path generation, economy logic that is associated with that class and much much more that I'm not sure how to describe. Long story short is should have been long split up into many smaller classes.
2  Game Development / Newbie & Debugging Questions / Re: Grid-based entity collision issues on: 2015-09-03 06:56:20
For debug purposes, try adding a collision check after you have done all your movement code. If the unit doesn't collide before moving, but collides after moving, throw an exception or something and you will know that you made an invalid move.
3  Discussions / Miscellaneous Topics / Generating .java file before compilation during build time on: 2015-09-02 07:33:31
Right now I have 2 build targets: GooglePlay and Amazon. In the Java code, the code has some checks to see what it should do based on the build type. The problem is that each time you want to build for Amazon, you have to manually edit the source Java code to change the build type to Amazon. What would be the best way to generate a .java file during build time, before Java code is compiled? I guess I'm looking for something like Android, which generates R file, which you can access from code.
4  Discussions / Miscellaneous Topics / Re: What I did today on: 2015-08-28 20:42:32
.. got surprised by how smooth the windows 7 build-in "backup and restore" feature works. \o/

Guess they had to make it work properly, because of how much everything breaks in Windows. Cheesy
5  Game Development / Newbie & Debugging Questions / Re: Game has a bunch of short pauses on: 2015-08-28 20:36:15
Maybe you could try recording these short pauses?

EDIT-
I wasn't implying that you have GC pauses, I just described what big GC pauses are caused by. Also, I'm not sure about this, but 200kb of garbage doesn't really mean anything. For all you know you might be allocating two 100kb arrays, or thousands of small objects which would be slower for GC to clean up than a couple of arrays.
6  Game Development / Newbie & Debugging Questions / Re: Game has a bunch of short pauses on: 2015-08-28 06:24:42
Big GC pauses are caused by having a huge heap and a lot of garbage objects being generated.
7  Game Development / Newbie & Debugging Questions / Re: Multiplayer game on Android on: 2015-08-27 09:17:08
I would wonder if it is OK to host a server on a mobile phone. I don't have much MP experience, but I don't think it would be a very good idea to host a server on a phone, unless it is a very small server.
8  Discussions / Jobs and Resumes / Re: [3dFoin] Zombie and August Sale - 50% off all items :D on: 2015-08-24 19:35:20
How is he able to lean backward and forward without having any ABS? Cheesy
9  Game Development / Newbie & Debugging Questions / Re: 2D-MMORPG physics engine on: 2015-08-04 16:57:41
It depends on what you need. I guess for 2D you can go and write your own physics engine, as long as it doesn't include rotations. It also depends on how you want the objects to interact. Though I doubt that you will run into performance problems on modern PCs with Box2D when only having few hundred objects. You should just try to setup a test and see how well it runs.
10  Game Development / Newbie & Debugging Questions / Re: My map load parser is taking ages on android on: 2015-07-29 10:22:34
If you are using Eclipse, there is a Trace View in DDMS Layout. Look at answer by Seppl
http://stackoverflow.com/questions/4850974/how-to-use-traceview-in-eclipse-for-android-development

It will show you how much time was spent executing parts of your code.
11  Discussions / Business and Project Management Discussions / Re: TheGreyLab Development Team Recuritment on: 2015-07-15 08:11:26
Would be nice if you could post a short demo video to show the state of the project.
12  Game Development / Newbie & Debugging Questions / Re: JNI threading > JNIEnv memleaks on: 2015-07-01 04:53:28
Yes, DeatchCurrentThread is being called after every call to Java.

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  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
class JNIThread:
{
   public:

   ~JNIThread()
   {
      jvm->DetachCurrentThread();
   }

   bool Attach()
   {
      switch (jvm->GetEnv(m_pEnv))
      {
        case JNI_OK:
           // Thread is ready to use, nothing to do
        break;

        case JNI_EDEATCHED:
           // Thread is detached, need to attach
           jvm->AttachCurrentThread(m_pEnv);
           // AttachCurrentThread probably also returns control value, whether it was a success
        break;
      }

      if (m_pEnv != NULL)
      {
        // If not null, means ready to use
      }

      return m_pEnv;
   }

   JNIEnv* m_pEnv;
}



// Using
funcion
{  
   JNIThread thread;  

   if (thread.Attach())
   {
      // do work
   }

   // thread is detached in destructor
}
13  Game Development / Newbie & Debugging Questions / Re: JNI threading > JNIEnv memleaks on: 2015-06-30 05:47:35
Are you sure that doing ->AttachCurrentThread spawns a new Java thread? I thought it only passes JVM context to your current thread, so that JNI calls are possible from that thread. At my work every call from native to Java (On android) tries to attach the thread if it is not yet attached. I think the code looks something like this:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
JNIEnv* getJNIEnv()
{
   JNIEvn* pEnv = NULL;

   switch (jvm->GetEnv(pEnv))
   {
      case JNI_OK:
         // Thread is ready to use, nothing to do
      break;

      case JNI_EDEATCHED:
         // Thread is detached, need to attach
         jvm->AttachCurrentThread(pEnv);
         // AttachCurrentThread probably also returns control value, whether it was a success
      break;
   }

   if (pEnv != NULL)
   {
      // If not null, means ready to use
   }

   return pEnv;
}


Though this probably won't compile, I didn't write the code, not sure what are the exact parameters.
14  Games Center / WIP games, tools & toy projects / Re: Mr.mustache on: 2015-06-16 17:51:36
I think the first thing you should add are wiggling mustaches when pressing S.
15  Game Development / Newbie & Debugging Questions / Re: Best way to save game for a Dungeon Crawler? on: 2015-06-09 09:38:39
If you have never done any serialisation before, I would suggest that the easiest place to start would be using .json.

.json is a tree data structure, in which nodes can have branch nodes of leaf nodes. Simply put, a branch node is a node that contains other branches and leafs, while a leaf node is like a leaf in a real tree. A leaf node might be a string, or an int, float etc. Not going to go into details, you can read more about it on the internet.

http://json.org/

The implementation would look something like this:
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  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
public class Level {
   private ArrayList<Entity> entities;

   public JsonObject getSavingJson() {
      JsonObject json;

      JsonArray jsonEntities;
      for (Entity entity : entities) {
         JsonObject jsonEntity = entity.getSavingJson();
         jsonEntities.add(jsonEntity);
      }

      json.add("entities", jsonEntities);

      return json;
   }

   public void loadFromJson(JsonObject json) {
      JsonArray jsonEntities = json.getArray("entities");

      for (int i = 0; i < jsonEntities.size(); i++) {
         JsonObject jsonEntity = jsonEntities.get(i);

         String type = jsonEntity.getString("type");

         Entity entity = null;
         if (type.equals("Entity")) entity = new Entity();
         // else if (type.equals("Player")) entity = new Player();

         entity.loadFromJson(jsonEntity);
      }
   }
}

public class Entity {
   
   private String type = "Entity";

   public JsonObject getSavingJson() {
      JsonObject json;

      json.add("type", type);

      // additional stuff
//      json.add("position", position);
//      json.add("health", health);

      return json;
   }

   public void loadFromJson(JsonObject json) {
      // load your stuff here
//      position = json.get("position");
//      health = json.get("health");
   }
}


16  Games Center / WIP games, tools & toy projects / Re: Flying Cavemen - Inifinite Scroller [LibGDX][Web] on: 2015-05-16 05:16:21
It starts running normally (it seems) and then after the first try or something it seems like it slows down the same like the web version. Maybe you have leaking memory?
17  Games Center / WIP games, tools & toy projects / Re: Flying Cavemen - Inifinite Scroller [LibGDX][Web] on: 2015-05-15 20:19:19
Chrome. My hardware isn't that ancient either. Its not great, but I can play some current gen comes pretty well on low settings. (CSGO, KSP and some others)
18  Games Center / WIP games, tools & toy projects / Re: Flying Cavemen - Inifinite Scroller [LibGDX][Web] on: 2015-05-15 20:11:09
The performance is horrible. I had like 2 fps.
19  Game Development / Newbie & Debugging Questions / Re: Trying to make an object that has a sort of parent object. on: 2015-05-03 14:58:15
Hm, they really should add sroll bar to long lists of code.

Or you should use a pastebin for extraordinary long code dumps.

Quote
Got extraordinary long code dumps? Use http://www.java-gaming.org/index.php?action=pastebin&hex= to keep your thread readable. (link opens in new tab)

20  Java Game APIs & Engines / Engines, Libraries and Tools / [Libgdx] adding a source folder to build path on: 2015-05-03 10:01:46
I was trying to find how to add an additional source folder to gradle build path on google, but I seem to have failed.

Does anybody know how to add source folder to gradle build path?
21  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [LWJGL] Library for rendering text. on: 2015-05-03 09:58:26
(this is kind of self-advertising)

I have made this library that will render text using FreeType in native code. The problem is that it only is available on WINDOWS, ANDROID and the .dll files take up a lot of space (9mb for windows alone).

https://www.mediafire.com/?r8uki5mk83uag1i

If you want the source code, or if you want to try to contribute:
https://github.com/gamingchris3/jfreetype

Here is some 'example' code.

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  
32  
      JFreeType jfreetype = JFreeType.createInstance();
     
      jfreetype.initialize(true); // the parameter is whether JFreeType should attempt to load native files itself
      // if you pass in false, you need to load native files yourself.
     
      JFreeTypeOptions options = new JFreeTypeOptions();
      options.font = "C:/path/to/font.ttf"; // full path to font file on the file system
      options.text = "A generic string of text"; // the string of text you want to render
      options.size = 20; // the size of the font
      options.width = 10000; // the width at which the size of the font will be reduced if the string is bigger than this number
      options.height = 10000; // the height at which the size of the font will be reduced if the string is bigger than this number
      options.lineSpacing = 0; // when wrapping text, spacing between lines (in pixels)
     
      Bitmap bitmap = jfreetype.render(options);
      int format = bitmap.format; // this can be ignored, right now the only format is alpha (1 byte alpha)
      int width = bitmap.width; // the width of the texture
      int height = bitmap.height; // the height of the texture
      ByteBuffer pixels = bitmap.pixels; // a byte buffer of pixels (the format is 1 byte alpha)
     
      TextMetrics metrics = bitmap.textMetrics; // contains some metrics generated from rendering the string
      int descender = metrics.descender; // the maximum descender of the string
     
     
      jfreetype.setInstantLoggingEnabled(false); // if instant logging is enabled, will print errors / info instantly to default output stream
     
      // If instant logging is disabling, will 'buffer' the messages (up to 128)
      String error = null;
      while ((error = jfreetype.getLog()) != null) {
         System.out.println(error); // prints out error messages?
      }
     
      jfreetype.destroy(); // cleanup?


On the final note, if you decide to try this lib, and something doesn't work, you might want to just drop it entirely, as this is not really a production level library yet.
22  Discussions / Miscellaneous Topics / Re: What do you define as a programming language? on: 2015-05-01 18:31:28
I would say to me a language is when you can write a 'compiler' for that 'language' using that 'language'.
23  Games Center / WIP games, tools & toy projects / Re: Tower Defense prototype on: 2015-04-30 08:41:19
@jonjava

I guess I compiled one of the jars with the latest JDK, while the game jar itself was compiled with an older version. Which version of JRE/JDK are you using right now? (The jar that causes the error was compiled with 1.8 or something)

EDIT---
Anyway, I will recompile the jar once I get home today and update the link so that people without latest java version can run it! Smiley
24  Java Game APIs & Engines / Java 2D / Re: Would appreciate if someone would critique my first game. on: 2015-04-29 18:54:07
The death sound really surprised me. Compared to the menu click sound, it was way loader.

It shouldn't ask you to enter your name after each time you die and want to play again. The 'default' way to make highscores is to allow the player to 'submit' their highscore after they finish playing and ask their name right then.

The paddle has some weird bug when it touches the ball with it's side, though I didn't think it was that bad. Its kind of nice that the ball comes back up when you hit it with its side Smiley

I would say its a nice little game you made Smiley I enjoyed playing it for couple of minutes.

25  Games Center / WIP games, tools & toy projects / Tower Defense prototype on: 2015-04-29 17:24:55
I started making this isometric tower defense prototype. This is not supposed to be a full game, but rather a play ground to try to find different code structures than to what I'm used to and get a better understanding of isometric game programming.

I also wanted to test text rendering library that I made on more machines. If the application doesn't work, please paste the stack below Smiley

So far all I have made is a 20x20 tile level. You can increase / decrease elevation by pressing X and C on the keyboard, which will change the elevation of the currently hovered tile. You can also place buildings by dragging a mouse while holding down left button and selecting some tiles. If you want to delete the building, right click on the building and it will be removed. Right now there the following patterns for buildings: 1x1, 2x2, 3x1, 1x3.
You can move using ASDW.

The prototype is very NOT optimized performance wise, so there might be performance drop on machines that don't have a proper graphics card (I had huge FPS drop on laptop with integrated-in GPU).

On the final note, this is only supposed to work on WINDOWS for now.

Here is the link. Just extract the folder to wherever you want and run the td.jar file inside!
http://www.mediafire.com/download/29ih1s6wln0al80/export.zip

--edit
whoops i just realized i put to .rar so now i changed link to .zip

26  Game Development / Newbie & Debugging Questions / Re: [LibGdx] Best way to handle textures for hundreds of objects? on: 2015-04-28 14:10:12
Have something like an asset manager that has stored all textures in a hashmap or a list and you can do AssetManager.getTexture("somettexture.png"); which would return a texture.
27  Game Development / Newbie & Debugging Questions / Re: Getting started with game programming on: 2015-04-28 13:38:31
You could start trying Libgdx first, since it is much higher level framework and it is easier to see the first results of your code, and once you are comfortable with it, you could try using LWJGL, even though Libdgx might still be a better options than LWJGL in most cases.
28  Java Game APIs & Engines / Engines, Libraries and Tools / Re: LibGDX drawing of sprites? on: 2015-04-27 05:25:14
When SpriteBatch reaches it's limit, it will automatically flush and begin a new batch. You shouldn't worry about this though, as the batch will need to be flushed on many other occasions, such as changing shaders, changing uniform variables in the shaders and many more.

EDIT---
If your game doesn't have more than 100 draw calls per frame, I don't think you have to worry about anything yet. You could probably have up to 500 or 1000 draw calls and game would still run at  60 fps on not very good machines.
29  Game Development / Game Play & Game Design / Re: Inventory and sorting on: 2015-04-27 05:21:50
Why not use both? Smiley

I think in Minecraft you can click to transfer items automatically and drag them manually.
30  Game Development / Newbie & Debugging Questions / Re: Java2D fillRect() memory leak on: 2015-04-23 05:22:06
Do you get out of memory error eventually?
Pages: [1] 2 3 ... 44
 
Coldstream24 (18 views)
2015-09-03 00:41:28

Andrew_3ds (29 views)
2015-09-01 19:08:10

afikri (20 views)
2015-08-31 09:30:22

afikri (26 views)
2015-08-31 09:30:07

afikri (14 views)
2015-08-31 09:27:24

afikri (17 views)
2015-08-31 09:26:40

Roquen (30 views)
2015-08-29 11:30:54

GamerC4 (38 views)
2015-08-22 20:38:50

GamerC4 (36 views)
2015-08-22 20:37:18

GamerC4 (42 views)
2015-08-22 20:37:01
HotSpot Options
by Roquen
2015-08-29 11:33:11

Rendering resources
by Roquen
2015-08-17 12:42:29

Rendering resources
by Roquen
2015-08-17 09:36:56

Rendering resources
by Roquen
2015-08-13 07:40:51

Networking Resources
by Roquen
2015-08-13 07:40:43

List of Learning Resources
by gouessej
2015-07-09 11:29:36

How Do I Expand My Game?
by bashfrog
2015-06-14 11:34:43

List of Learning Resources
by PocketCrafter7
2015-05-31 05:37:30
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!