F
Francois Lionet
Hello,
For the game I am writing, I need to handle a collision map. This collision
map is a simple array of bits representing an image, a bit set indicating
that there is a collision for this pixel. I am wondering on how to implement
this... I need to be able to scroll this array to follow the scrolling of
the game, to poke a shape into it, and retreive every pixel individually.
The size of this array can be quite big, bigger than the screen.
Should I do it by hand : reserve an array of bytes, and poke the shapes
myself, and do the collision detection. I fear that the scrolling would be
very slow, and that the overall performance would be bad. Is there a utility
class to shift the data in an array by an offset?
Should I use a BufferedImage of BINARY type? This would be really easy for
poking the shapes into it, and scrolling would be fast. But to get the data,
I would have to use the raster class, and the only way of getting the data
is to copy them into an array of Int (or float/double even worse), with one
int per pixel! Imagine the size of the array, and the time needed to copy
the data. Do you know if there is a way of getting the data in the raster
without copying them in an array?
What do you think? Do you think that the by hand method would be fast
enough? Do you know any method of getting access to the raster data without
copy?
Thanks, Francois
For the game I am writing, I need to handle a collision map. This collision
map is a simple array of bits representing an image, a bit set indicating
that there is a collision for this pixel. I am wondering on how to implement
this... I need to be able to scroll this array to follow the scrolling of
the game, to poke a shape into it, and retreive every pixel individually.
The size of this array can be quite big, bigger than the screen.
Should I do it by hand : reserve an array of bytes, and poke the shapes
myself, and do the collision detection. I fear that the scrolling would be
very slow, and that the overall performance would be bad. Is there a utility
class to shift the data in an array by an offset?
Should I use a BufferedImage of BINARY type? This would be really easy for
poking the shapes into it, and scrolling would be fast. But to get the data,
I would have to use the raster class, and the only way of getting the data
is to copy them into an array of Int (or float/double even worse), with one
int per pixel! Imagine the size of the array, and the time needed to copy
the data. Do you know if there is a way of getting the data in the raster
without copying them in an array?
What do you think? Do you think that the by hand method would be fast
enough? Do you know any method of getting access to the raster data without
copy?
Thanks, Francois