Java-Gaming.org
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
Featured games (78)
games approved by the League of Dukes
Games in Showcase (416)
games submitted by our members
Games in WIP (306)
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 / Game Mechanics / Re: Have I found a new more efficient angle-finder? on: 2013-06-19 00:21:25
I'm not really seeing why you have to use sqrt in the first place...shouldn't angle calculation be a simple dx, dy, atan2, rotate vector?

That would be the trig route, which is fine, but then I'm not sure which is more expensive, atans or sqrts?
Benchmark time! Unless it's already been proven?
2  Game Development / Game Mechanics / Re: Have I found a new more efficient angle-finder? on: 2013-06-19 00:14:04
It's usually bad form to have a check for specific edge cases in what should be a purely mathematical calculation. Also, doing so is not what you want if you are looking for performance.
Here is the formal calculation:
1  
2  
3  
4  
5  
Vector2f dir = new Vector2f(x2 - x1, y2 - y1);
dir.divide(dir.magnitude()) //makes dir into a unit vector(important)
dir.multiply(speed);
//dir is now in the proper direction (dy/dx) and the correct length (speed)
object.moveBy(dir);


Vector2f.magnitude() is the same as Math.sqrt(dir.x * dir.x + dir.y * dir.y), so you're not going to avoid that.


Ninja edit: Really, sqrts arn't going to be you're bottleneck for pretty much anything.
3  Discussions / General Discussions / Re: Yippieeee! Got my new Graphic card! on: 2013-06-18 18:35:05
I built my comp with a HD 4670 (old I know), but I want to upgrade sometime soon.
Overclocked GTX 580 chiming in! Mwahahaha \o/

Sounds expensive.  Tongue Also quite fast  Cool
4  Game Development / Game Mechanics / Re: Java2D rendering with BufferedImage RGB data on: 2013-06-18 07:18:40
I think you're correct. If I'm recalling correctly, which given the hour here I may not be, I think the preferred way to do direct pixel manipulations was to use create an image that was compatible with your BufferStrategy, then grab the pixel data for that image via the "raster/alpha data" methods and manipulate it. Once the pixel level manipulation was done, you render the final product to the back buffer and flip. This keeps the strategy itself accelerated even if the "scratch image" isn't. Direct manipulation of the back buffer is definitely a no-no. Shocked

Agreed. But using the pixel array should keep the scratch image accelerated and thus help with the process, otherwise not very many gains would be had, as you still have to render to the strategy.
5  Game Development / Game Mechanics / Re: Java2D rendering with BufferedImage RGB data on: 2013-06-18 06:57:36
Yea, it was mostly low level pixel operations that did that, but I believe that the .getRaster().getDataBuffer() etc. stuff does successfully get around this, albeit then you have to work with color packing and manually indexing and such. So for BufferedImages, that is the best option for pixel-by-pixel access to the image, am I correct?
6  Game Development / Newbie & Debugging Questions / Re: My game is almost half a Gigabyte in size on: 2013-06-18 06:47:42
Yea, I think it is mostly just the traditional advice.

As an aside, I would avoid using mp3's in anything I distribute at the moment. There are currently too many licencing/patent uncertainties involved with their use that can be sidestepped with the ogg/vorbis suggestion. Cool

Ah, now there is a legitimate reason in regards to file format, good idea, thank you sir.
7  Game Development / Game Mechanics / Re: Java2D rendering with BufferedImage RGB data on: 2013-06-18 06:44:59
As a side note, I could have sworn that I read BufferStrategy uses BufferedImages behind the scenes, but I may be wrong.

It may, but either way, it takes care of it for you and it is likely to do it well, and that is nice.

Maybe I've just been lucky in the fact that I haven't tripped enough of them to blow my performance to pieces. persecutioncomplex

IIRC, I think it is mainly (or at least used to be) certain drawing operations (like transforms or compositing) or setData() etc, operations on buffered images that it didn't like.
8  Game Development / Newbie & Debugging Questions / Re: My game is almost half a Gigabyte in size on: 2013-06-18 06:21:27
I think it's for ease of processing since you don't have to unpack/decode the data on the fly. I would imagine many sound libraries would store the data in memory in an unpacked format for this reason. Just my $0.02.

That is a reason I've considered, but also, all sounds loaded into memory are in an uncompressed (raw) format. Only files streamed from the HDD avoid this (and only partly, as they must be decoded in as the stream comes in), which is what you try to do for long sounds, like background music, to avoid using hundreds of MB's.
But surely the processing time required to decode many small mp3's or such is small compared to other concerns?
9  Game Development / Game Mechanics / Re: Java2D rendering with BufferedImage RGB data on: 2013-06-18 06:10:32
I DO know that when finicking around in Java2D looking for performance, it is  very easy to 'trip a tripwire' and send the renderer into software rendering (making your image unmanaged), which vastly slows down everything. Another approach with Java2D is using BufferStrategy, which circumvents using BufferedImages, and, in my experience, is slightly faster. It is best used for fullscreen mode applications, however.
10  Game Development / Newbie & Debugging Questions / Re: My game is almost half a Gigabyte in size on: 2013-06-18 05:57:59
Generally you would use WAV files for short sounds (Special FX) and Mp3 or other compressed format for music and large sounds.
I've heard that, but I always wonder, why? Is it loading times? I have several theories on this, but I want to know other people's opinions on this, as I am wondering if I am doing something genuinely 'wrong.'
11  Game Development / Game Mechanics / Re: Java2D rendering with BufferedImage RGB data on: 2013-06-18 05:39:31
I'm not entirely sure what you're asking, but you can obtain the color data of a BufferedImage with this:
1  
 data = ((DataBufferInt) image.getRaster().getDataBuffer()).getData();

That will give you an integer array (you can change it to give a byte array, etc.), with each integer corresponding to the BufferedImage's type, e.g. TYPE_INT_ARGB for ARGB packed integers.

Modifying this array with also change the image, as it is a reference to the image's raster.
This should be faster than Graphics.drawSomething() for some operations, but it won't be huge. If you're concerned about performance, don't be using Java2D  Pointing
12  Game Development / Newbie & Debugging Questions / Re: My game is almost half a Gigabyte in size on: 2013-06-17 02:59:56
I know all about trying to avoid 3rd party stuff, but trust me, you want modern audio compression  Wink
13  Game Development / Newbie & Debugging Questions / Re: My game is almost half a Gigabyte in size on: 2013-06-17 02:09:57
First, if you can, use something like MP3s instead of WAVs, that will save a ridiculous amount of space.
Might need to investigate a mp3 loader or library for it, but it would be worth the investment.

EDIT: Kinda ninja'd,  but yeah, WAV is totally uncompressed, and MP3 is pretty well compressed, and still sounds fine to most ppl down to about 192 Kbps or so

In regards to an mp3 loader, just use libgdx; it works quite well.

Yea, well if he went LibGDX for sound then he would probably want to use it for the rest of the game (I'm still assuming he isn't already), and while it might improve performance etc, that's pretty much premature optimization and would greatly increase development time, and I find that completely changing the way you do things in the middle of a project is not the way to stay focused and get it done.  Wink
14  Game Development / Newbie & Debugging Questions / Re: My game is almost half a Gigabyte in size on: 2013-06-17 01:55:52
First, if you can, use something like MP3s instead of WAVs, that will save a ridiculous amount of space.
Might need to investigate a mp3 loader or library for it, but it would be worth the investment.

EDIT: Kinda ninja'd,  but yeah, WAV is totally uncompressed, and MP3 is pretty well compressed, and still sounds fine to most ppl down to about 192 Kbps or so
15  Games Center / WIP games, tools & toy projects / Re: [WIP] Scene Animator 'Alpha' - [Pre-release is out!] [Almost 'alpha'] on: 2013-06-16 18:28:59
Do what you need to do first, but if this gets [ported?] to LibGDX, then I'm sold for sure.  Pointing
Nice stuff either way.
16  Games Center / WIP games, tools & toy projects / Re: [WIP] Scene Animator 'Alpha' - [Pre-release is out!] [Almost 'alpha'] on: 2013-06-15 23:12:57
Oh dang, I might just use this   Cheesy

Usually I code these kinda things myself, but if it's plug-and-play and slick enough, I might let you reinvent the wheel for me Tongue
I'm staying tuned for sure.
17  Games Center / WIP games, tools & toy projects / Re: SF Citybuilder- Buildings/Concept Art on: 2013-05-27 04:49:24
Wow, nice art!  Pointing

Quick comment, I thought that if you had a day/night cycle in the game, you could use the different shading amounts at different times of day, as the 'Strong' shading struck me as looking a lot like it would at sunset, and the subtle midday. Just an idea.  Smiley

Really nice though, gonna show this to my friend, he loves his Dune and such.
18  Game Development / Newbie & Debugging Questions / Re: (question) Tile mapping: 1d, 2d, or 3d Array? on: 2013-05-20 22:31:25
Which is faster for PCs/Macs?

One thing I have learned is not to worry too much about performance unless you know it's going to be an issue (e.g. bad algorithm scaling). Instead, when you start off, do what reduces the conceptual weight of the project, what makes it easier to wrap your head around, as that is more important. If you can't figure out how to do something at all, then what is the point of making it fast?

From what I got from this, I think the 3D arrays are the way to go, either one big one, or 3 separate ones.

example:
1  
tiles[x][y][z]
where (x, y) is the world coordinate, and z is the layer you want to reference (0-5).

or you could have it [Z][X][Y], or any other order for that matter, just be consistent in the code haha!
19  Games Center / WIP games, tools & toy projects / Re: [WIP] Daedalus on: 2013-04-19 03:14:21
The game looks awesome!

I'm getting this error:

...
I'm on Windows 7, Radeon X1950 Pro
I was also having problems regarding Basique on a laptop with crappy Gl support (game crashed before main menu showed up), but I found that if you take out the #version on the fist line of the shader file, the game works fine.

Hope somebody finds this useful.
20  Java Game APIs & Engines / Engines, Libraries and Tools / Re: LibGDX BufferedImage to Texture on: 2013-04-10 03:16:23
If you are using LibGDX, I have to say that I don't recommend also using BufferedImages (from Java2D), instead you could use a Pixmap, or if you really do need BufferedImages, then I guess you could use ImageIO to save the image to a file, bring the file back in as a texture, then delete the file, but that seems quite hacky and inefficient.
21  Game Development / Newbie & Debugging Questions / Re: A good resource for anyone, first post introduction on: 2013-04-09 01:19:57
I think it started to really 'click' for me was when I was reading a Java book from the library that had me making a simple calculator app with the AWT component subclasses etc, that's when I started to understand the Object-Oriented paradigm and the backbone concepts of programming. I recommend finding a simple task like a calculator app or similar, nothing major, and make it, following a tutorial if you need to. One of the biggest things I can say is don't try to jump off into the deep end right away, like full-fledged game development; instead start simple and try to understand what is making things happen, and then think about how to scale those concepts up to bigger things.

TL;DR, start with a simple project  Wink
22  Game Development / Newbie & Debugging Questions / Re: Making custom menus on: 2013-04-04 15:44:11
Easy method is having your Canvas/JPanel/whatever implement an event Listener and test for the condition.
E.g. mouse clicks for intersection with a rectangle around your text:

1  
2  
3  
4  
5  
6  
7  
Rectangle buttonArea; //initialized elsewhere for readability

public void mousePressed(MouseEvent e) {
     if(buttonArea.contains(e.getPoint())) {
          //do stuff here, like flip to next screen, start game, etc.
    }
}


Just use KeyListener for keys, and change which String the dot is drawn next to, and also test for 'E' being pressed, and have that do whatever action you need.
23  Discussions / General Discussions / Re: bck2brwsr a JVM in Javascript on: 2013-03-01 23:08:39
Even if its not super fast, still seems like a nifty way to sneak applets into your page without a couple dozen security popups showing their ugly heads.
24  Game Development / Game Mechanics / Re: 128 bit integer on: 2013-02-15 16:59:38
If all you need is up to around 10^15, then just use longs, they can go to 2^63 or so, which is almost 10^19.
25  Games Center / WIP games, tools & toy projects / Re: Particle Editor Tool on: 2013-02-08 22:18:23
 Shocked
This looks epic, can't wait for a demo!
26  Game Development / Shared Code / Re: Pre-multiplied Alpha for drawing particles in one pass on: 2012-08-21 02:11:39
Maybe someone else has a better explanation, but as I understand, it's just another way of compositing colors, you don't need to use it, or understand why it exists, nothing, just that it is an alternative method for (in the case of OpenGL) glBlendFunc(), as well as a non-implementation specific method of compositing, so if the language/api/whatever you are using doesn't support anything like glBlendFunc you can use this. That is what I know.
27  Game Development / Shared Code / Re: Pre-multiplied Alpha for drawing particles in one pass on: 2012-08-21 01:39:40
Could someone explain what pre-multiplied alpha is exactly? Google isn't exactly helping with its big words.

It's precisely what it sounds like: the rgb colors are multiplied with the alpha channel before anything is drawn, instead of being blended in while stuff is being drawn.

So, say if you drew a  transparent red [1.0f, 0.0f, 0.0f, 0.5f] (that's rgba) square, then what would end up on screen is the same as if you drew a square with the opaque color [.5f, 0.0f, 0.0f 1.0f]. Notice the 1.0f * 0.5f = 0.5f, hence 'pre-multiplication.'

This is nice for large batch rendering because you can simulate blend modes just by setting the current color to draw with, instead of using glBlendFunc().
28  Games Center / Showcase / Re: Toxic Bunny HD on: 2012-08-19 23:12:57
Damn, you got all that performance from java2d?  Do you guys have any developer diaries to share?


Heh that's what I was wondering; I'd probably be over 8ms just drawing the background! (on my crappy laptop anyway)

Nice job though, looks awesome!
29  Java Game APIs & Engines / Java 2D / Re: Java 2D collision detection on: 2012-08-19 22:32:00
OK, I think I got this:

It looks to me like you are checking for collision with any block in the map (brute force method), but then you get out of the loop and check again if he is still colliding. Well if you don't do anything of course he is still going to be colliding! Wink

Simple (not the best, but easy to understand, which is key!) method of resolving the collsion:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
Rectangle collision = hero.intersection(collisionBlock); //  Get the intersection itself
           
            if(hero.collUp) {              // If he was colliding upwards,
               hero.y -= collision.height;// move him back down
               
            } else if(hero.collDown) {     // If he was colliding downwards,
               hero.y += collision.height;// move him back up
               
            } else if(hero.collRight) {    // If he was colliding to the right,
               hero.x -= collision.width; // move him to the left
               
            } else if(hero.collLeft) {     // If he was colliding to the left,
               hero.x += collision.width; // move him to the right
           }


Put that in between the end of the collision check loop and the is-he-still-colliding check, and tell me how it goes!  Smiley

(Also I have more code if you need to see it to get the picture)
Pages: [1]
Play Revenge of the Titans! The situation is critical. We need fancy commanders to defend Earth, the moon, Mars!
 
Browse for soundtracks for your game!

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

The invasion has landed! On Mars! And you're there to beat 'em!
BrassApparatus (6 views)
2013-06-19 08:52:37

NegativeZero (11 views)
2013-06-19 03:31:52

NegativeZero (13 views)
2013-06-19 03:24:09

Jesse_Attard (18 views)
2013-06-18 22:03:02

HeroesGraveDev (59 views)
2013-06-15 23:35:23

Vermeer (59 views)
2013-06-14 20:08:06

davedes (58 views)
2013-06-14 16:03:55

alaslipknot (52 views)
2013-06-13 07:56:31

Roquen (73 views)
2013-06-12 04:12:32

alaslipknot (58 views)
2013-06-10 19:30:18
Smoothing Algorithm Question
by UprightPath
2013-05-28 02:58:26

Smoothing Algorithm Question
by UprightPath
2013-05-28 02:57:33

Complex number cookbook
by Roquen
2013-04-24 12:47:31

2D Dynamic Lighting
by Oskuro
2013-04-17 16:46:12

2D Dynamic Lighting
by Oskuro
2013-04-17 16:45:57

2D Dynamic Lighting
by Oskuro
2013-04-17 16:23:20

Noise (bandpassed white)
by Roquen
2013-04-05 17:36:01

Noise (bandpassed white)
by Roquen
2013-04-03 16:17:38
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!