@TheRicher112 Yea same, I have tried changing many things, but the sprite cannot seem to stop and go the other way, its like the program cant correctly check the s.getHeight/Width, hmmm i wonder, would having 2 monitors mess this up? :( help
hey bucky, i have followed from 24 to 26 and followed all the codes and the positioning of x and its velocity is working correctly after moving from left to right when it reaches the edge of my screen to the right it bounces back to left, but my problem is the y axis my y doesnt seem to move, the movement of my sprite is just left to right, did i missed something about the y? i have been tinkering the codes for the get y and set y but i cant seem to find it, hope you could answer me, and thanks.
Hope that someone will reply to this: I have my image on the top left side of the screen and it doesn't want to move at all, it's just flippin' a lil bit(about 1 or 2 pixels) but nothing more. The animation works. I tried to set the thread.sleep to 10 and it seems be moving more, but not significantly. I checked the code but that's alright... Suggestions?
The multiplying by -1 method works, but can cause a glitch at the edge of the screen if your image goes over too far before the update and then has a subsequent update before getting completely back to the screen area... it will then reverse its direction toward the border again because it receives the -1 value multiplier again. The absolute value method he gave you should correct this.
@Farzanumeric I was trying to post something like that myself, but youtube didn't like my comment-code. Basically, you mean just to make an if(condition || condition) and setVelocity to negative getVelocity, right?
@maradona640 maybe that's because you probably have some heavy images! you could change the line: w.createBufferStrategy(2); in your setFullScreen method... you just got to change the number 2 by a greater number and see what happens! hope it helps!
i have a problem i imported the java.awt.* and javax.swing.* but still the sprite thing dont work like when you put sprite.getX it gives me errors HELP ME
And now, with this new power, I shall make a GENERIC SCREENSAVER! And all shall tremble before my 350 lines of code. And college graduates from the farthest corners of the Earth shall ask of me, "Sire, tell us how thou didst achieve this marvelous wonder!" And I will say, "lol nope."
Flash an Visual Basic are both inferior to Java, but even yet Java is inferior to C++ and C. You have to have a JRE to make a Java program run whereas with C or C++ it creates a .exe that needs no files to run.
However the Android OS for phones is pretty cool ;D
HAHA bucky .... I did that last week too haha ... I need a GPS on my darn carkeys ... but losing my car as well .... my mind won't be far behind that I guess ^^
Mine was a little choppy, so I changed the Thread.sleep to 10 for smoother animation in the movieLoop. You can also comment out that try/catch block for no restrictions.
Visual Basic is not cross-platform and you are limited to what you can do. Visual basic sucks compared to Java. Maybe once you learn more programming, you will see that too.
@beleivezit I am pretty sure it's because. When each image loads the Java screen still needs to be refreshed. So In my opinion is all double buffing is refreshes the screen so you can see what has happened from before.
In Java, the screen is never cleared. If you look at your code, your background is re-drawn over all previous drawings then your sprite is redrawn. That is why your trail is cleared.
cool it works =D what im wondering about is how to make it move from moving the mouse or using the arrow keys but i guess i will be learning that in another tutorial
it's supposed to leave a "trail", correct? I didn't put a background or anything. I have the "Sprite" moving around the screen, everything's working... it's just I see pictures left behind from its previous location. thus, leaving a trail.
In Java the screen is never automatically cleared. If you don't want to see the trail, call the Graphics.clearRect(int,int,int,int) method before the drawImage() in draw()
I don't think Math.abs() was necessary to use. Since if going to left velocity is negative, and if going to right velocity is positive. So having to use the - before the expression would've sufficed.
back in 2000 when my mum and my brother got to go aroudn the world with 1 of my cousins and some friends i had to stay at my aunties (dad worked shift work) i was only 9 at the time but yeah that aside
it took us 4 hours to find the car again at the air port sydney international air port has over 3k parking spots
lol at the venting.. I live in fuquay, but I hate the traffic in Raleigh also.. parking at wake tech main campus in the beginning of fall semester wasn't fun either..
Yes, but the velocity would have to be negative to go left on the screen so multiplying it by -1 would make it positive, so going right then. Same if it was going right, it would have to be positive, then would turn negative once multiplied by -1.
But imagine if, for some reason, the sprite found itself off the screen in two consecutive updates, it would be stuck going back and forth off the edge of the screen.
That could probably only happen if the velocity was reduced between updates. I haven't been following this series so I don't know if that can even happen with the way he's coded it.
Sweet nice work but my image is jerking just alitle when it moves but it may be due to the fact my computer sucks(getting a new one soon) but maby in a future tutorial you could go over setting the fps and or transparent color setting if possiable thanks
We thank you! My good bucky
GamesByBeast 1 month ago
WTF, my image just leave the screen in the right-bottom corner :D What I have to do?
TheRicher112 3 months ago
@TheRicher112 yeah mine does this too
leopardtate 2 months ago
@TheRicher112 Yea same, I have tried changing many things, but the sprite cannot seem to stop and go the other way, its like the program cant correctly check the s.getHeight/Width, hmmm i wonder, would having 2 monitors mess this up? :( help
00kopoka 4 weeks ago
@00kopoka I think it does have something to do with two monitors because I'm having the same exact issue.
stbrobbins 2 days ago
Fixed it, checked the code over and over again and saw that I have typed 1! line wrong
Togglevolt 3 months ago
hey bucky, i have followed from 24 to 26 and followed all the codes and the positioning of x and its velocity is working correctly after moving from left to right when it reaches the edge of my screen to the right it bounces back to left, but my problem is the y axis my y doesnt seem to move, the movement of my sprite is just left to right, did i missed something about the y? i have been tinkering the codes for the get y and set y but i cant seem to find it, hope you could answer me, and thanks.
tikyorules 3 months ago
@tikyorules I've got the same problem :(
Togglevolt 3 months ago
Hope that someone will reply to this: I have my image on the top left side of the screen and it doesn't want to move at all, it's just flippin' a lil bit(about 1 or 2 pixels) but nothing more. The animation works. I tried to set the thread.sleep to 10 and it seems be moving more, but not significantly. I checked the code but that's alright... Suggestions?
neutronIRT 4 months ago
@neutronIRT don't waste your time on java. Java is a piece of shit.
6580006247 3 months ago
The multiplying by -1 method works, but can cause a glitch at the edge of the screen if your image goes over too far before the update and then has a subsequent update before getting completely back to the screen area... it will then reverse its direction toward the border again because it receives the -1 value multiplier again. The absolute value method he gave you should correct this.
cbeard05 4 months ago
in school i mean
Trialtrex21 4 months ago
They need to make a Java Coding class :D:D:D:D
Trialtrex21 4 months ago
100th like :D
monkeyvonspencer 4 months ago
Comment removed
TheAngel2ome 5 months ago
Comment removed
TheAngel2ome 5 months ago
Comment removed
zerohourkevin 5 months ago
Adding a simple gravity "engine" is actually really simple.
Simply put vy += 0.05; at the beginning of your update method in sprite!
Walnooot 6 months ago
Comment removed
KrisThePolishman 7 months ago
It's more efficient to multiply the velocity by -1. This will cover both exiting left and right. you can cut down the conditions by half.
Farzanumeric 8 months ago
@Farzanumeric I was trying to post something like that myself, but youtube didn't like my comment-code. Basically, you mean just to make an if(condition || condition) and setVelocity to negative getVelocity, right?
DarkYuan4 5 months ago in playlist Java Game Development Tutorials
@DarkYuan4 Exactly. The velocity is the same except the negative just shows its going the other way now. :)
Farizard 5 months ago
@Farizard Im also Farzanumeric, logged in on a different email atm
Farizard 5 months ago
do you go to school to teach your teacher?
gd1gc 8 months ago
wouldnt it be easier to multiply a X velocity value by -1?
jdatabean 9 months ago
idk if this is supposed to happen but mine just moves like a couple of pixels diagonally and switches between images and there is a lot of flashing
maradona640 9 months ago
@maradona640 maybe that's because you probably have some heavy images! you could change the line: w.createBufferStrategy(2); in your setFullScreen method... you just got to change the number 2 by a greater number and see what happens! hope it helps!
guerrero006 6 months ago
i have a problem i imported the java.awt.* and javax.swing.* but still the sprite thing dont work like when you put sprite.getX it gives me errors HELP ME
Banjokazooie42 9 months ago
I got error in ScreenManager.... Please tell me how to remove this error.
shiwu117 9 months ago
@shiwu117 Lol!
Haroids 5 months ago
And now, with this new power, I shall make a GENERIC SCREENSAVER! And all shall tremble before my 350 lines of code. And college graduates from the farthest corners of the Earth shall ask of me, "Sire, tell us how thou didst achieve this marvelous wonder!" And I will say, "lol nope."
TheSpongeTom 10 months ago 38
@TheSpongeTom lol
302MineCrafter 2 months ago in playlist Java Game Development Tutorials
Go to school? I thought you already knew everything!
noideayo 11 months ago
so coool :)
It randlomly changes the speed if you add (Math.abs(sprite.getVelocityX()) * Math.random() + Math.random())
and change velocity and position from float to double
mufaPufaDha 11 months ago
woww thank you bucky!!!
thank you sooo much for teaching me how to do stuff like this!
TheGreekSkater 11 months ago
this is awesome!!!!!!
Randude14 11 months ago
Mine doesn't work, I copied the script but it doesn't work!
Please someone help!
When I press the run button, I see that my comp is thinking (I see a hourglass for a sec) and then nothing happens
Maybe it's about my hardware, maybe it can't handle running it
I have:
CPU: 2.01GHz single core
GPU: ATI x1600pro 256mb(DX9; Shader3.0; doesn't support OpenGL)
Motherboard: Old piece of s***
RAM: 1GB ddr
please help!!!
HomelessShrimps 1 year ago
Flash an Visual Basic are both inferior to Java, but even yet Java is inferior to C++ and C. You have to have a JRE to make a Java program run whereas with C or C++ it creates a .exe that needs no files to run.
However the Android OS for phones is pretty cool ;D
buzzy918 1 year ago
this is my new screen saver!
LivingSkits 1 year ago
LOL go to school and eat 5 dubble cheeseburgers at McDonald xD
IobbyI90 1 year ago
HAHA bucky .... I did that last week too haha ... I need a GPS on my darn carkeys ... but losing my car as well .... my mind won't be far behind that I guess ^^
gam35guru 1 year ago
I had to write "s.getHeigth" to make mine work
sprite.getHeight()>= s.getHeigth
xXZarlachXx 1 year ago
Comment removed
xXZarlachXx 1 year ago
Bucky, how about a collision between objects as well as boundries java tutorial?
dashbyictfd 1 year ago
Mine was a little choppy, so I changed the Thread.sleep to 10 for smoother animation in the movieLoop. You can also comment out that try/catch block for no restrictions.
coydigga 1 year ago
Visual Basic is not cross-platform and you are limited to what you can do. Visual basic sucks compared to Java. Maybe once you learn more programming, you will see that too.
Great tutorials!
theballerplaya 1 year ago
agreed with java you can do so much more it just takes a little longer to learn but it pays off in the long run
cplusplustutorialman 1 year ago
shit, it took me 10 min to figure out how to do this with visual basic, and with java it takes 26 tutorials :P.
vikingablod1016 2 years ago
@vikingablod1016 it's even easier in flash but that doesn't matter right.. we're here to learn Java :P
MrJimmySegers 1 year ago
instead of not showing us the result you can just do it off fullscreen by not calling the setfullscreen method
MrKiller00224 2 years ago 29
if you make a backgroup it stops the trail (i think its cuz the buffering that copys the image is done behind the sceens)
anyone know the exact reason?
beleivezit 2 years ago
@beleivezit I am pretty sure it's because. When each image loads the Java screen still needs to be refreshed. So In my opinion is all double buffing is refreshes the screen so you can see what has happened from before.
poke1103 2 years ago
@beleivezit
In Java, the screen is never cleared. If you look at your code, your background is re-drawn over all previous drawings then your sprite is redrawn. That is why your trail is cleared.
ra4king 1 year ago
cool it works =D what im wondering about is how to make it move from moving the mouse or using the arrow keys but i guess i will be learning that in another tutorial
11wesley11 2 years ago
it's supposed to leave a "trail", correct? I didn't put a background or anything. I have the "Sprite" moving around the screen, everything's working... it's just I see pictures left behind from its previous location. thus, leaving a trail.
chocobosROK 2 years ago
you need to have a background of some sort, i just drew a white box
"g.fillrect(0,0,2000,2000)"
tagalala123 2 years ago 7
@chocobosROK
In Java the screen is never automatically cleared. If you don't want to see the trail, call the Graphics.clearRect(int,int,int,int) method before the drawImage() in draw()
ra4king 1 year ago
I don't think Math.abs() was necessary to use. Since if going to left velocity is negative, and if going to right velocity is positive. So having to use the - before the expression would've sufficed.
gasto5 2 years ago
lol 90 minutes isnt to bad
back in 2000 when my mum and my brother got to go aroudn the world with 1 of my cousins and some friends i had to stay at my aunties (dad worked shift work) i was only 9 at the time but yeah that aside
it took us 4 hours to find the car again at the air port sydney international air port has over 3k parking spots
frobinhood 2 years ago
this is crazy cool
venomchris 2 years ago
Oh and by the way the Images class is still calling to the old Screen class, I don't know if you want to fix that or not.
SirStiller 2 years ago
Dude I work at McDonald's, get a McDouble instead of a Double it has one less piece of cheese and it's like 20 cents less.
SirStiller 2 years ago
why do people call you bucky???????
georgewig 2 years ago 2
His nickname i guess?
MWGlitchers 2 years ago
lol at the venting.. I live in fuquay, but I hate the traffic in Raleigh also.. parking at wake tech main campus in the beginning of fall semester wasn't fun either..
jeffgreenback 2 years ago
don't you have the code for this uploaded somewhere ?
taht would be SO much better than watching your video and retyping, watching your video and retyping, watching your video and retyping ...
IronChefWannabe 2 years ago
You have to learn somehow... you're not going to learn just by reading code
SirStiller 2 years ago
Could you also just multiply the velocity (when your setting it) by -1 instead of getting the absolute value?
Believer424 2 years ago
absolute value is ALWAYS positive. If you multiply a positive number by -1, it will result in a negative:
20 x -1 = -20
MWGlitchers 2 years ago
Yes, but the velocity would have to be negative to go left on the screen so multiplying it by -1 would make it positive, so going right then. Same if it was going right, it would have to be positive, then would turn negative once multiplied by -1.
Believer424 2 years ago
But imagine if, for some reason, the sprite found itself off the screen in two consecutive updates, it would be stuck going back and forth off the edge of the screen.
That could probably only happen if the velocity was reduced between updates. I haven't been following this series so I don't know if that can even happen with the way he's coded it.
armpitpuncher 2 years ago
Sweet nice work but my image is jerking just alitle when it moves but it may be due to the fact my computer sucks(getting a new one soon) but maby in a future tutorial you could go over setting the fps and or transparent color setting if possiable thanks
WSPSNIPER2 2 years ago
lmao
1deividas1 2 years ago
wuts this lol
qwertygustaf 2 years ago
from raleigh? charlotte here
NoTaTtHiScHoOl 2 years ago