r/javagamedev • • Sep 18 '26

Does anyone want my game framework?

0 Upvotes

I want to move one from it. It's a game framework built primarily with bgfx and SDL3 for desktop, with raw TeaVM bindings + WebGL for the browser. I planned to add mobile support, but never got to it.

If you're interested, you can see the organization. The repos are currently archived, but if anyone wants the framework, I'm happy to pass ownership.

(Note: it used to have a website as well, but I shut it down, so some of the links you see in some of the READMEs won't work).


r/javagamedev • • Sep 30 '18

im dumb

0 Upvotes

I kept getting errors from my LWJGL engine (kinda newby with OpenGL) and spent hours on the wiki until I realized I put List<Vector2f> instead of List<Vector3f>


r/javagamedev • • Feb 03 '21

How to iterate over Map or HashMap in java - Java Vogue

Thumbnail javavogue.com
2 Upvotes

r/javagamedev • • Mar 07 '15

Pikmin 8 bit tower defense.

1 Upvotes

If anyone is interested I started a tower pikmin defense game in Java it will be fully open source. You guys don't have to support with money just let me know what you think of it or what you would like to see.

https://www.kickstarter.com/projects/729409412/pikmin-tower-defense-8-bit-game

Also believe it or not this is my first reddit post.


r/javagamedev • • Oct 05 '18

Need advice on 2D rendering engine. What am I doing right/wrong, what am I missing?

1 Upvotes

I'm working on a basic rendering engine for a top-down 2D game, technical details are Active Rendering and double buffering, past that, I'm not too sure what my decisions I have to make / what they should be?I tried my best to google things before posting here, but most sources I could find were either far too basic (Think 15 lines of code for the whole thing), too complicated with no explanation (Think 400+ lines of code without as much as a comment), or, most of the time, outright unrelated (Swing based.)

I figured I was left with not much else than diving in, writing something, then looking answers.Below is my render code, follow by my main gameLoop/gameCode (most of which is either super WIP, or straight up temp code.)The third 'code tag' is my questions themselves.Direct answers to those questions, or links to good sources on the subject (I have of course read the JavaDoc for every class in question, and the first few google search results) are very much appreciated! Thanks, in advance!

import java.awt.Dimension;
import java.awt.Frame;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.awt.image.BufferStrategy;
import java.awt.image.BufferedImage;
import java.util.Timer;
import java.util.TimerTask;

public class MangWindow extends Frame
{
      private BufferStrategy bs;
      private BufferedImage image;      
      
      MangWindow(int _w, int _h)
      {          
            setTitle("Sketch - RenderingEngine2D");                        
            setLocation(1920, 0);
            Dimension size = new Dimension(_w, _h);
            setSize(size);
            setMinimumSize(size);
            setMaximumSize(size);
            setResizable(true);
            setIgnoreRepaint(true);

            pack();
            setVisible(true);
            
            createBufferStrategy(2);
            bs = getBufferStrategy();

      	image = new BufferedImage(g.windowW, g.windowH, BufferedImage.TYPE_INT_ARGB_PRE);
      	
            setExitRoute(0);               
      }
      
      public void render()
      {
      	do
      	{
      		do
      		{
            		Graphics g3d = bs.getDrawGraphics();
            		
            		g3d.drawImage(image,  0,  0,  null);
            		
            		g3d.dispose();      			
      		}while (bs.contentsRestored());

      		bs.show();
      		
      	} while (bs.contentsLost());      	
      }
      public Graphics2D createG2d()
      {
      	return image.createGraphics();
      }
      
      public void clear(Graphics2D g2d)
      {
      	g2d.setColor(g.colorBackground);      	
      	g2d.fillRect(0, 0, g.windowW, g.windowH);
      }
      
      //_t is automatic countdown to exit, in seconds, 0 =  off.
      private void setExitRoute(long _t)
      {      	
      	if (_t > 0)
      	{
      		Timer timer = new Timer();
      		timer.schedule(new TimerTask()
      		{
      			public void run() { exit(); }
      		}, _t * 1000L);      		
      	}
            addWindowListener(new WindowAdapter() 
            {
                  public void windowClosing(WindowEvent e) 
                  {
                  	exit();
                  }
            });
      }
      private void exit()
      {
            //TODO: Save game. (configs, world, etc...);
      	g.print("Exitting!");
            dispose(); 
            System.exit(0);       	
      }
}

Main game code:

import java.awt.Color;
import java.awt.Graphics;
import java.awt.Graphics2D;

public class Main
{
	MangWindow mangWindow;
	
	testObject obj; //TEMP graphics test code
	float x = 0;
	
      public static void main(String[] args)
      {
      	Main main = new Main();

            main.init();
            //TODO: implement actual gameLoop and deltaTime
            while (true) 
            { 
            	main.run(); 
            	main.draw();
            	
            	try
            	{
            		Thread.sleep(1);            		
            	}
            	catch (InterruptedException e)
            	{
            		g.print("Got interrupted");
            	}
      	}
            
            
            
      }
      void init()
      {
      	//initialize window and other such graphics
            mangWindow = new MangWindow(g.windowW, g.windowH);
            
            //TODO: load all required assets/configs/data/files/etc...
            IStatParser iStatParser = new IStatParser();
            
            //TODO: initialize into 'main menu'
            //TEMP
            //TEMP graphics test code
            obj = new testObject();
            
      }
      
      void run()      
      {
     //TODO: add actual game logic
      }
     
      void draw() //calls the draw methods of all objects, then calls the window's render
      {
      	Graphics2D g2d = mangWindow.createG2d();

      	mangWindow.clear(g2d);
      	//TEMP graphics test code
      	x += 0.1;
      	if (x > 500) { x = 0; }       	
      	obj.draw(g2d, (int)(x));
      	//example code:
      	//world.draw(g2d);	//Would call the 'draw()' method for all current world objects,
		//would look simply be them drawing their own sprites, and/or animating them, if needed
      	
      	g2d.dispose();
      	
      	mangWindow.render();
      	
      }
}     
      

class testObject
{
	public void draw(Graphics2D g2d, int _x)
	{
		g2d.setColor(Color.red);
		g2d.drawRect(15 + _x,  15,  50,  50);
		g2d.setColor(new Color(255, 255, 0, 127));
		g2d.fillRect(16 + _x,  16,  49,  49);
		g2d.setColor(new Color(0, 0, 255, 127));
		g2d.fillRect(16 + _x,  16,  49,  49);
	}
}

Questions:

1- In Main.draw(), should I be creating a new g2d and disposing of it every single step? If yes/no, why?
Simply creating the graphics context (of the BufferedImage) in Main.init() (making it a class member), and never disposing of it "SEEMED" to work just fine?

2- Should Main.draw() be a surroned by a do-while-loop-indentation similar to that of MangWindow.render()?

3-Where/Who should be responsible of clearing the image?
Eventually, my draw() code would be, in the following order:
drawBackground() 	//Draws a 'dynamic' background. i.e. depends on where you are in the world.
drawWorld() 		//Draws all blocks, player, etc...
drawHUDAndGUIs()	//Seems obvious enough.
I still need a clear before drawBackground() (As it's an actual 'background', not just a solid color. Think "cave background")
So, who should own the clear() method? (From an OOP perspective)

4-How OOP is my Main.draw() method? Is there any stuff that should be moved out of it, or into it? 
For example, is it handling things that should be handled by MangWindow.render()? Or vice-versa?

5- Is there any reason I should be using a Canvas instead of drawing directly to the window? Is there any reason not to?

6- BufferedImage vs VolatileImage?

r/javagamedev • • May 05 '15

ParkourGrip - Java LibGDX puzzle game development.

Thumbnail
youtube.com
0 Upvotes

r/javagamedev • • Dec 19 '12

[Slick2D] Detecting an area where collision would prevent the player from passing through

2 Upvotes

I can't get it to work for me. I'm using a tiled map.


r/javagamedev • • Oct 16 '25

Working on a PC Port of Pou

Thumbnail
reddit.com
0 Upvotes

r/javagamedev • • May 05 '13

Game in java(Eclipse) for kids

0 Upvotes

I am interested in making a java game for kids on eclipse.I want to make such a game which will teach them importance of environment and help them to understand the need for environment conservation.Can anybody please give me some hints and help me in developing such a game,I am very very new in game development so I need to understand from the scratch but I am very much interested in developing such a game,so please help me with the code and all. Thank You and please reply asap


r/javagamedev • • Dec 21 '18

Oracle to start charging fees for Java in January 2019...

0 Upvotes

r/javagamedev • • Jun 03 '13

Creating a 2D drawing class for use in LWJGL

0 Upvotes

I'm currently creating a game using the lwjgl. I have much of the three dimensional graphics working, but I'm running into a snag on the two dimensional side.

My idea was to create a Shape2D class that holds a list of vertices and texture coordinates, and I was able to get that working. However, I would like to have solid color shapes without having to add a square of that color to my texture sheet and keep track of that, and so I tried using glColor3f. This did not work, and my test shape was drawn black, and all textured shapes drawn after were drawn with a shade of red (the test shape's intended color).

My Shape2D class

My Rectangle class

The calls I use to set opengl in 3d and 2d mode

Any help or suggestions would be awesome!


r/javagamedev • • Jun 09 '13

[Question] Update on lighting: I found the problem not to be with the lights itself, but with the normals. What is the proper usage of glNormalPointer

0 Upvotes

I discovered the main problem was that I didn't have

GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);

in my code. When I added that I did see lighting effects that looked correct, but now openGL crashes on me. Crash dump

This is the code I use to set up the normal VBO, it is the same setup I use for the texture and vertex VBO's that I know work.

float[] norms = new float[normalsList.size()];
for (int i = 0; i < normalsList.size(); i++)
    norms[i] = normalsList.get(i);

GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, nHandle);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER, 4 * norms.length, GL15.GL_DYNAMIC_DRAW);
ByteBuffer byteBuffer3 = GL15.glMapBuffer(GL15.GL_ARRAY_BUFFER, GL15.GL_WRITE_ONLY, 4 * norms.length, null);
nBuffer = byteBuffer3.order(ByteOrder.nativeOrder()).asFloatBuffer();
nBuffer.put(textures);
nBuffer.flip();
GL15.glUnmapBuffer(GL15.GL_ARRAY_BUFFER);

This is the code I use to draw my VBO objects, changing the values for glNormalPointer has changed where the program crashes, but it always does crash.

GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, tHandle);
GL11.glTexCoordPointer(2, GL11.GL_FLOAT, 0, 0);

GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, nHandle);
GL11.glNormalPointer(GL11.GL_FLOAT, 0, 0);

GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vHandle);
GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, 0);

GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, model.cubeVerts.length / (3));

Screenshots

I know that I need to disable GL_LIGHTING for 2d drawing, I just don't have that for my test world right now.

Any help is always appreciated!


r/javagamedev • • Nov 06 '13

Managed Images and OSX

0 Upvotes

I'm developing a 2D game using Java2D for graphics. I've been getting remarkably bad performance on OSX devices when the same hardware holds at 60 FPS when booted with Windows 7.

I've been doing some investigating and found that, among other issues, Apple doesn't seem to want to manage images.

I added in a line to print out each time an image is drawn-

 System.out.println(image.getCapabilities(GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration()).isAccelerated());

On Windows, after like 2 seconds, this is always true. On Mac, no matter how long it runs, this shows as false.

All the images show as TYPE_INT_ARGB, and I'm not performing any image manipulation, it just will not manage. Can anyone provide any advice on how to make OSX manage images?

Here are the System.properties for a mac that I'm testing on:

  sun.java2d.opengl=true
  java.runtime.name=Java(TM) SE Runtime Environment
  sun.boot.library.path=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Libraries
  java.vm.version=20.51-b01-456
  awt.nativeDoubleBuffering=true
  gopherProxySet=false
  mrj.build=10M4508
  java.vm.vendor=Apple Inc.
  java.vendor.url=http://www.apple.com/
  java.vm.name=Java HotSpot(TM) 64-Bit Server VM
  file.encoding.pkg=sun.io
  sun.java.launcher=SUN_STANDARD
  user.country=US
  sun.os.patch.level=unknown
  java.vm.specification.name=Java Virtual Machine Specification
  java.runtime.version=1.6.0_51-b11-456-10M4508
  java.awt.graphicsenv=apple.awt.CGraphicsEnvironment
  java.endorsed.dirs=/System/Library/Java/JavaVirtualMachines/1.6.0.jdk/Contents/Home/lib/endorsed
  os.arch=x86_64
  apple.awt.graphics.UseOpenGL=false

r/javagamedev • • Nov 13 '25

(UA/ENG) New fantasy mod, JavaDev's recruitment, petproject

Thumbnail reddit.com
0 Upvotes

r/javagamedev • • Aug 28 '22

OpenGL and GLFW error

12 Upvotes

r/javagamedev • • Jan 05 '13

Is IntelliJ IDEA any good?

6 Upvotes

I currently use Eclipse and I've seen it in action, and looks pretty nice. Do any of you use/would you reccomend it?


r/javagamedev • • Dec 11 '12

My game will no longer play. I made my first game with Slick2d but ran into some problems exporting. Now the game just gives an error when I run from Eclipse.

1 Upvotes

I am pretty sure I didn't change anything in the code between it working, and exporting it, so something really went wrong.

Here is the download for the project file. If you guys can work out what I have done wrong that would be great: http://www.mediafire.com/?xkzsmds2fzmjkuh


r/javagamedev • • Sep 25 '14

How can I improve this text based game? I have never coded or such before

Thumbnail
imgur.com
1 Upvotes

r/javagamedev • • Apr 13 '15

[Question] Is there a way to make this less pc intensive? - Slick2d

1 Upvotes

So I'm trying to draw textures and apply shadow over them. this is what I'm doing at the moment:

sprite = WorldGenerator.SPRITE_GRASS;
sprite.setImageColor(100,100,100,50);
	
g.drawImage(sprite,x,y);
	
Color color = new Color(0,0,0,height*4); // the height value is what i use to determine how much shadow to cast.
g.setColor(color);
g.fillRect(x, y, 32, 32);
	
g.flush();

But this is too intensive and thus creates lagg. All tips are welcome, thank you for your time you guys are awesome!


r/javagamedev • • Mar 13 '17

Multiplayer Platform

Thumbnail
fuse.rupy.se
1 Upvotes

r/javagamedev • • Jun 29 '13

"A Peasant's Tale" : My First Video Game

Thumbnail
youtube.com
0 Upvotes

r/javagamedev • • Aug 08 '16

Nice shooting, fading particles and lobby map as default!!!

Thumbnail
imgur.com
1 Upvotes

r/javagamedev • • Sep 03 '25

New RPG Game

1 Upvotes

Hi everyone, I'm a new coder who wants to profit by making games, I'm now making a Dungeon RPG Talking about a player enters a cave and couldn't get out again to the world, can someone give me ideas for my game name and studio name? I'd add it to the credits scene

Thx


r/javagamedev • • Aug 19 '25

I Make Steam Capsule Art That Pops! DM Me If You Want It For Your Java Game

Thumbnail
gallery
1 Upvotes