A good bit of info here on the actual use of PBOs. It does depend on what you want to do with the data afterwards as to exactly which way is best to get the data back out of a texture, or indeed why it’s there in the first place (it’s an unusual place to have data that you want to read back to the client).
Thanks princec
Any chance at there being an LWJGL example? I want to use it to read pixels from a rectangle inside an image.
Heres a video of the game I’m currently working on, you can see how it lags when I destroy a piece of ground because it is reading the whole image.
That looks really interesting - reminds me of Soldat (which of course is a good thing). The code in that page should be trivial to port to LWJGL as the syntax is almost identical.
Thanks yep, it’s a Soldat clone (although with a lot of extra features). Soldat is my favourite game, I’ve played it for 6 years. I think it’s time there is a new version!
I’ll have have look and try get it working.
Thanks again,
roland
Also, do I have to do ByteBuffer.allocateDirect(size); each time I read the pixels? I found that it takes 37ms to do it on my big texture. Could I just allocate once in the constructor and then use the same ByteBuffer each time?
@roland, You game is much more cooler looking than my scorched earth type game:
I thought about making “holes” with vertexes, but couldn’t figure it out on my own, so I’m just cutting away at an Image.
Keep up the good work, inspirational, and I can’t wait to play your game.
Thanks
Your game is looking good. Do you randomly generate the ground? or do you load images from a file?
I once tried to make a game like yours, and it kind of worked, I think it would have been fun if I had stuck with it.
I’ll try to put a link up, although its extremely buggy and incomplete, just to show you an idea.
Some tips: In my game I have a scrolling background picture, you could put a different one in than the gradient image, or have multiple background images with the further back ones moving slower than the ones in front. You should also put some scenery images in such as trees and buildings.
You could also when exploding the ground, making particles fly up that the same colour of the pixel you destroyed, and also make pixels “fall down” if there are no pixels below them. (check
if ((image.getPixel(x,y) != 0) && (image.getPixel(x,y+1) == 0)) image.setPixel(x,y+1,image.getPixel(x,y));
Although I dont recommend using get and setpixel cos it’s real slow. But you get the idea?
You could also maybe use the mouse to control aiming since they are humans although that would be annoying for multiplayer on one PC.
It would be cool if you made it multiplayer, turn based but everyone shoots at the same time (or they have 10 seconds to shoot or something))
But that’s just my ideas.
True, tracing an image is quite hard (especially to make it fast), so I hope I can make it work. The good thing about using vertices is the physics are much easier than pixel physics (atleast for my game). So there wasn’t an easy choice.
go single player -> level 1 start -> wait for it to load
click on top left to choose towers and choose stone cannon
click somewhere above the ground and create a few towers.
Then click (B) on the top right (battle phase)
use mouse to aim and hold down left click for power.
Ground is randomly generated, yes, then I texture it and drop Grass on it. I am planning on having Parallax scrolling in the future (showing the other side of the map). I did have mouse aim, but as you might have been able to tell from the video, the map is an endless loop so determining if the angle should be to the left or right was a pain. During testing I found my self shooting a bullet (not affected by gravity) when my player was off screen, and saw the bullet come from the opposite side of the screen than I expected. It is (when it’s done) turn based, each player has 30 sec to move and shoot and 3 secs after shooting to move (hide). Not every player goes in the same order, it depends on the cool down time of the weapon you used last as to when you get to go next. I’m not going to have falling ground. I like the idea of building a cave, with a rocket launcher, to hide in (like I used to do in Worms).