Added: 2 years ago
From: thenewboston
Views: 26,034
Sort by time | Sort by thread (beta)

Link to this comment:

Share to:
see all

All Comments (75)

Sign In or Sign Up now to post a comment!
  • We thank you! My good bucky

  • WTF, my image just leave the screen in the right-bottom corner :D What I have to do?

  • @TheRicher112 yeah mine does this too

  • @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 I think it does have something to do with two monitors because I'm having the same exact issue.

  • Fixed it, checked the code over and over again and saw that I have typed 1! line wrong

  • 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 I've got the same problem :(

  • 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 don't waste your time on java. Java is a piece of shit.

  • 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.

  • in school i mean

  • They need to make a Java Coding class :D:D:D:D

  • 100th like :D

  • Comment removed

  • Comment removed

  • Comment removed

  • Adding a simple gravity "engine" is actually really simple.

    Simply put vy += 0.05; at the beginning of your update method in sprite!

  • Comment removed

  • 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 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 Exactly. The velocity is the same except the negative just shows its going the other way now. :)

  • @Farizard Im also Farzanumeric, logged in on a different email atm

  • do you go to school to teach your teacher? 

  • wouldnt it be easier to multiply a X velocity value by -1?

  • 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 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

  • I got error in ScreenManager.... Please tell me how to remove this error.

  • @shiwu117 Lol!

  • 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."

  • Go to school? I thought you already knew everything!

  • 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

  • woww thank you bucky!!!

    thank you sooo much for teaching me how to do stuff like this!

  • this is awesome!!!!!!

  • 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!!!

  • 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

  • this is my new screen saver!

  • LOL go to school and eat 5 dubble cheeseburgers at McDonald xD

  • 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 ^^

  • I had to write "s.getHeigth" to make mine work

    sprite.getHeight()>= s.getHeigth

  • Comment removed

  • Bucky, how about a collision between objects as well as boundries java tutorial?

  • 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.

    Great tutorials!

  • 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

  • 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 it's even easier in flash but that doesn't matter right.. we're here to learn Java :P

  • instead of not showing us the result you can just do it off fullscreen by not calling the setfullscreen method

  • 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 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.

  • @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.

  • 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.

  • you need to have a background of some sort, i just drew a white box

    "g.fillrect(0,0,2000,2000)"

  • @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()

  • 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.

  • 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

  • this is crazy cool

  • 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.

  • 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.

  • why do people call you bucky???????

  • His nickname i guess?

  • 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..

  • 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 ...

  • You have to learn somehow... you're not going to learn just by reading code

  • Could you also just multiply the velocity (when your setting it) by -1 instead of getting the absolute value?

  • absolute value is ALWAYS positive. If you multiply a positive number by -1, it will result in a negative:

    20 x -1 = -20

  • 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

  • lmao

  • wuts this lol

  • from raleigh? charlotte here

Loading...
0 / 00Unsaved Playlist Return to active list
    1. Your queue is empty. Add videos to your queue using this button:
      or sign in to load a different list.
    Loading...Loading...Saving...
    • Clear all videos from this list
    • Learn more