Sorry if the title is a little... vague. Anyway, I'm making a platformer using java and I've been trying to create a pressure plate triggered dispenser that shoots poisoned darts. The game is pretty much split up into a grid system, with each block being a spot on the grid. so far I've made it so that when the pressure plate is activated, it looks as if it's pressed down. I've also been able to draw it to the screen but it does not move or anything. This is the code I use to draw it to the screen:
public void drawDart(Graphics g) {
if(Component.isPressed) {
for(int x = 0; x < block[0].length; x++) {
for (int y=0; y < block[0].length; y++) {
if(x == 91 && y == 35) {
block[x][y] = new Block(new Rectangle(x * Tile.tileSize, y * Tile.tileSize, Tile.tileSize, Tile.tileSize), Tile.poisonDart);
}
}
}
}
}
Unfortunately, with this code when I step on the pressure plate, the dart is drawn, but will not move. I've tried using x++ before but that doesn't move the dart at all.
Another problem is that I would like the dart to look like it's affected by gravity, which is hard to do when the game is split into a large grid system. Either way, what do you guys think?
Moderator edit (moved from OP comment):
block[x][y] = new Block(new Rectangle(x * Tile.tileSize, y * Tile.tileSize,
Tile.tileSize, Tile.tileSize), Tile.poisonDart);