Hi !
Featured games (91)
games approved by the League of Dukes
Games in Showcase (755)
Games in Android Showcase (229)
games submitted by our members
Games in WIP (842)
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]
1  Game Development / Newbie & Debugging Questions / Re: Sizing a JFrame correctly... on: 2008-07-15 16:04:54
100 by 200 is not wide enough for the title bar, so I bumped it up to 200x200. Using that code my window's content pane is 202 pixels in both directions, and the content pane doesn't know how large it is when it's initialized.

The way my game works is that I each menu screen or gameplay screen is a different JPanel, and I switch the current ContentPane in the JPanel to the appropriate game screen. One of these JPanels needs to know it's own size

I can throw in a hack where I have a public variable in the JFrame that represents the intended size and then have the ContentPane use that in place of getHeight and getWidth, but that doesn't seem like a good solution.  Undecided
2  Game Development / Newbie & Debugging Questions / Sizing a JFrame correctly... on: 2008-07-15 09:07:02
I want to set the size of my JFrame to a specific height and width. However, I don't want the border to be included in the sizing calculations. I want to size the window based off the content of the window.

For example, if I want my content panel to be 800x600, calling this doesn't work:

this.setSize(800, 600); // "this" is the frame

It sets the size, but the content area has about 30 pixels cut off from the height and 6 or so from the width.

I also tried

this.getContentPane().setSize(800, 600);

And that didn't work either. That just made the JFrame the minimum possible size. My understanding is that adding this.pack(); should solve that problem, but I must be misunderstanding what pack() does because it doesn't seem to solve the problem at all.

I've also tried swapping out setSize with setPreferredSize, and also throwing in setMinimumSize, but nothing I do seems to work reliably.

Another related problem is that sometimes even when I manually set the size of the JFrame the contentpane doesn't know what size it is. I'll call this.getHeight() or something similar from within the contentpane and it returns 0.

What am I doing wrong here?
3  Java Game APIs & Engines / JOGL Development / Re: Problems loading texture and a question about sprites on: 2008-06-23 03:00:40
Thanks, I think I have it now. It was a combination of problems, which is why whenever I fixed one thing it still didn't work. I'll be able to get them loaded now.

4  Java Game APIs & Engines / JOGL Development / Re: Problems loading texture and a question about sprites on: 2008-06-22 09:36:15
Could you post a simple program or something that just loads up a texture from a file and displays it? I've tried reading through the API and looking for tutorials, but I'm having no luck. I keep getting unrelated exceptions whenever I try the Jogl ports of NeHe's tutorials.
5  Java Game APIs & Engines / JOGL Development / Re: Problems loading texture and a question about sprites on: 2008-06-19 19:17:57
I'm not on my home computer, but I remember what I did. I've tried a few different things. I'm not worried abou binding the texture or anything between the glBegin or glEnd, the problem is that the texture I try to generate is always a null pointer.

Texture myTex1 = TextureIO.newTexture(myBufImg, true); // returns null
Texture myTex2 = TextureIO.newTexture(new File(filename), true); // returns null

I've tried a few different things, but I can't get the texture loaded. If I could do that I'm sure I could get it drawn to the screen.
6  Java Game APIs & Engines / JOGL Development / Re: Problems loading texture and a question about sprites on: 2008-06-19 17:24:13
I skimmed the link you posted, but I don't think its quite what I'm looking for.

And it doesn't mention anything about how to load the textures either =/
7  Java Game APIs & Engines / JOGL Development / Problems loading texture and a question about sprites on: 2008-06-19 00:53:48
I'm trying to use TextureIO.newTexture(...)  to read a texture so I can use it for some sprites but whenever I call the function I get a null pointer returned, not matter what set of parameters I feed to it. Does anyone know why it's happening or how to fix it?

Also, should I be using GL_QUADS with textures on them for my sprites, or should I be using something like glDrawPixels? I've used OpenGL in C++ for a class, but I've never done anything like make a game. I've mostly used it for making 3D stuff. If I were to use glDrawPixels, how would I get them in a format that the function can use?
8  Java Game APIs & Engines / Java 2D / Improving performance in my game on: 2008-06-19 00:43:09
I'm writing a sprite based fighting game and whenever I draw large sprites with transparency, like the stage itself, the game slows way down. When I draw a few smaller sprites it works fine though. I just read the .png files with and then when I draw them I just use the standard g.drawImage(...) function.

While googling around for a solution I saw suggestions to use -Dsun.java2d.opengl=True, but I keep getting the error message "Could not enable OpenGL pipeline for default config on screen 0" which appears to be because I have an intel chipset.

The other option that I know of is to replace the rendering code I currently have with JOGL. I've got JOGL set up on my computer and I can run it just fine. I've done OpenGL programming in C++ for about a year (I had two elective courses at my school in graphics programming in openGL), but I've been having trouble loading textures. I can load images just fine, but when I try to turn them into a texture with TextureIO.newTexture(...) I get a null pointer.

I don't even know if that's the way to do it correctly though, it's hard to find up to date tutorials. Anyone have tips or code I can look at or tutorials on how to get 2D sprites to run effeciently?
Pages: [1]
DesertCoockie (52 views)
2018-05-13 18:23:11

nelsongames (82 views)
2018-04-24 18:15:36

nelsongames (74 views)
2018-04-24 18:14:32

ivj94 (757 views)
2018-03-24 14:47:39

ivj94 (87 views)
2018-03-24 14:46:31

ivj94 (643 views)
2018-03-24 14:43:53

Solater (102 views)
2018-03-17 05:04:08

nelsongames (184 views)
2018-03-05 17:56:34

Gornova (426 views)
2018-03-02 22:15:33

buddyBro (1086 views)
2018-02-28 16:59:18
Java Gaming Resources
by philfrei
2017-12-05 19:38:37

Java Gaming Resources
by philfrei
2017-12-05 19:37:39

Java Gaming Resources
by philfrei
2017-12-05 19:36:10

Java Gaming Resources
by philfrei
2017-12-05 19:33:10

List of Learning Resources
by elect
2017-03-13 14:05:44

List of Learning Resources
by elect
2017-03-13 14:04:45

SF/X Libraries
by philfrei
2017-03-02 08:45:19

SF/X Libraries
by philfrei
2017-03-02 08:44:05 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!