Hey Everyone! I’ve been gone for quite a while, reason being I’ve been caught up in classes, got a promotion at work, and in the middle of a move. But mainly because I’ve been designing several game consoles, using the Z80, an STM32, and even a couple of PowerPC 750s. However, that’s beside the point. In a 2D game I’m working on, the map loader for it reads an image file and generates a level out of it. The thing is, when it reads a tile data and generates a sprite sheet, the game crashes with an Index Out of Bounds Exception.
The broken part is that when I used debug mode and step through the code, the game loads the tile sheet with no issues. The with print line statements, in the code where the sprite sheet is loaded in, the array size says it’s 400 or so, but when the game jumps out of that code, it says that same array is 0. This does not happen when I step through the code manually. It also does not happen if I have the game load in the whole sprite sheet for every sprite created, but obviously this is super slow. I fixed the glitch by just having every sprite share the same sheet, which gets created when the game starts. So in short:
Create a sprite sheet using a pre-loaded image: Crash
Create a sprite sheet by loading in the images every single time: No Crash
Create one sprite object, and have new sprites copy it’s sheet data: Crash
Have every sprite share the same sheet: No Crash
Manually step through the code: None of the above methods crash.
-Read tile data
-Jump to sprite generator
-Array Size: 400
-Return from sprite generator
-Array size: 0 (stays at 400 if manually stepping)
-Use the sprite data: crashes
What I think is happening is somewhere along the code the Array for the sprite sheet is stored in cache somewhere, but is not visible to the rest of the code. I don’t know, I just found it very weird.
I’ve done that already and fixed the issue. I just find it weird that the exception happens when I let the program run on its own, but it doesn’t happen when I manually step through the code in debug mode.
I broke Java again. So I’m working on a 3D game also, using the JME SDK, and I have to use a library I made for a post processing filter. I imported the jar file like I normally do, but the IDE refused to let me use the classes in that JAR file. Like the SDK didn’t acknowledge the class’s existence. So I had to copy the code from the library into the game’s source code itself. Has anyone else come across this problem?
I’ve done all three of those, and also closing and reopening the project, restarting netbeans, clearing the cache, was tempted to reinstall it bu I got lazy and just copied the code. I swear I’m the king of breaking things
The thing is the JAR i’m trying to use I’ve successfully used in previous projects, it’s just this one in particular where it acts like it ins’t there. But it would probably be helpful if I gave a screenshot
I don’t know how I didn’t notice that, I’ve been using the wrong jar file this whole time! And about the package name, I made that “library” a looooong time ago, before I started doing programming classes and learning proper naming conventions. Before then I had a strange habit or always capitalizing my package names. I still do it actually