SJGL (Now on GitHub!)

I’m not dead
I’m sorry for the lack of updates, it’s just I don’t know what to add. Any ideas?
If you have any questions or suggestions, you can PM me here or email me here

Well obviously this is a good place to start, as it has been posted by numerous members before.

Make a game with it! Not just moving images like the last one, but an actual purpose. For example: pong or asteroids.

Then once that game is done, pick out the code that sticks out to you as being helpful and reusable, and add that to the library.

CopyableCougar4

Alright. The moment you’ve all been waiting for…

It’s time for the first ‘real’ game made with SJGL, Dr. Mike!

Dr. Mike is a simplified clone of Dr. Mario, a NES game some of you may remember. If you don’t, you play as a doctor trying to get rid of unwanted viruses with brightly colored pills. If you kill all the viruses in one stage, more spawn. In Dr. Mike, there are 2 stages: easy and hard. Once you complete the easy stage, you go onto a harder one. The easy stage is normal: drop the pills onto the corresponding viruses to make them go poof. In the hard stage, they sort of dance around the screen until you kill one, which kills the party vibe and makes them stationary. Then, you kill them and the game ends. A screenshot is below:

You can download Dr. Mike here: here

Just letting you know, the pills spawn outside of the little area.


http://puu.sh/d82fC/472577cb66.png

Dang it. I must have overlooked something when I set the spawn point to inside the bottle/test tube.

(Sorry for the double post)

It’s update time. This update to SJGL has been centered around mainly bug-fixing, ridding the library of useless features, and geometry. Here’s a change log:

Added:

  • Sprite class: It’s an alternative to using the GL class for image loading and drawing
  • Added com.darkcart.lib.sjgl.geometry package
  • Added Rectangle class
  • Added Circle class
  • Added Vector2f class
  • Added Vector3f class
  • You can now draw shapes with the respective classes using SimpleGL. (i.e. gl.rect(new Rectangle(10, 10, 32, 32)):wink:
  • Added TimeUtil class: mainly just a wrapper for Thread.sleep(long milli)…

Removed:

  • GameListener no longer implements WindowListener.

Download: here
SJGL now comes with 2 example games/tech demos, Dr. Mike and Minicraft (Pathfinding Creepers!)

Where’s the vector math? :frowning:

On Minicraft, the up and down controls are reversed.

Up: moves me down
Down: moves me up

Still working on it, please hold :wink:

@gzuzboey: I should probably fix that, shouldn’t I? :wink:

Yea, probably. :wink:

@DarkCart: Once your done fixing that mistake, you should put Minicraft on github with all the other examples :slight_smile:

Just for fun, I’m going to do the same task in pure Swing/AWT and SJGL, just to see the differences. The resulting code will draw a red ball on a black background.

Swing/AWT:


import java.awt.Color;
import java.awt.Graphics;
import javax.swing.JFrame;
import javax.swing.JPanel;

public class AWT {

	public static void main(String[] args) {
		new AWT();
	}

	public AWT() {
		JFrame frame = new JFrame();
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(640, 480);
		frame.add(new Paint());
		frame.setTitle("Red Ball");
		frame.setResizable(false);
		frame.setLocationRelativeTo(null);
		frame.setVisible(true);
	}

	class Paint extends JPanel {
		private static final long serialVersionUID = 1L;

		public void paint(Graphics g) {
			super.paint(g);
			g.setColor(Color.black);
			g.fillRect(0, 0, 640, 680);
			g.setColor(Color.red);
			g.fillOval(10, 10, 32, 32);
		}
	}
}

SJGL:


import java.awt.Graphics;
import com.darkcart.lib.sjgl.*;
import com.darkcart.lib.sjgl.simplegl.*;
import com.darkcart.lib.sjgl.util.*;

public class SJGLTest extends BasicGame {
	GL gl;
	
	public void init() {
		Window win = new Window();
		win.createWindow(640, 480, "SJGL Test", false);
		win.addTool(this);
		gl = new GL();
	}

	public void logic(){}

	public void paint(Graphics g) {
		gl.init(g);
		gl.background(Color.black);
		gl.fill(true);
		gl.circle(10, 10, 32, 32);
	}
	
	public static void main(String[] args) {
		new SJGLTest().init();
	}
}

Alright, maybe it saves about 5 lines of code extra. I should work on that.

Just so you are aware, that’s Swing, not AWT. AWT would be just Frame/Panel, not JFrame/JPanel.

Fixed that.

I really don’t want to be rude, but I don’t see much of a future in this project. Only thing it’s useful for is just simple prototyping (in my opinion). If someone wants to make an actual game, (s)he should use a library that uses graphics card (LWJGL, JOGL, or libraries/frameworks built on top of them, like LibGDX, Slick2D…), not Swing. If you built it on top of LWJGL (or JOGL), it would be (kinda) useful (and you’d learn a ton of stuff about graphics), but Swing/AWT is just not good for games (and if I’m correct, that’s what your library is for). You also don’t follow many conventions, like many naming conventions (“update” in SJGL is “logic”, “render” is “paint”, etc.), which isn’t very good, either. But it’s your library, your toy project. Just don’t expect it to be used very much.
(Also, I’m still kinda waiting for a better tech demo. Dr. Mike doesn’t show many capabilities of SJGL)

Many people have said this before. But you can ignore it, if you want.

This.

If you’re working on a game library, that’s perfectly fine. Even more so if it actually brings something new to the table and/or makes things easier while still giving the developer all of the necessary features required to make a good game.

Spend more of your time making games, less of your time making libraries. :slight_smile:

As for the naming conventions, you should seriously consider using something more common such as [icode]update()[/icode] and [icode]render()[/icode] in your code as MrPizzaCake pointed out in his post.

  • Jev

Exactly. If you want, make a library (I especially encourage that when it’s for learning and/or helping other developers), but make sure you can make a great game with it. But don’t make 5 libraries and only one game. Make a small library that will help you with developing more games, which could help you can improve the library, make even more games, and so on.

It’s update time!

Major features added are Vector math (probably not perfect)! Here’s the change log:

Added:

  • Vector math! Add, subtract, multiply, divide, rotating, setting, cloning, normalizing, distance. That enough? :wink:
  • addTool(JComponent comp) and removeTool(JComponent comp) are now start(JComponent comp) and stop(JComponent comp)
  • clip(int x, int y, int width, int height) and clipRect(int x, int y, int width, int height)
  • So, apparently, there’s this thing where you can use OpenGL to render Java2D graphics (System.setProperty(“sun.java2d.opengl”, true);, for anyone who wants to know). SJGL now has that.
  • logic() SHOULD be changed to update()

Removed:

  • Vector3f class
  • Window.java’s createWindow(). Use the constructor for this. (Window win = new Window(640, 480, false);

Download (Google Drive): here

Download is also in the OP.

Dot product, Cross/wedge product, multiply with matrices, etc.

Weeeeelllll… now I have something to do on Christmas.

w4yOOdpghDI

Just watch it. You can implement 2D vectors in less than 10 minutes.

  • Jev