@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.
i dont mean to be a stickler for detail, but it might help people who are just learning if you used more "proper" coding terminology. for example, you consistently referred to methods as classes, which left me staring at my code for 10 minutes wondering what i had done wrong. but besides that the videos are absolutely AMAZING!!! thank you so much.
Hi, I have a question. I've made it so my bullets fire at y-coordinates "y+33" so they come from around my chest area. The problem is that if I jump all the bullets jump with me. I just want them to always be around my chest when they're launched, not when they're already flying. Would be cool if someone could give me an explaination on how to do this. :)
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).
Comment removed
jikiwaify 2 weeks ago in playlist Java Game Programming: 2D Side Scroller
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.
Stormrage32 1 month ago in playlist More videos from MrJavaHelp
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.
x3zinja12 1 month ago in playlist Java Game Programming: 2D Side Scroller
@MrJavaHelp How to just draw a pixel??? or a rectangle?
IckbinderTod 1 month ago
Dude, this tutorial you made helped me out SO MUCH for my final project in my game development class! Thank you very much!
KingBowser444 2 months ago
I dont really understand the purpose of the Array List, is there no other way to do it without the Array List?
scottyy888 3 months ago
Control + Shift + F To fix up your code and make it easier to read.
MrPitbull917 3 months ago in playlist Java Game Programming: 2D Side Scroller
if i leave space pressed infinite bullets appear :/ what can i do about it?
geronimoaris 5 months ago 7
@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.
RyanfaeScotland 4 months ago in playlist Java Game Programming: 2D Side Scroller
@geronimoaris Use a timer with a thread class. and allow the space to only be effectively fired every 30-40 ms.
AjanWIN 2 weeks ago
whats the w int?
geronimoaris 5 months ago
i dont mean to be a stickler for detail, but it might help people who are just learning if you used more "proper" coding terminology. for example, you consistently referred to methods as classes, which left me staring at my code for 10 minutes wondering what i had done wrong. but besides that the videos are absolutely AMAZING!!! thank you so much.
trollz4tehlolz 5 months ago
were do i go to make the bullet fire higher up (im very new to most of this)
MrSoluther 5 months ago
@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.
RyanfaeScotland 4 months ago in playlist Java Game Programming: 2D Side Scroller
I completely understand... none of it.
just kidding, i actually get most of it.
contactron 5 months ago
you are a life savior!!
thanks!
DnlJackson 6 months ago
he bought a new mic thumbs up for that
taperi5 6 months ago 20
can we get a copy of this code plsss??
blood4you20 6 months ago
can we get the copy of this code?? plssss
blood4you20 6 months ago
what game engine do you use?
EPHRAIMDify 7 months ago
@EPHRAIMDify none
Prussiaaccount 6 months ago
were u using netbeans to write your programs?
izzycat67890 8 months ago
Hi, I have a question. I've made it so my bullets fire at y-coordinates "y+33" so they come from around my chest area. The problem is that if I jump all the bullets jump with me. I just want them to always be around my chest when they're launched, not when they're already flying. Would be cool if someone could give me an explaination on how to do this. :)
MegaTrekant 8 months ago
How do you make it so that you can fire multiple bullets, so like have it fullyautomatic
xxmannylee1992xx 8 months ago
when my game loads my character doesn't show up till it loads the next image by walking forwards.
TheAdventuresClayMan 1 year ago
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
@MrJavaHelp Hi there, i'm using Bluej to create my game, so would the steps involved be any different? i've also inboxed you about it :) thanks
manzrnet 1 year ago
@manzrnet no they wouldn't. java is java.
Randude14 11 months ago
Man, your graphics are way awesome.
LCaaroe 1 year ago