Uploader Comments (MrJavaHelp)
Top Comments
-
he bought a new mic thumbs up for that
-
if i leave space pressed infinite bullets appear :/ what can i do about it?
All Comments (32)
-
@geronimoaris Use a timer with a thread class. and allow the space to only be effectively fired every 30-40 ms.
-
You leave a lot out in the videos, you include it in the source code but, it would be much more professional if you showed everything in the videos.
-
I have been playing around with this and I can't seem to figure out how to make the bullets able to shoot in each of the four directions.
-
@MrJavaHelp How to just draw a pixel??? or a rectangle?
-
Dude, this tutorial you made helped me out SO MUCH for my final project in my game development class! Thank you very much!
-
I dont really understand the purpose of the Array List, is there no other way to do it without the Array List?
-
Control + Shift + F To fix up your code and make it easier to read.
-
@MrSoluther 6:20 He takes about the bullets creation and he uses the character's height divided by 2, this is the figure you need to change.
-
@geronimoaris Add a counter which checks how many bullets are alive and have it increment when a new one is made and decrement when an old one is destroyed. Then have some code check if that counter is equal to the max and don't let it make new bullets if it is.
why is the arrayList static?
liorlolobobo 1 year ago
@liorlolobobo Just so that every other classes has access to it and it is the same array across all classes.
MrJavaHelp 1 year ago
@MrJavaHelp can't you just make a method : Bullet[] getBullets() ?
liorlolobobo 1 year ago
@liorlolobobo You can!
You can do a lot of things differently, but the way I did it seemed the most logical:
- Creating an array of all bullets.
- Adding to array as the fire() method is called (user presses space).
- Checking constantly if any of the bullets in the array have a coordinate greater than 700 (out of screen) and if so, removing it from array (done in actionPerformed method).
- Lastly, going through whole array and printing each bullet (in paint method).
Thanks,
MrJavaHelp
MrJavaHelp 1 year ago