(if you're using a sprite sheet JohnTheRedeemer's suggestion is best suggestion but here is another one)
DrawImage is overloaded several times and one of the versions allows you to specify rectangles for both the source and destination coordinates. It's powerful for drawing images at various sizes, though a bit much for just flipping them. Look for this one: drawImage(Image image, float x, float y, float srcx, float srcy, float srcx2, float srcy2) Here.
(Really shouldn't be posting right now... got a Systems exam to study for...)
Just in the interest of full disclosure, I convert when I load the image- that newImg I'm writing to is just to resize the oldImg so oldImg and u.currentlevel.graphics are the same size (this is assumed true in multiply()). The result should be the same, though- all edits to oldImg are done by drawing to its Graphics2D.
Here's the multiply() method:
private BufferedImage multiply(BufferedImage a, BufferedImage b) {
int[] Adata = ((DataBufferInt)a.getRaster().getDataBuffer()).getData();
int[] Bdata = ((DataBufferInt)b.getRaster().getDataBuffer()).getData();
BufferedImage c = new BufferedImage(a.getWidth(), a.getHeight(), BufferedImage.TYPE_INT_ARGB);
int[] Cdata = ((DataBufferInt)c.getRaster().getDataBuffer()).getData();
int aR, aG, aB, bR, bG, bB, cR, cG, cB;
for (int i = 0; i < Adata.length; ++i) {
int aColor = Adata[i];
int bColor = Bdata[i];
//System.out.println("Adata = " + Integer.toHexString(Adata[i])); // shows FF000000 everywhere!
//System.out.println("Bdata = " + Integer.toHexString(Bdata[i]));
aR = (aColor >> 16) & 0x000000FF;
aG = (aColor >> 8) & 0x000000FF;
aB = (aColor) & 0x000000FF;
bR = (bColor >> 16) & 0x000000FF;
bG = (bColor >> 8) & 0x000000FF;
bB = (bColor) & 0x000000FF;
cR = (aR * bR) >> 8;
cG = (aG * bG) >> 8;
cB = (aB * bB) >> 8;
Cdata[i] = (cR << 16) & (cG << 8) & cB;
//System.out.println("Cdata = " + Integer.toHexString(Cdata[i]));
}
I may look at Slick2D, it seems interesting. I don't have time at the moment to figure it out, but it seems like a good replacement. :)
I'm using the int array, which seems fastest, but Java is complaining on one of those lines because "java.awt.image.DataBufferByte cannot be cast to java.awt.image.DataBufferInt". One of the images I'm using is loaded from ImageIO.read(), and I assume it sets the image's type to TYPE_3BYTE_BGR or TYPE_4BYTE_ABGR. Is there a quick way to convert it to the type I need when it's loaded? (If need be I'll just create a new image of the same size but correct type, and write the image I need into its Graphics2D)
I really should look into LWJGL, but after a semester of mucking around with C++/GLFW and trying to figure out which framework is best, I thought, "I know Java, and I know Swing. I can make a crappy but complete game without learning any new languages or frameworks". So here I am... :P
.
[EDIT] I just wrote it into the Graphics2D, and that seems to work, but one of the images I'm working with looks like it's completely empty. This is basically what I do:
// create new image at the correct size- this is what I multiply
BufferedImage newImg = new BufferedImage(1024, 512, BufferedImage.TYPE_INT_ARGB);
// create its graphics and write to it, eventually the placement will be changed
Graphics2D g2 = newImg.createGraphics();
g2.drawImage(oldImg, 0, 0, null);
// multiply image by level graphics
BufferedImage display = multiply(newImg, u.currentLevel.graphics);
println() statements I put in the multiply() method, which modifies the int arrays, show that every single integer in newImg's int array is 0. Now I know this is not right- I just wrote to its Graphics2D. Does that not update its int array?
The 'M' in your title is backwards. This disturbs my OCPD and never-ending love of Doom.
That said... this sounds absolutely amazing. I've been interested in procedural generation for some time (at least conceptually- I could never implement something like Infinity - TQFE or even a good roguelike (yet :P)), but this, measuring a player's enjoyment and responding to it, sounds absolutely groundbreaking.
I'll try this out and try to give halfway-decent feedback when I have some free time! Best of luck on this and your other projects! :D
It's got vertex locations right from what I can tell, but the faces are using all the wrong vertices. It looks like face definitions are just screwed up in general.
The line is supposed to be "f <verts> <texcoords> <normals>", right? Or am I missing something?
(if you're using a sprite sheet JohnTheRedeemer's suggestion is best suggestion but here is another one)
DrawImage is overloaded several times and one of the versions allows you to specify rectangles for both the source and destination coordinates. It's powerful for drawing images at various sizes, though a bit much for just flipping them. Look for this one: drawImage(Image image, float x, float y, float srcx, float srcy, float srcx2, float srcy2) Here.
(Really shouldn't be posting right now... got a Systems exam to study for...)
Just in the interest of full disclosure, I convert when I load the image- that newImg I'm writing to is just to resize the oldImg so oldImg and u.currentlevel.graphics are the same size (this is assumed true in multiply()). The result should be the same, though- all edits to oldImg are done by drawing to its Graphics2D.
Here's the multiply() method:
I may look at Slick2D, it seems interesting. I don't have time at the moment to figure it out, but it seems like a good replacement. :)
Thanks!
I'm using the int array, which seems fastest, but Java is complaining on one of those lines because "java.awt.image.DataBufferByte cannot be cast to java.awt.image.DataBufferInt". One of the images I'm using is loaded from ImageIO.read(), and I assume it sets the image's type to TYPE_3BYTE_BGR or TYPE_4BYTE_ABGR. Is there a quick way to convert it to the type I need when it's loaded? (If need be I'll just create a new image of the same size but correct type, and write the image I need into its Graphics2D)
I really should look into LWJGL, but after a semester of mucking around with C++/GLFW and trying to figure out which framework is best, I thought, "I know Java, and I know Swing. I can make a crappy but complete game without learning any new languages or frameworks". So here I am... :P
.
[EDIT] I just wrote it into the Graphics2D, and that seems to work, but one of the images I'm working with looks like it's completely empty. This is basically what I do:
println() statements I put in the multiply() method, which modifies the int arrays, show that every single integer in newImg's int array is 0. Now I know this is not right- I just wrote to its Graphics2D. Does that not update its int array?
Yes, now expand GNU again...
ERROR: stack overflow
really not much we can say about 16 pixels...
The 'M' in your title is backwards. This disturbs my OCPD and never-ending love of Doom.
That said... this sounds absolutely amazing. I've been interested in procedural generation for some time (at least conceptually- I could never implement something like Infinity - TQFE or even a good roguelike (yet :P)), but this, measuring a player's enjoyment and responding to it, sounds absolutely groundbreaking.
I'll try this out and try to give halfway-decent feedback when I have some free time! Best of luck on this and your other projects! :D
Mine always just seems to come out like this.
http://i.imgur.com/oOb1B.png
Any good tutorials on GL3? Sounds like a good idea for standards' sake.
THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU THANK YOU :D
Blender has not so much a learning curve, as a learning sheer asymptotic cliff of evil evilness. :p
Can't I just batch-create 100000 images in GIMP, then start making really awesome game art?
In Wings3D
In my program... HOLY SHIT WHAT IS THAT
It's got vertex locations right from what I can tell, but the faces are using all the wrong vertices. It looks like face definitions are just screwed up in general.
The line is supposed to be "f <verts> <texcoords> <normals>", right? Or am I missing something?
[EDIT] I'm missing something. It's "f <vert/coord/normal> <vert/coord/normal> <vert/coord/normal>". I'm a noob.
End of this list.
Back to top