Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (804)
Games in Android Showcase (237)
games submitted by our members
Games in WIP (867)
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
1  Java Game APIs & Engines / Engines, Libraries and Tools / Re: [libGDX] Subpixel smooth spite movement on: 2019-03-28 10:09:34
But when I add sprite to code and start to move that sprite across tilemap it turned out that it moves only in pixel intervals.
(e.g. i can't move that sprite in 1.5 pixels).


Maybe someone know how can smooth sub-pixel sprite movement can be achieved with that upscaled approach?

Well, that doesn't work because the upscaling/scrolling is done as a post-render effect, using the final frame rendered in low resolution.

I did a brief experiment with rendering "kind-a sub-pixel moving" sprites a while back. It's... difficult. One approach I tried is to render moving sprites into a separate frame buffer, at higher (4x, 8x) resolution, and then blend it accordingly before (final scene composition) or during the upscale/smooth-scroll render pass. My results were.. mixed. It looked quite promising, but at some point you are starting to fight with blending artifacts.

I believe the "easiest" method would be to render moving sprites at a scale matching the upscale factor. e.g. if the upscale shader does a x3 scaling, render the sprites into a frame buffer 3x the size of the primary render buffer. Then, in the upscale shader, mix/mask background with sprites, but before subsampling. That would not give you true "sub-pixel", but just "1/3 pixel" movement for sprites.
2  Games Center / WIP games, tools & toy projects / Re: Labyrinth Quest - A text-based roguelike on: 2018-09-14 07:15:33
My aim with this project isn't so much as to push out a game as it is to learn the ins and outs of Java as well as the conventions that come along with it.

As we talk about conventions..  you should accustom yourself to properly "break;" your switch statement blocks. Many of them are not, and w/o having more insight to your code I can only assume that's a bug in most cases.

This means to:

- "break;" every case, even the last one. If you add another case, and forget to adjust the now-not-last-anymore block, you are in trouble
- if the fall-through case is intended, I prefer to leave a comment at the place to remind future-me or any other passer-by about it
- the only exception is if the block ends with a return statement -> the break only adds visible noise in this case
3  Game Development / Newbie & Debugging Questions / Re: Collision works one way, but not the other on: 2018-09-12 23:58:23
Your issue here is that this check is not only true for intersecting the block from the right, but also for every other playerX smaller than (blockX + paintWidth):

if (game.player.playerX < blockX + paintWidth) {
   game.player.playerX = blockX + paintWidth;

You probably want to do something along this:

if ((game.player.playerX > blockX) && (game.player.playerX < blockX + paintWidth)) {
   game.player.playerX = blockX + paintWidth;

... and

if ((game.player.playerX + Player.PLAYERWIDTH > blockX) && (game.player.playerX + Player.PLAYERWIDTH < blockX + paintWidth)) {
   game.player.playerX = blockX - Player.PLAYERWIDTH;

4  Game Development / Newbie & Debugging Questions / Re: Listing classes from a package on: 2018-09-08 13:56:03
Here's the one I use:

Example of use:

It's a rather slow operation, so I usually do this only once and cache the result.
5  Java Game APIs & Engines / Engines, Libraries and Tools / Re: libgdx + textureatlas too many render calls on: 2018-05-20 07:25:00
I believe you are on the right track, but I suggest you to approach the issue more ... "analytically". Use the debugger. Run the game, put a breakpoint in SpriteBatch.flush(). You are interested in any calls which are not from SpriteBatch.end(). Have a look at each and figure out why they happen.

they can be caused by changes to:

- shaders
- textures (pages for an atlas, if atlas size too small to fit all regions in one page)
- render states (blending)
- uniforms (transforms)
- batch buffer too small

edit: One note about your latest remarks: kind of hard to tell w/o knowing how it looks like, but if your font bitmaps aren't part of an atlas, and if your UI uses a lot of text as well as other elements, you got your render calls right there. That'd be one flush for each UI actor which needs to display both some regions/patches and text.

Also, if atlas size is of concern, one possible solution is to put fonts and UI bitmaps into one atlas, and anything else into another. You flush/change batches anyway from world to UI. It's only important to not reference one from another, e.g. trying something fancy like rendering world sprites inside the UI.
6  Discussions / Miscellaneous Topics / Re: What I did today on: 2018-03-29 09:02:03
Rewrote the threading system...

Yep, threading is fun. Found a race condition in our asset loader thread yesterday, which happened *occasionally* to the other coder on the project. I've never been able to reproduce on Windows or Mac OS. Tried to test and debug an unrelated feature on Ubuntu, and lo and behold, bug triggered every other run.
7  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Steamworks4j - just starting out on steam and have a few questions on: 2018-02-01 14:44:51
Congratulations, you found a weak point!  Grin

You need to call SteamAPI.init() first. The problem is that this function does two things: loading the native libraries, and calling native SteamAPI::init(). Now it is legal to call restartAppIfNecessary() before init(), but the Java wrapper doesn't allow this .. yet. It's fixed already in 1.7.1-SNAPSHOT.

edit: in case you try to use the snapshot build, the correct order will be (omitting error checks):

8  Java Game APIs & Engines / Engines, Libraries and Tools / Re: Steamworks4j - just starting out on steam and have a few questions on: 2018-01-31 15:01:33
A1) I'm biased obviously, but one primary goal of steamworks4j is to stay as close as possible to the C++ API. So maybe it's not the *easiest to use* solution on the planet, but should allow you to follow any documentation you can find about the C++ SDK, or even Steamworks.NET (which uses a similar approach for C#).

A2) I wasn't aware until now, but apparently you can use the SpaceWar AppID (480) to start testing w/o being a registered developer first.

A3) To get started, the documentation is publicly available now:

A4) Yes, there's a developer forum you'll get access to when accepted. Tons of questions, and sometimes even a useful answer. Wink

A5) Only the usual PC/Java/AV-software shenanigans if you ship with a bundled JRE (and optionally a launcher like packr). Nothing specific to Steam.

A6) I don't think so. This may need a separate service to collect the data (via their Web API, for example), and publish it to some self-hosted web page.
9  Discussions / General Discussions / Re: Move to Kotlin? on: 2017-11-16 10:27:21
a language shouldn't need a specific IDE to be adequately grokked (it's like there's a link between Kotlin and Intellij or something!  Grin )

I beg to differ. I started to look into building some small DSL with Kotlin, and I find it incredibly helpful to get that much assistance.
10  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-09-26 11:18:04
@CoDi^R: You say it like the Dark Side is a bad thing  Grin

Not at all! But as every Sith lord knows: it's a fine line between ruling the galaxy and going nuts.  Wink
11  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-09-26 10:26:15
I really think one of the things Java lacks most is operator overloading. Because it's so fancy.

12  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-09-22 12:10:44
It's still ZIP files. I can rename them to *.zip, then use the 'unzip' cli to unpack. It warns about "4 extra bytes at..." though, so they probably just customized (obfuscated) the header a little. Just enough to irritate the OS X Archive Utility...  Roll Eyes
13  Game Development / Networking & Multiplayer / Re: Steam and Kryonet? on: 2017-08-16 15:22:07
Unfortunately you can't test Steam features without getting on Steam, which is a bit of a bugger.
I'd advise not using the Steam network APIs if you can help it and make something that works everywhere.

Cas Smiley

Yes, if I had to, I'd try to build some kind of generic interface and treat Steam networking as yet another implementation. Even if only for testing purposes, because it's a pain already to just test some simple networking functions with multiple Steam accounts.
14  Game Development / Networking & Multiplayer / Re: Steam and Kryonet? on: 2017-08-16 15:17:05
Quote from: tommohawkaction
Ah does this mean I don't have to worry about port forwarding?

So they say.

Quote from: tommohawkaction
Also would i be able to use Kryonet with Steam?

I don't know Kryonet, so I can't answer that. Essentially the Steam P2P API boils down, after initial connection/negotiation, to two functions, "send message to another Steam user" and "receive message from another Steam user", which work with byte data. I can't tell if you can dock Kryonet on top of that.

Quote from: tommohawkaction
Also does P2P work with multiple users (MAX 4)

Sure, but you'll have to manage yourself what messages are sent to which user(s).

Quote from: tommohawkaction
One more thing, you said this requires Steam? Is there anyway I could test this without putting my game on Steam yet

You need to register with the Steamworks partner program, which gives you (your Steam account) developer access, but probably requires you to sign some NDA first. It's been a while and long before the days of Steam Direct (and I didn't do the initial registration myself), so I don't know the current time and effort needed.
15  Game Development / Networking & Multiplayer / Re: Steam and Kryonet? on: 2017-08-16 13:09:29
The Steamworks SDK includes a P2P networking interface, which also does NAT translation. Of course this requires Steam, so for potential non-Steam builds you would have to provide an alternative network implementation.
16  Game Development / Newbie & Debugging Questions / Re: Saving files to appropriate location on: 2017-07-28 18:49:29
This is what I'm using right now:

// ~/{user}/Documents
String home = System.getProperty("user.home");
File documents = new File(home, "Documents");

// %APPDATA (c:\Users\{user}\AppData\Roaming)
String appdata = System.getenv("APPDATA");
File roaming = new File(appdata);

From there I create {Company}/{Product} subfolders.

Not sure yet how portable that is. In any case you want to guard your save function and check for exceptions, then warn the user, retry, and/or use a fallback location. There are crazy configurations out there.

Nice test case, on Windows at least: check your save code with a user name containing spaces and special characters. This can break in so many ways it isn't funny.
17  Java Game APIs & Engines / Engines, Libraries and Tools / Re: LWJGLX/Debug on: 2017-07-26 10:39:56
3. support for shared contexts and checking for false sharing of VAOs (other non-shareable GL objects soon to come). Of course, this cannot be covered 100%, since a user could theoretically allocate two different VAOs in two shared contexts, having different meanings/contents and assuming to be able to use the VAO of context A in context B (without checking that they actually have the same handle/integer value)

Ooooohhh! Yes, yes, that could be very useful. I have a bug lurking in our multi-windowed editor which I wasn't able to track down yet, though I believe its some mis-sharing of GL resources.

As usual, my MacBook doesn't care. My Windows PC spams GL debug errors. On the artist PC it crashes hard.
18  Game Development / Shared Code / Re: Faster Than Light JSON Parser on: 2017-07-07 11:28:13
Interesting topic. FYI if I read the bechmark results right, ks5/6 are faster than ks7/8/9 here on my MacBook Pro 2013, Java version "1.8.0_112".
19  Game Development / Shared Code / Re: "Better" LinkedList implementation on: 2017-06-19 12:39:59
The removeFirst() and removeLast() functions don't check for empty lists yet.  Pointing  Grin

I like your solution, esp. because its an intrusive list - the node pointers are members of the list element.
20  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-05-10 14:43:17
I would first ask if Python was ok, then give

I'd suggest to review the code which consumes the output, and check why (if) it needs to do the reverse operation in the first place. Wink
21  Java Game APIs & Engines / Engines, Libraries and Tools / Re: GLSL Language Parsers for Java? on: 2017-05-08 20:33:01
Seems there is no "official" GLSL grammar for ANTLR, but Google points me to a few Github projects:
22  Game Development / Newbie & Debugging Questions / Re: Returning specific type of Object that extends Object? on: 2017-04-29 23:44:12
for(int i = 0; i < components.size(); i++){
   if(components.get(i).getClass() == componentType){
      thisComponent = components.get(i);
      break; /* <--- this here <--- */

You probably want to stop iterating the loop after you find a matching component.
23  Discussions / Miscellaneous Topics / Re: Silly Programming Mistakes on: 2017-04-23 21:07:12
Doing a small side project with Direct State Access (DSA) in "modern" GL 4.5. About an hour of my life I won't get back...  Roll Eyes
24  Discussions / Miscellaneous Topics / Re: Silly Programming Mistakes on: 2017-04-12 08:03:37
boolean filtered = filter.apply(this, cy, cy, h);

camera.position.set(cameraIY, cameraIY, 0.0f);

Both last week. Both took more than half an hour. And both could have been spotted much earlier if my variable naming decisions would not deny the capabilities of IntelliJ's code introspection ("parameter 'x' is named 'y', are you crazy or just short on caffein?").
25  Game Development / Newbie & Debugging Questions / Re: Incorrect boolean value returned by keyboard input functions? on: 2017-04-07 15:07:49
As an example, with libGDX my experience is that polling with Gdx.input.isKey*() is a lot less reliable than event-based handling using InputProcessor. My approach would be to look out for alternate APIs, and if they exist, chose the one closest "to the metal".
26  Game Development / Game Play & Game Design / Re: Graphics Backend Abstraction on: 2017-03-24 11:51:14

That would be an issue when someone reordered the enum contents.

A non-issue in my book, but you could harden the initialize() function as much as you want, so that it fails hard if someone messes up.
27  Game Development / Game Play & Game Design / Re: Graphics Backend Abstraction on: 2017-03-24 11:40:25
Question aside if this level of abstraction is what you should aim for, this would be a pretty simple implementation:

public enum PrimitiveTopology {


   private int value;

   public int value() {
      return value;

   static void initialize(int... constants) {
      for (PrimitiveTopology v : values()) {
         v.value = constants[v.ordinal()];

class BackendGL {

   static void initialize() {
      // call once at backend initialization time
      PrimitiveTopology.initialize(GL_POINTS, GL_LINES, GL_TRIANGLES);

28  Game Development / Newbie & Debugging Questions / Re: Networking and UI Questions on: 2017-03-13 14:32:12
Let says that the player can play 3 ways:
1. Single player
2. A client in multiplayer
3. A server-client in multiplayer

2. and 3. should be identical. In fact, I would try to deal with 1., 2. and 3. exactly the same way.

The reason: it can be a development nightmare to model different environments. It's probably much easier to implement everything as client-server, so that for 1. and 3., it's just a client "connected" to a local server in the same process.
29  Discussions / Miscellaneous Topics / Re: What I did today on: 2017-02-21 13:56:52
files were stored on the server to use a UUID for the file name, and then store the real file name in a database with a reference to the UUID

Hash the file content, e.g. with SHA-1. Use this as your UUID and file name. As a side effect, you gain the option to detect hash collisions / duplicates. You lose the 1:1 mapping of user to file ownership, but there are solutions to this problem too.
30  Game Development / Newbie & Debugging Questions / Re: Sprite render order using libgx tiled maps on: 2017-02-17 10:31:59
MapObjects are rendered in the order they are added. In my opinion, libGDX' existing tile map renderers are, out of the box, simply unusable if objects need to consider any order of rendering.

My advise would be: override TiledMapRenderer.renderObjects(). Keep the MapObject array, or use some sensible (spatial) data structure to store all objects on the map. Each frame, iterate objects, perform view culling, extract the objects visible on the screen to a second array. Sort this array by object.position.y. Render visible objects top to bottom.
Pages: [1] 2 3
Riven (442 views)
2019-09-04 15:33:17

hadezbladez (5304 views)
2018-11-16 13:46:03

hadezbladez (2218 views)
2018-11-16 13:41:33

hadezbladez (5571 views)
2018-11-16 13:35:35

hadezbladez (1158 views)
2018-11-16 13:32:03

EgonOlsen (4595 views)
2018-06-10 19:43:48

EgonOlsen (5470 views)
2018-06-10 19:43:44

EgonOlsen (3132 views)
2018-06-10 19:43:20

DesertCoockie (4026 views)
2018-05-13 18:23:11

nelsongames (4744 views)
2018-04-24 18:15:36
A NON-ideal modular configuration for Eclipse with JavaFX
by philfrei
2019-12-19 19:35:12

Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08 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‑
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!