Im currently working on a game (ever tried Zero Gravity on the Amiga 500, or Lunar Lander??). Well, anyway, its a 2D game where you navigate a Lander through treacherous terrain, and caves.
Im new to Java so Im learing as I go along, but there is one thing that I havent been able to figure out, and that is how to check for collisions with the background (the montains and rocks) while simultaneously rotating the lander.
The way Im checking for collision is by using PixelGrabber to store the pixel layout of the lander object into an array, and then, every frame, the background object checks the position of the lander, grabs the pixels of the background image corresponding to that position, and then compares the two.
I have made all the "empty" areas blue (255). As long at the background pixels that are overlapping the lander pixels are blue, nothing happens, but if the color of the pixels are anything but blue, and those overlapp a part of the lander pixels that are not blue, the ship blows up.
So the problem Im faceing at the moment is that I need to be able to grab pixels other than in an straight horizontal/vertical way, since the landers coordinates are not fixed in these directions.
I have a possible solutions to the problem which I havent tried yet, and that is to have an offscreen image of the background, which I rotate as the ship rotates. This offscreen image would not be used for painting though. But, the easiest way would be to alter the array in the lander object that contains the pixel layout. Or to be able to issue commands through PixelGrabber, to grab a "rotated, rectangle area".
Does anyone have a clue how I should procede to solve this problem?