Hello everybody, im new to this site as well as Java! I have this game, well its not really a game, i’m just testing out things in java so see if i can do them, compile my knowledge, and then later on make an awesome game. So more than likely i will be coming back with a lot of question because most things in java i cant get unless i see and example or is personally taught to me. ;D
Well, i have this code right here, and i know this is VERY bad for a 2D game (with the for loop) but i mean, the logic to me sounds perfectly sound:
but prior to this i have no 2D Java gaming knowledge what so ever. ANY HELP WOULD BE USEFUL.
if (drawRect) {
g.setColor(Color.BLUE);
g.fillRect(dx, dy, 10, 10);
for (int x= 0; x < 500; x++) {
dx += 3;
}
repaint();
}
I have this inside my paint method. And to my understanding i set a keyListener to the Space bar to toggle drawRect to True. I would believe that whenever my space bar toggles to true it would create a blue rectangle, and start to change the x position dynamically by 3 on the x axis? Resulting in what looks like… a bullet? It just does not work. It does spawn the bullet? It just doesnt move. All help is accepted. I really need to to learn how to do this stuff… This is what i want to do later on in life. I just dont know where to start…
Thanks in advance,
- SquidNig