To see how to read images in IntelliJ, please check this video: th-cam.com/video/Q9jtg0ocGgo/w-d-xo.html It seems quite a few people are struggling with "java.lang.IllegalArgumentException: input == null!" error. In case of this video, the error happens when the program fails to read sprite images. First, *make sure to check if your res folder has been registered as a source folder* Especially if you are not using Eclipse since the registration/resource reading process in other IDEs can be different from what I did in the video. Also, check if your file names/paths are identical to what you typed in the getPlayerImage method. Check for any unnecessary space, underscore, or other characters. *The file names and paths need to be completely identical.* If you cannot find any discrepancy, try using the same sprites in the video (the link is in the description). If you could display the images, the issue was caused by your modification so you can narrow it down. You can check if image loading is done properly or not by inserting these lines in the getPlayerImage method: System.out.println("Image loading started"); // load sprite images.... // load sprite images.... System.out.println("Image loading ended"); The loading was done properly if the second text was printed on the console. If only the first text was printed out, something went wrong during the loading and the program stopped there.
In my case i am doing it on vs code. This error occurred. I solve it by changing the path, in my case the path is: "./../src/player/boy_right_2.png", for example.
for IntelliJ users: 1) create "res" folder: - right mouse button on main project folder -> New -> Directory -> "res" 2) mark "res" folder as Sourses Root: - right mouse button on "res" folder -> mark directory as -> Sources Root 3) create "player" folder inside "res" folder: - right mouse button on "res" folder -> new -> Package -> "player" 4) paste images in "player" folder 5) you have to add .getClassLoader() between getClass() and .getResourceAsStream() OLD: up1 = ImageIO.read(getClass().getResourceAsStream("player/boy_up_1.png")); NEW: up1 = ImageIO.read(getClass().getClassLoader().getResourceAsStream("player/boy_up_1.png"));
My son and I finished episode 3 of your series tonight. You do an excellent job explaining everything and teach at the perfect pace. We were both so excited when the little blue haired boy started walking around. Will continue the series tomorrow with episode 4. Thank you!
If anyone is having issues where they are getting no errors but nothing is drawn be sure to add the getPlayerImage(); method to the player constructor in the Player class. (Just under setDefaultValues ();)
This series is so good. I've been interested in making actual games for a long time, but I've had a lot of struggle learnign unity, and I was about ready to give up, but now I've this AMAZING series to help me use the language I'm really familiar with to make real games. I've made some pretty cool console based games before, like this whole tower defense game which was displayed to the player exclusively in text, but games like that have obviously an incredibly niche appeal. That's why I'm so excited to really branch out like this. Please keep making these amazing videos.
@@Ashokkumar31082 I am a little late but he probably meant that he struggled with Unity, but now he found this tutorial to NOT use Unity to create his games, so that he doesn't struggle so much with making games. I hope I could enlighten you.
I came across your tutorials just a few days ago, but they are helping tremendously with making a space invaders esque game. Thank you so much Ive been learning a LOT
I now have ca. 3 or 4 years of programming experience in Java and Python. But sometimes I simply dont know how to implement somthing clean. Sure I could do it, but it will look like shit. You helped me a lot, how to implement all the stuff objectoriented. And a lot of times I think to abstract. Also I like your tutorials because you write all the stuff from scratch, only with the default java libarys. There are a lot of youtubers out there that would simply download Unity for 2D game development - im ok with that. But its hard to find good tutorials how to programm a 2D game engine from scratch. Also a lot of people is hating on Java, I cant understand that. Im intrested where you learned java. Keep it up, really good work and videos.
Yes, I also feel nothing against using engines such as Unity. If making a game is your sole purpose, using engine or library is a lot easier. That said developing it from scratch gives you deeper understanding on how game programs work and programming itself. Also, creating from scratch is fun! I'm glad you liked the videos. Always good to meet a fellow Java developer!
Great Tutorial! Ive been loving it so far! Please keep uploading! For anyone who uses another IDE than RyiSnow and can't fix the "java.lang.IllegalArgumentException: input == null!" error here are solutions for VS Code and Intellij that worked for me: For Intellij: 1. Create the "res" folder as a new package in the src folder/section 2. Create the player folder in res as player.res so that it is a package inside of the "res" package 3. Add /res to the file path in the getPlayerImage-method so that it becomes "/res/player/boy....." 4. enjoy For VS Studio: 1. Create the "res" folder in the src folder/section 2. Create the "player" folder in the "res" folder 3. Add /res to the file path in the getPlayerImage-method so that it becomes "/res/player/boy....." 4. enjoy The error most likely occurs because only the "src" folder is saved in the project source folder
@@mrshadow7399 unfortunately my game stopped working and i gave up 😆 i didn't find a solution, i am so sorry 🙏 Keep going and good luck, you'll eventually find the solution..
If your thinking led to the same question as mine : "Wait a minute, we already tested the upPressed, downPressed etc. Why test it again just to update the sprite?" You can also just update the spritecounter in the if slot of the update method, like so : public void update(){ if(keyH.upPressed) { direction = "up"; y -= speed; spriteCounter++;} I just think it looks cleaner as a whole. Now it accomplishes the same thing with less nesting, see which you like better. I sincerely hope I'm not offending the author with my suggestions. Thank you for the instructive series!
You're so incredibly talented at what you do. I hope you have a job that appreciates your skill and pays you generously for what you can do. I hope to someday be even 1/4 the developer that you are.
Thank you sir, I have always understood concepts of java but never really understood when to use them. Using your tutorial i was able to get a basic hold of 2d programming I hope you become a more popular teacher cause your teaching techniques are excellent and as always Thank You!
Gotta love forgetting to add break at the end of my case statements and spending like 5 minutes trying to figure out why only the left sprite is rendering. Love the Tutorials so far.
Your art skills are great, spent a few hours last night messing around with converting your guide to Android so far I have an un animated sprite that can move around the screen smoothly. I'm going to see what I can learn tonight, I feel so new lol.
Also I enjoy that you explain things easily, plus everything makes sense from someone that does have java experience! With your permission I may do guides on this while I'm following along to convert to Android 😁
How????? I am confused becasue we store BufferedImage objects, so we can create one 1 arrayList called images, that has all of the, but are we still creating up1, up2, down1, down2? or dont and just do image.add(ImageIO.read(getClass....etc ? But how do you get the string to change for "/player/boy_left1... or /player/boy_right2"???????? Can you show what you did?
Hello, in class Player when you import Gamepanel and Keyhandler you get option to do main.Gamepanl etc i do not get these options when i type it in myself I get an error saying the import main cannot be resolved. any solutions, Thanks.
i dont know what is happening my player sprite is not showing its showing the white rectangle only even though i have cut out the code for it. please help.
I require help. When I try to import "main.GamePanel" and "main.KeyHandler" nothing shows up. When I write the imports manualy, it is still an error, like it does not recognise the imports or something. Does anyone have an answer to this?
not sure if you still need help but.. i had a similar problem, turns out it was because my GamePanel and KeyHandler files were not in a "main" folder. when I added them to a folder called "main", it worked as it did in the video
I'm following along your tutorial, and I can say I'm having a lot of fun creating this game. Thank you for putting this together and for posting the resources needed to create the game. Your explanations are very easy to follow and does not take too long.
I have the solution for those of you, who are struggling with the error pinned in the comments and using VS Code (but you can give it a try in your IDE). I put the pictures in a single folder called player and then I moved the folder in the src folder. And then wrote this: File f1 = new File("./src/player/ninja_up_1.png"); File f2 = new File("./src/player/ninja_up_2.png"); File f3 = new File("./src/player/ninja_down_1.png"); File f4 = new File("./src/player/ninja_down_2.png"); File f5 = new File("./src/player/ninja_left_1.png"); File f6 = new File("./src/player/ninja_left_2.png"); File f7 = new File("./src/player/ninja_right_1.png"); File f8 = new File("./src/player/ninja_right_2.png"); up1 = ImageIO.read(f1); up2 = ImageIO.read(f2); down1 = ImageIO.read(f3); down2 = ImageIO.read(f4); left1 = ImageIO.read(f5); left2 = ImageIO.read(f6); right1 = ImageIO.read(f7); right2 = ImageIO.read(f8);
I'm making a game as a final project (the game is Tron the one of the movie, the motorcycles that leave a wall of light behind them), the thing is that I don't know how to make that wall and I've been searching a lot and I can't find how to do it. I don't know if you or someone from the community could help me, thank you very much in advance.
I get to the 7:10 test and the rectangle no longer moves :( I left the old if loop location updater in the GamePanel class and that box still moves. But the new box will not budge. Advice? I've got the new loop in the Player class, as well as updated all the x's and y's.
Incredible. What about storing the sprites inside an array? And better, having one single sprite sheet file and changing the position? For performance/memory. I think I will add these if it's not done on the videos to my version on my repository. Thanks a lot. Very fun tutorial.
I have this problem : i can move the rectangle so i guess in the key listener class and update method there s no error but when i import the images (i just copied like in the video) and run the program i can see my player in the defaultValues position and direction so the sprites are loaded but i can’t move it (i tried to comment the getPlayerImage(); and the g2.drawImage(x,y,gp.tileSize,gp.tileSize,null) and i wrote again g2.fillRect(x,y,gp.tileSize, ,gp.tileSize) , so i can move again the rectangle , but with te image loaded i can’t move the player and the program runs with no error
@@natesannatesan2220 I used a different key instead (VK_W,A,D,X OR SOMETHING 😊) , the arrow up, down, left, right (VK_UP,DOWN,LEFT,RIGHT) and it worked 😊. had the same problem hopefully it helped.
*my sprites are not drawing to the screen, i used the same sprites from video description everything loads in without any error but the sprites won't load to screen please help*
In case you haven't figured it out yet, you are probably missing some breaks in switch statement. It's such a stupid mistake but it slipped by me and hopefully its the same solution for you.
I can get the image to show on the window but not move (and I can also get the rectangle to move but only if its a rectangle not the image). There doesn't seem to be any syntax errors so I don't know what I did wrong. Pls help
18:57 u can try adding something like this : else if (spriteNum == 2) { spriteNum = 3; } else if (spriteNum == 3) { spriteNum = 4; } before he adds this: else if (spriteNum == 8) { spriteNum = 1; } it worked for me idk if its good but hey it works
Hi! This is an old video but I am trying to resolve an error I get at 9:32. package entity; import java.awt.image.BufferedImage; public class Entity { public int x, y; public int speed; public BufferedImage up, down, right, left; public String direction; } It gives me the error BufferedImage cannot be resolved. Does anyone know why? I'm using Eclipse.
Same issue for me too, BufferedImage cannot be resolved. also it mentions that BufferedImage is already indirectly referenced from required type java.awt.Graphics2D
this might be a little late but if i switch to bufferedimage, not even drawing the images, just assigning the pngs, my key binding seems to break, whenever i stop calling the method that assigns the pngs it goes back to normal, if i add any other functions with the images on they work just fine, but the key binding breaks, i'm not sure how keybinding focus works but it still seems quite awful
nevermind i'm leaving this comment here for people with the same problem, key binding's default focus is just as crappy as keylistener's, put JComponent.WHEN_IN_FOCUSED_WINDOW inside the getInputMap()'s parameter to fix this
I love that you did this. you're really great at teaching it srsly dude don't underestimate your talent. I greatly appreciate your videos, I'm doing this as a summer project and I make edm so I'm going to be making full tracks for different settings and looking forward to drawing little characters
you have nice tutorial, but i need help. for the character i have 3 pictures for up and down, and have 4 pictures for right and left. iam in 20:52 of the video and my character when he is gos de up and down show a moment when he dessapear because i have 4 spriteNumber and just 3 pictures for down and up. when hes go to the left or right hes looks normal but the problem is when hes go to up and down, hes disappear for a one frame!
Hello, I have a problem with my getPlayerImage() method, when I start the program an error occurred and it says "Caused by: java.lang.IllegalArgumentException: input == null!", I tried to change the path of my pictures but nothing changed. I have the same code as you but the only difference is the path for the pictures.
Sounds like the program is failing to load your image. Are you using png file? Also, check if you have spelled the file names right such as not forgetting to type underscore, back slash etc... that often happens.
@@RyiSnow To test the method I used your sprites so the image isn't a problem, I think. And I thought that the path was wrong too, but I checked several times and nothing
@@RyiSnow I sent like 5 times a message with my git depository, cause I couldn't write my code on commentary of this video, I don't know why, so is there another way to show you the code ?
@@marinasalonso2716 You cannot paste external link in TH-cam comment. It most likely gets regarded as spam. You cannot directly copy & paste your code here? If it still doesn't work, you can contact me via twitter.
Without setting that the direction variable is null (not instantiated) so you likely get NullPointer exception error. You need to set a value to avoid that either in Entity class or Player class.
Hello there. I just started learning a few days ago the beautiful language "java"..I am very glad I found your channel, a few video and already helped me understand more than just reading 📚. You deserve more views for sure. Keep up the good work. Wishing you a lot of success 🙌🏼
Hello, I have an error at 2:23 when you type -Player player = new Player(this.KeyH){}, here Player is at the beginning and Player after new I have an error and it says like this - Player cannot be resolved to a type , help me how can I fix it?
When I run it at 14:50 in the video the screen is white and I get a flood of errors like too many to write, the screen is white, and it says Cannot invoke “Object.getClass()” because “this.gp” is null. Can you help me with this?
It also says The method drawImage(BufferedImage, BufferedImageOp, int int) in the type Graphics 2D is not applicable for the arguments (BufferedImage, int, int, int, int)
I can't get my spirits into the res and player resource I don't know where to find it I don't know how to set my eclipse up where I can have that file selecting bar on the right
Apparently getClass().getRAS() starts at the root folder of the class so to get it to work like that you have to put the resources in the entity folder or package (w/e).
when you created the player, you passed this, here you don't accept it at all, it keeps asking for cast. I do it to later give an error of creating local variable.
The scwitch(direction) fall dont work: i try this: BufferedImage image = switch (direction) { case "up" -> (spriteNum == 1) ? up1 : up2; case "down" -> (spriteNum == 1) ? down1 : down2; case "right" -> (spriteNum == 1) ? right1 : right2; case "left" -> (spriteNum == 1) ? left1 : left2; default -> null; }; but i can only see 1 Picture at every way..
@@kira890 i think i found a workaround by putting the folder that i used for my sprites into the folder that had something to do with my project.. i forgot LOL but after i did that i could use the name of the file to refer to it if you’re interested i can find my code and see what i did exactly :p
does anyone get this error Error: Could not find or load main class main.Main Caused by: java.lang.ClassNotFoundException: main.Main. when they create the source folder res @8:30
Hey I love your videos. But i got a question about the animation. The update method is based on the number of FPS. Which means that with the system you made, a person with 30 fps on the game will have 2x slower animation and a person with 120 fps 2x faster. Is there a way to have the same animation speed regardless of fps?
Yes, I think you can set the speed based on fps. Example: int speed = 240/FPS; This returns 4 if fps is 60 and returns 8 if fps is 30 so the player speed stays the same. That said if you set fps 241 or more, the speed becomes 0 (since int doesn't accept decimal) so player won't move at all in that case. So probably you'll need to change it to double and arrange the code a little bit. Like counting decimal behind the scene and when it hits 1, apply the movement or something.
Hi, I just realized that you were asking about the animation, not the player's movement speed. Maybe you've already figured it out but you can also set the sprite counter based on fps so the interval between sprite 1 and 2 stays the same.
I’ve been following your tutorials to the t so far, but when after shifting the key input stuff to the player class and after clicking run, the square doesn’t move at all, do you have any clue what the problem could be? no errors are popping up, it’s just not getting my key inputs for some reason edit - never mind, I forgot to put the player update inside the game panel update
I'm stuck in running with new images @sts (spring tool suite application), it's getting me null when read image or maybe my folder res structure. Thank you and I'm sorry..
you can scale up the process to include more image files, essentially what was done in the tutorial but repeated for each file. You'll have to add a line variables in Entity to initialize the extra files, add lines in getPlayerImage() to read the extra files, and modify the if statement with sprite counter to switch spriteNum more than just two times. You can use modulo to make the spriteNum if statement easier too, doing spriteCounter % 10 == 0 in the if statement and removing spriteCounter = 0; at the end will change the sprite every second, rather than hard coding it in for every second. since modulo returns 0 anytime x is divisible by y, thus it will change any time spriteCounter is divisible by 10 (10, 20, 30, etc...), add an else statement at the end to set the spriteNum back to 1 to display the idle sprite while not moving and re add spriteCounter = 0; in there as well.
I was working with vscode and when i downloaded intellij and copy and pasted all my vscode onto there after mimicing RyiSnow's file structure exactly i got it to work. Im gonna try to push it to github so that i can pull it back onto a vscode editor. I guess my compiler is just limited in what it can do.
For anyone wondering how to resolve the error in VS code. Just right click on the res folder and select "add folder to java source path." this worked for me.
I am having trouble with the movement(I have followed all the directions properly but I think that the movement logic is wrong in the tutorial) -When I press right then while right is still pressed, I press up or down, the sprite will move up or down and when I let go of up or down (remember right is still pressed), the sprite will continue to go right. - The problem is that this does not work for when I am going up and then I want to go left or right. - There is something wrong with the if statements, we check for up before down,left and right so anything below in the if statement is overruled by everything above. Is is there any way I can fix this bug?
hello, Thank you for this video, it is very helpful. However, I would like to ask why is there no visible image is showing on my window since I added the sprites, I check everything and I am confused. I used eclipse, thank you for your help!
God is good and I am getting a little better in troubleshooting. the mistake I made that should be avoided on this video was that I did not include the line of code, "import java.awt.image.BufferedImage; " right after the " package entity;" in the Entity class. To all my peers, I would encourage you to make sure all your imports are added. This will solve a lot of your problems. To our teacher @RyiSnow, for future tutorials, please call more attention to when you import something or click to import something. Sometimes you click so fast and if I blink, I miss where you click to have Eclipse automatically import something. Sometimes, I do not ever see it, but I know it is there. So far, I have been able to use Eclipse to track it down. Other Input: MSpaint and Gimp both are good alternatives to make Pixel art. The only problem with MSpaint is that it is difficult to make it 16x16px, but if you make your draw area close to square and draw your images, you can use Gimp to both resize your image to 16x16px and a few simple clicks will make the white background transparent. You should be able to do everything inside of Gimp, but I am not yet well versed with Gimp as I am MsPaint as of yet. Gimp is almost as powerful as Photoshop and is completely free and opensource, so it is worth learning. Fun Thought: I have considered taking photos of myself, and other people, in all of the same poses as your little boy sprite and inserting that into the game. Yes, I could probably do animated pixel art also, but I am talking about just unedited pictures except for the 16x16px resizing and making the background transparent.
Hey man I keep getting this error and I think it has something to do with imports you think you can take a look ---------------------------------- package entity; import java.awt.Color; import java.awt.Graphics2D; import java.awt.image.BufferedImage; import java.io.IOException; import javax.imageio.ImageIO; import main.GamePanel; import main.KeyHandler; public class Player extends Entity{
GamePanel gp; KeyHandler keyH;
public Player(GamePanel gp, KeyHandler keyH) {
this.gp = gp; this.keyH = keyH;
setDefaultValues(); getPlayerImage(); }
public void setDefaultValues() { x = 100; y = 100; speed = 4; direction = "down"; }
@@megha9307 I am going to take a wild guess at what your problem is, but without seeing all of your code and not just your player class, it is hard to tell, but I am going to give you a few things to look for and there is a good chance you will find it on your own and be a better programmer for it. First, see if it helps to add import javax.imageio.ImageIO; to your entity class for reasons I explain below. If that doesn't work and if you are using eclipse like Ryisnow and me, read the error line and see exactly what it reads. It will give you a lot of clues. Remember that your player class extends the entity class. You pasted your code for the Player class. If you happen to forget an import in your Entity class, it can cause an error on your Player class and cause it not to work. Be watchful of each time Ryi uses a variable or attribute from another class. You might be working in the Player class and think you should import something there when you should import something to the Entity class because that is where that item in question originates. The same goes for making variables public when you call them from a different class than where they were declared. In a video coming up there is an instance where Ryi forgets to make a certain variable public and has to go back and make it public, so the program will work. I do not remember if this applies to both folders and packages, but this definitely applies to packages. Each time Ryi has you create a new package or a new folder, you have to import your main class or some other class to that new class you just created or vice versa, so it is not isolated and can talk to the rest of your program. Eclipse will often do this with a couple of clicks and Ryisnow will click so fast to generate that import automatically that if you blink, I assure you will miss it. I have also had a few instances where Eclipse offered to generate that import line of code for Ryisnow, but it wouldn't do it for me, so I had to read the error details very carefully and figure out which import line of code I needed to add and add it manually. Good luck and comment back when you figure it out because these comments help other people with their code also!
To see how to read images in IntelliJ, please check this video:
th-cam.com/video/Q9jtg0ocGgo/w-d-xo.html
It seems quite a few people are struggling with "java.lang.IllegalArgumentException: input == null!" error.
In case of this video, the error happens when the program fails to read sprite images.
First, *make sure to check if your res folder has been registered as a source folder*
Especially if you are not using Eclipse since the registration/resource reading process in other IDEs can be different from what I did in the video.
Also, check if your file names/paths are identical to what you typed in the getPlayerImage method. Check for any unnecessary space, underscore, or other characters. *The file names and paths need to be completely identical.* If you cannot find any discrepancy, try using the same sprites in the video (the link is in the description). If you could display the images, the issue was caused by your modification so you can narrow it down.
You can check if image loading is done properly or not by inserting these lines in the getPlayerImage method:
System.out.println("Image loading started");
// load sprite images....
// load sprite images....
System.out.println("Image loading ended");
The loading was done properly if the second text was printed on the console. If only the first text was printed out, something went wrong during the loading and the program stopped there.
In my case i am doing it on vs code. This error occurred. I solve it by changing the path, in my case the path is: "./../src/player/boy_right_2.png", for example.
@Jackson Hello man. Look my answer below, it could help you!
@@unity_with_timoteo did you type this "./../src/player/boy_right_2.png" only or not
@Jackson did you can compile it?
you should pin this comment, it was very helpfull.
for IntelliJ users:
1) create "res" folder:
- right mouse button on main project folder -> New -> Directory -> "res"
2) mark "res" folder as Sourses Root:
- right mouse button on "res" folder -> mark directory as -> Sources Root
3) create "player" folder inside "res" folder:
- right mouse button on "res" folder -> new -> Package -> "player"
4) paste images in "player" folder
5) you have to add .getClassLoader() between getClass() and .getResourceAsStream()
OLD:
up1 = ImageIO.read(getClass().getResourceAsStream("player/boy_up_1.png"));
NEW:
up1 = ImageIO.read(getClass().getClassLoader().getResourceAsStream("player/boy_up_1.png"));
This comment right here is pure gold, thank you so much ❤❤
I had to add a try catch to getPlayerImage()
try {
getPlayerImage();
}catch (Exception e){
System.out.println("getPlayerImage() is not working");
}
there's several solutions posted for IntelliJ, but somehow NOTHING works for me... always get NullPointerException
I give up
omg I just forgot to add
setDefaultValues();
getPlayerImage();"
I'm so annoyed at myself :((((
Thank you!
My son and I finished episode 3 of your series tonight. You do an excellent job explaining everything and teach at the perfect pace. We were both so excited when the little blue haired boy started walking around. Will continue the series tomorrow with episode 4. Thank you!
It warms my heart to hear that! I hope you and your son will keep enjoying coding :)
You deserve more viewers! I have learned so much from you
Glad it helped! Thank you for the comment.
Well most ppls don't play java games no more except for me
@@thenolife1957 minecraft is originally made in java
@@faced2404 except from that
Heheeee
If anyone is having issues where they are getting no errors but nothing is drawn be sure to add the getPlayerImage(); method to the player constructor in the Player class. (Just under setDefaultValues ();)
thx
@@easypeezy9142 Glad I could help 😄
I was stuck for 2 hours. Thank you very much!
@@RealSenn You're welcome 😄 I'm glad I could help!
TYSM!!!!
This series is so good. I've been interested in making actual games for a long time, but I've had a lot of struggle learnign unity, and I was about ready to give up, but now I've this AMAZING series to help me use the language I'm really familiar with to make real games.
I've made some pretty cool console based games before, like this whole tower defense game which was displayed to the player exclusively in text, but games like that have obviously an incredibly niche appeal. That's why I'm so excited to really branch out like this.
Please keep making these amazing videos.
wut this aint unity lol
@@Ashokkumar31082 I am a little late but he probably meant that he struggled with Unity, but now he found this tutorial to NOT use Unity to create his games, so that he doesn't struggle so much with making games. I hope I could enlighten you.
I came across your tutorials just a few days ago, but they are helping tremendously with making a space invaders esque game. Thank you so much Ive been learning a LOT
I now have ca. 3 or 4 years of programming experience in Java and Python. But sometimes I simply dont know how to implement somthing clean. Sure I could do it, but it will look like shit. You helped me a lot, how to implement all the stuff objectoriented. And a lot of times I think to abstract.
Also I like your tutorials because you write all the stuff from scratch, only with the default java libarys. There are a lot of youtubers out there that would simply download Unity for 2D game development - im ok with that. But its hard to find good tutorials how to programm a 2D game engine from scratch. Also a lot of people is hating on Java, I cant understand that.
Im intrested where you learned java.
Keep it up, really good work and videos.
Yes, I also feel nothing against using engines such as Unity. If making a game is your sole purpose, using engine or library is a lot easier. That said developing it from scratch gives you deeper understanding on how game programs work and programming itself. Also, creating from scratch is fun! I'm glad you liked the videos. Always good to meet a fellow Java developer!
I’m an elementary student, this is very easy to understand, thanks!
Man. you are actually a legend. You deserve like more than 1 mil subscribers. Youre the greatest!
Great Tutorial! Ive been loving it so far! Please keep uploading!
For anyone who uses another IDE than RyiSnow and can't fix the "java.lang.IllegalArgumentException: input == null!" error here are solutions for VS Code and Intellij that worked for me:
For Intellij:
1. Create the "res" folder as a new package in the src folder/section
2. Create the player folder in res as player.res so that it is a package inside of the "res" package
3. Add /res to the file path in the getPlayerImage-method so that it becomes "/res/player/boy....."
4. enjoy
For VS Studio:
1. Create the "res" folder in the src folder/section
2. Create the "player" folder in the "res" folder
3. Add /res to the file path in the getPlayerImage-method so that it becomes "/res/player/boy....."
4. enjoy
The error most likely occurs because only the "src" folder is saved in the project source folder
THANKYOU SO MUCH
it happens to me in eclipse, i don't know why, could you please help me?
@@gCoder_ same issue, did you find a solution?
@@mrshadow7399 unfortunately my game stopped working and i gave up 😆 i didn't find a solution, i am so sorry 🙏
Keep going and good luck, you'll eventually find the solution..
If your thinking led to the same question as mine : "Wait a minute, we already tested the upPressed, downPressed etc. Why test it again just to update the sprite?"
You can also just update the spritecounter in the if slot of the update method, like so :
public void update(){
if(keyH.upPressed) {
direction = "up";
y -= speed;
spriteCounter++;}
I just think it looks cleaner as a whole. Now it accomplishes the same thing with less nesting, see which you like better.
I sincerely hope I'm not offending the author with my suggestions. Thank you for the instructive series!
Only problem is, if you press all keys at the same time your character animation is 4 times faster
but thanks :)
@@mathisseifert4073with else if you can’t use 4 button at the same time so you can use spriteCounter++ in if and else if statement
You're so incredibly talented at what you do. I hope you have a job that appreciates your skill and pays you generously for what you can do. I hope to someday be even 1/4 the developer that you are.
I'm just a mediocre programmer. I'm sure you can catch up :)
I'm just happy I got my sprite character to move, since started this tutorial 2 days ago its fun learning game dev again 😁 Thanks RyiSnow
Glad to hear that and welcome back to game dev :D
Thank you for this tutorial. This has been very easy to follow and learn from! I'm a beginner and didn't know a thing before I started this series.
Glad it was helpful!
Thank you sir, I have always understood concepts of java but never really understood when to use them. Using your tutorial i was able to get a basic hold of 2d programming I hope you become a more popular teacher cause your teaching techniques are excellent and as always Thank You!
5:14 can tell me why my line 'Player player = new Player(this.keyH);' is error constructor undefined ?
Instead of "this.keyH", do "this, keyH" because we want to pass 2 arguments to the constructor
at 14:50 my sprite has a white background how do you get yours to have a black background?
I see now i just didn't commit out the two lines that's why my character had a white background in the square
Bro I did comment out the two lines but it's still Showing the white box 😭 any fix for this ?
Can i say it? YOU ARE A THE BEST TEACHER THAT I EVER HAD! Thank you very much, fantastic tutorial.
Gotta love forgetting to add break at the end of my case statements and spending like 5 minutes trying to figure out why only the left sprite is rendering. Love the Tutorials so far.
Thank you Ryi
Thank you for your support!!! I hope you'll enjoy the series :)
Your art skills are great, spent a few hours last night messing around with converting your guide to Android so far I have an un animated sprite that can move around the screen smoothly. I'm going to see what I can learn tonight, I feel so new lol.
Also I enjoy that you explain things easily, plus everything makes sense from someone that does have java experience! With your permission I may do guides on this while I'm following along to convert to Android 😁
For any of those who is only getting one sprite character, make sure to add break at the end of each case in the switch statement
you can also use arrays to storage the images and then iterate through the values c:
How????? I am confused becasue we store BufferedImage objects, so we can create one 1 arrayList called images, that has all of the, but are we still creating up1, up2, down1, down2? or dont and just do image.add(ImageIO.read(getClass....etc ? But how do you get the string to change for "/player/boy_left1... or /player/boy_right2"????????
Can you show what you did?
@@Team6OWG @REDLIK share dude!! ((:
you what if we want to have a re images a 32 by 32 ?
Its been years since this came out and it still hold true today!! Thanks for teaching me java!
Hello, in class Player when you import Gamepanel and Keyhandler you get option to do main.Gamepanl etc i do not get these options when i type it in myself I get an error saying the import main cannot be resolved. any solutions, Thanks.
Your tutorials are amazing man, keep it up!!!
Thanks, will do!
i dont know what is happening my player sprite is not showing its showing the white rectangle only even though i have cut out the code for it. please help.
I require help. When I try to import "main.GamePanel" and "main.KeyHandler" nothing shows up. When I write the imports manualy, it is still an error, like it does not recognise the imports or something. Does anyone have an answer to this?
not sure if you still need help but.. i had a similar problem, turns out it was because my GamePanel and KeyHandler files were not in a "main" folder. when I added them to a folder called "main", it worked as it did in the video
Thank you so much for making time to share this tutorial with us! I’m really grateful!
No problem :) I'm glad you liked it!
I'm following along your tutorial, and I can say I'm having a lot of fun creating this game. Thank you for putting this together and for posting the resources needed to create the game. Your explanations are very easy to follow and does not take too long.
How to create a Source folder in BlueJ IDE.Please kindly help .
I have the solution for those of you, who are struggling with the error pinned in the comments and using VS Code (but you can give it a try in your IDE). I put the pictures in a single folder called player and then I moved the folder in the src folder. And then wrote this: File f1 = new File("./src/player/ninja_up_1.png");
File f2 = new File("./src/player/ninja_up_2.png");
File f3 = new File("./src/player/ninja_down_1.png");
File f4 = new File("./src/player/ninja_down_2.png");
File f5 = new File("./src/player/ninja_left_1.png");
File f6 = new File("./src/player/ninja_left_2.png");
File f7 = new File("./src/player/ninja_right_1.png");
File f8 = new File("./src/player/ninja_right_2.png");
up1 = ImageIO.read(f1);
up2 = ImageIO.read(f2);
down1 = ImageIO.read(f3);
down2 = ImageIO.read(f4);
left1 = ImageIO.read(f5);
left2 = ImageIO.read(f6);
right1 = ImageIO.read(f7);
right2 = ImageIO.read(f8);
I swear you are god in disguise. Thank you so much! I was going to give up since I didn’t know what to do.
Thank you so much! omg I literally spent HOURS looking for a solution the other way. LIFE SAVER!
it worked very well in intellij, thank you very much!
I use VSCode and this worked hella good. thank u very much
I've been trying to fix this error for like days. Thankkssss
I'm making a game as a final project (the game is Tron the one of the movie, the motorcycles that leave a wall of light behind them), the thing is that I don't know how to make that wall and I've been searching a lot and I can't find how to do it. I don't know if you or someone from the community could help me, thank you very much in advance.
1:39
for some reason it doesn't show me the import option, any idea why?
btw thanks a lot for the video, you're doing an amazing job!
it doesnt give me import player option at 2:38
nvm fixed it
How did you fix it
I get to the 7:10 test and the rectangle no longer moves :( I left the old if loop location updater in the GamePanel class and that box still moves. But the new box will not budge. Advice? I've got the new loop in the Player class, as well as updated all the x's and y's.
Incredible. What about storing the sprites inside an array?
And better, having one single sprite sheet file and changing the position? For performance/memory. I think I will add these if it's not done on the videos to my version on my repository.
Thanks a lot. Very fun tutorial.
I have this problem : i can move the rectangle so i guess in the key listener class and update method there s no error but when i import the images (i just copied like in the video) and run the program i can see my player in the defaultValues position and direction so the sprites are loaded but i can’t move it
(i tried to comment the getPlayerImage(); and the g2.drawImage(x,y,gp.tileSize,gp.tileSize,null) and i wrote again g2.fillRect(x,y,gp.tileSize, ,gp.tileSize) , so i can move again the rectangle , but with te image loaded i can’t move the player and the program runs with no error
For me too
@@natesannatesan2220 I used a different key instead (VK_W,A,D,X OR SOMETHING 😊) , the arrow up, down, left, right (VK_UP,DOWN,LEFT,RIGHT) and it worked 😊.
had the same problem hopefully it helped.
same
is there a way to make another image animation (I want to add an idle animation when not pressing any keys)?
*my sprites are not drawing to the screen, i used the same sprites from video description everything loads in without any error but the sprites won't load to screen please help*
Did you add the getPlayerImage(); method to the player constructor in the Player class? I had the same problem and this was my solution
Hey, the character only appearing when going D key, WAS keys won't show character? can you help me with that?
In case you haven't figured it out yet, you are probably missing some breaks in switch statement. It's such a stupid mistake but it slipped by me and hopefully its the same solution for you.
I can get the image to show on the window but not move (and I can also get the rectangle to move but only if its a rectangle not the image). There doesn't seem to be any syntax errors so I don't know what I did wrong. Pls help
Can I see your Player class?
@@RyiSnow sure where do i send it
You can paste it here.
@RyiSnow actually now it doesnt work for the rectangle too, it just paints it but it doesnt move
Same here
Hi! I have some problem with animation how to add more frames (4) ?
18:57 u can try adding something like this :
else if (spriteNum == 2) {
spriteNum = 3;
}
else if (spriteNum == 3) {
spriteNum = 4;
}
before he adds this:
else if (spriteNum == 8) {
spriteNum = 1;
}
it worked for me idk if its good but hey it works
Hi! This is an old video but I am trying to resolve an error I get at 9:32.
package entity;
import java.awt.image.BufferedImage;
public class Entity {
public int x, y;
public int speed;
public BufferedImage up, down, right, left;
public String direction;
}
It gives me the error BufferedImage cannot be resolved. Does anyone know why? I'm using Eclipse.
Same issue for me too, BufferedImage cannot be resolved. also it mentions that BufferedImage is already indirectly referenced from required type java.awt.Graphics2D
Thank you mate! This is the best series in TH-cam...keep going!!
this might be a little late but if i switch to bufferedimage, not even drawing the images, just assigning the pngs, my key binding seems to break, whenever i stop calling the method that assigns the pngs it goes back to normal, if i add any other functions with the images on they work just fine, but the key binding breaks, i'm not sure how keybinding focus works but it still seems quite awful
nevermind i'm leaving this comment here for people with the same problem, key binding's default focus is just as crappy as keylistener's, put JComponent.WHEN_IN_FOCUSED_WINDOW inside the getInputMap()'s parameter to fix this
I love that you did this. you're really great at teaching it srsly dude don't underestimate your talent. I greatly appreciate your videos, I'm doing this as a summer project and I make edm so I'm going to be making full tracks for different settings and looking forward to drawing little characters
At 6:33 can you explain why you kept the tile size inside of "GamePanel" instead of moving it to the "Entity" class
I think it could be because he wanted to implement entities bigger than the size of 1 GamePanel in later videos
for me its only showing one direction of image
you have nice tutorial, but i need help.
for the character i have 3 pictures for up and down, and have 4 pictures for right and left. iam in 20:52 of the video and my character when he is gos de up and down show a moment when he dessapear because i have 4 spriteNumber and just 3 pictures for down and up. when hes go to the left or right hes looks normal but the problem is when hes go to up and down, hes disappear for a one frame!
Your explanations are very clear and straight forward! Great video! (I subscribed).
Hello, I have a problem with my getPlayerImage() method, when I start the program an error occurred and it says "Caused by: java.lang.IllegalArgumentException: input == null!", I tried to change the path of my pictures but nothing changed. I have the same code as you but the only difference is the path for the pictures.
Sounds like the program is failing to load your image. Are you using png file? Also, check if you have spelled the file names right such as not forgetting to type underscore, back slash etc... that often happens.
@@RyiSnow To test the method I used your sprites so the image isn't a problem, I think. And I thought that the path was wrong too, but I checked several times and nothing
Can I see your Player class? You can paste it here.
@@RyiSnow I sent like 5 times a message with my git depository, cause I couldn't write my code on commentary of this video, I don't know why, so is there another way to show you the code ?
@@marinasalonso2716 You cannot paste external link in TH-cam comment. It most likely gets regarded as spam. You cannot directly copy & paste your code here? If it still doesn't work, you can contact me via twitter.
I thought setting variable "direction" to down was unnecessary at 11:40, but I was completely wrong cause it fired repeated errors.. why is it needed?
Without setting that the direction variable is null (not instantiated) so you likely get NullPointer exception error. You need to set a value to avoid that either in Entity class or Player class.
@@RyiSnow Oh I see.. thank you 🙏
Hello there. I just started learning a few days ago the beautiful language "java"..I am very glad I found your channel, a few video and already helped me understand more than just reading 📚.
You deserve more views for sure.
Keep up the good work. Wishing you a lot of success 🙌🏼
Thank you for your kind words!
Hello, I have an error at 2:23 when you type -Player player = new Player(this.KeyH){}, here Player is at the beginning and Player after new I have an error and it says like this - Player cannot be resolved to a type , help me how can I fix it?
When I run it at 14:50 in the video the screen is white and I get a flood of errors like too many to write, the screen is white, and it says Cannot invoke “Object.getClass()” because “this.gp” is null. Can you help me with this?
It also says The method drawImage(BufferedImage, BufferedImageOp, int int) in the type Graphics 2D is not applicable for the arguments (BufferedImage, int, int, int, int)
Nevermind I figured it out lol
Enjoying this series a lot. Thank you.
I can't get my spirits into the res and player resource I don't know where to find it I don't know how to set my eclipse up where I can have that file selecting bar on the right
What I'm saying is that I don't have that package explorer option on the left so I can't find my files what did I do
Apparently getClass().getRAS() starts at the root folder of the class so to get it to work like that you have to put the resources in the entity folder or package (w/e).
when you created the player, you passed this, here you don't accept it at all, it keeps asking for cast. I do it to later give an error of creating local variable.
i use netbeans IDE and i don't play program, can use help me?
Can't wait for the background tiles :)
i'm trying but the rect is not moving even though everything's fine
for anyone want the character to move diagonally, just replace all else if conditions in update method to all if conditions
Thank you for this! Exactly what I needed
Бро, ты лучший❤
Ты единственный на кого я подписался не из вежливости, а из уважения к твоему труду и твоим знаниям!
I was trying to limit myself to one video a night, but I could not help it and decided to do another! :)
The scwitch(direction) fall dont work: i try this: BufferedImage image = switch (direction) {
case "up" -> (spriteNum == 1) ? up1 : up2;
case "down" -> (spriteNum == 1) ? down1 : down2;
case "right" -> (spriteNum == 1) ? right1 : right2;
case "left" -> (spriteNum == 1) ? left1 : left2;
default -> null;
}; but i can only see 1 Picture at every way..
thank you so much for the amazing help
how would the folder part at 8:53 be done in BlueJ?
did u ever figure this out bc im struggling LOL
@@flyingxo I really wonder if you're still struggling. I don't use BlueJ, just curious. c:
@@kira890 i think i found a workaround by putting the folder that i used for my sprites into the folder that had something to do with my project.. i forgot LOL but after i did that i could use the name of the file to refer to it
if you’re interested i can find my code and see what i did exactly :p
does anyone get this error Error: Could not find or load main class main.Main
Caused by: java.lang.ClassNotFoundException: main.Main. when they create the source folder res @8:30
why cant I import player in the game panel class? thanks
Hey I love your videos. But i got a question about the animation. The update method is based on the number of FPS. Which means that with the system you made, a person with 30 fps on the game will have 2x slower animation and a person with 120 fps 2x faster. Is there a way to have the same animation speed regardless of fps?
Yes, I think you can set the speed based on fps.
Example:
int speed = 240/FPS;
This returns 4 if fps is 60 and returns 8 if fps is 30 so the player speed stays the same.
That said if you set fps 241 or more, the speed becomes 0 (since int doesn't accept decimal) so player won't move at all in that case. So probably you'll need to change it to double and arrange the code a little bit. Like counting decimal behind the scene and when it hits 1, apply the movement or something.
@@RyiSnow Great idea! Thank you I will try it
Hi, I just realized that you were asking about the animation, not the player's movement speed. Maybe you've already figured it out but you can also set the sprite counter based on fps so the interval between sprite 1 and 2 stays the same.
I’ve been following your tutorials to the t so far, but when after shifting the key input stuff to the player class and after clicking run, the square doesn’t move at all, do you have any clue what the problem could be? no errors are popping up, it’s just not getting my key inputs for some reason
edit - never mind, I forgot to put the player update inside the game panel update
it doesn't run anymore and it is a repaint error. i have no clue what to do
My sprite seems to only change to the right and up sprite’s
I have a problem but not with the code. I cant make my image with transparent background. Can someone help me.
Why can't my character move down? Even though I followed it correctly
Im here bro. Ehehe. Really, lot learning from you. Thanks again bro
i have a problem, the class KeyHander no works for some reason.. And I did it the same of the video... Any sugestions?
Hi @RyiSnow
I have a question, is it possible for the sprites to move diagonally? Thanks!
how do i create a new folder? im working on intelliJ, and i can see you made the res folder indside the src folder.
I made a video for that!
th-cam.com/video/Q9jtg0ocGgo/w-d-xo.html
I'm stuck in running with new images @sts (spring tool suite application), it's getting me null when read image or maybe my folder res structure.
Thank you and I'm sorry..
I wanted to know if I can put more than 8 sprites, like 16 sprites so that the character has more movement, how to do this?
you can scale up the process to include more image files, essentially what was done in the tutorial but repeated for each file. You'll have to add a line variables in Entity to initialize the extra files, add lines in getPlayerImage() to read the extra files, and modify the if statement with sprite counter to switch spriteNum more than just two times. You can use modulo to make the spriteNum if statement easier too, doing spriteCounter % 10 == 0 in the if statement and removing spriteCounter = 0; at the end will change the sprite every second, rather than hard coding it in for every second. since modulo returns 0 anytime x is divisible by y, thus it will change any time spriteCounter is divisible by 10 (10, 20, 30, etc...), add an else statement at the end to set the spriteNum back to 1 to display the idle sprite while not moving and re add spriteCounter = 0; in there as well.
@@printlnPrints can you send me an example? Please
I have problem with adding my own model. I made it 16x16 same as you did but It just doesn't want to load.
Are you sure you added the getPlayerImage(); method to the player constructor in the Player class? I had the same problem and this fixed it
I was working with vscode and when i downloaded intellij and copy and pasted all my vscode onto there after mimicing RyiSnow's file structure exactly i got it to work. Im gonna try to push it to github so that i can pull it back onto a vscode editor. I guess my compiler is just limited in what it can do.
the image don't show up 😭
Try to create Source Folder res, add Package player, and writte path "/player/(sprite_name)"
@ ok I will try that, thanks 😊
@@FoxTop-bs5sr i tried it but it still won't show up. i even watched the intellij video
Help! when pressed, the player does not move at all
How would I make it so that my character can walk diagonally like if I press W and D at the same time?
I keep getting an error even though the file path and name are correct plase help me :)
For anyone wondering how to resolve the error in VS code. Just right click on the res folder and select "add folder to java source path." this worked for me.
I am having trouble with the movement(I have followed all the directions properly but I think that the movement logic is wrong in the tutorial)
-When I press right then while right is still pressed, I press up or down, the sprite will move up or down and when I let go of up or down (remember right is still pressed), the sprite will continue to go right.
- The problem is that this does not work for when I am going up and then I want to go left or right.
- There is something wrong with the if statements, we check for up before down,left and right so anything below in the if statement is overruled by everything above.
Is is there any way I can fix this bug?
thank you very much for these wonderful video tutorials. An excellent resource !
You are doing a great job ! I will tell my friends about you !!!
hello, Thank you for this video, it is very helpful. However, I would like to ask why is there no visible image is showing on my window since I added the sprites, I check everything and I am confused. I used eclipse, thank you for your help!
i fixed it now, thank you still! consider this as appreciation post. hehe
isn't it better just to make a walk class? so we can use it for other characters too?
I have a question, why is the character way smaller for me?
God is good and I am getting a little better in troubleshooting. the mistake I made that should be avoided on this video was that I did not include the line of code, "import java.awt.image.BufferedImage; " right after the " package entity;" in the Entity class.
To all my peers, I would encourage you to make sure all your imports are added. This will solve a lot of your problems.
To our teacher @RyiSnow, for future tutorials, please call more attention to when you import something or click to import something. Sometimes you click so fast and if I blink, I miss where you click to have Eclipse automatically import something. Sometimes, I do not ever see it, but I know it is there. So far, I have been able to use Eclipse to track it down.
Other Input: MSpaint and Gimp both are good alternatives to make Pixel art. The only problem with MSpaint is that it is difficult to make it 16x16px, but if you make your draw area close to square and draw your images, you can use Gimp to both resize your image to 16x16px and a few simple clicks will make the white background transparent.
You should be able to do everything inside of Gimp, but I am not yet well versed with Gimp as I am MsPaint as of yet. Gimp is almost as powerful as Photoshop and is completely free and opensource, so it is worth learning.
Fun Thought: I have considered taking photos of myself, and other people, in all of the same poses as your little boy sprite and inserting that into the game. Yes, I could probably do animated pixel art also, but I am talking about just unedited pictures except for the 16x16px resizing and making the background transparent.
Hey man I keep getting this error and I think it has something to do with imports you think you can take a look
----------------------------------
package entity;
import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.image.BufferedImage;
import java.io.IOException;
import javax.imageio.ImageIO;
import main.GamePanel;
import main.KeyHandler;
public class Player extends Entity{
GamePanel gp;
KeyHandler keyH;
public Player(GamePanel gp, KeyHandler keyH) {
this.gp = gp;
this.keyH = keyH;
setDefaultValues();
getPlayerImage();
}
public void setDefaultValues() {
x = 100;
y = 100;
speed = 4;
direction = "down";
}
public void getPlayerImage() {
try {
down1 = ImageIO.read(getClass().getResourceAsStream("/player/boy_down_1.png"));
down2 = ImageIO.read(getClass().getResourceAsStream("/player/boy_down_2.png"));
up1 = ImageIO.read(getClass().getResourceAsStream("/player/boy_up_1.png"));
up2 = ImageIO.read(getClass().getResourceAsStream("/player/boy_up_2.png"));
right1 = ImageIO.read(getClass().getResourceAsStream("/player/boy_right_1.png"));
right2 = ImageIO.read(getClass().getResourceAsStream("/player/boy_right_2.png"));
left1 = ImageIO.read(getClass().getResourceAsStream("/player/boy_left_1.png"));
left2 = ImageIO.read(getClass().getResourceAsStream("/player/boy_left_2.png"));
}catch (IOException e) {
e.printStackTrace();
}
}
public void update() {
if (keyH.upPressed == true) {
direction = "up";
y -= speed;
}
else if(keyH.downPressed == true) {
direction = "down";
y += speed;
}
else if(keyH.leftPressed == true) {
direction = "left";
x -= speed;
}
else if(keyH.rightPressed == true) {
direction = "right";
x += speed;
}
}
public void draw(Graphics2D g2) {
BufferedImage image = null;
switch(direction) {
case"up":
image = up1;
break;
case"down":
image = down1;
break;
case"right":
image = right1;
break;
case"left":
image = left1;
break;
}
g2.drawImage(image, x, y, gp.tileSize, gp.tileSize, null);
}
}
The error that im getting is The type java.io.IOException cannot be resolved. It is indirectly referenced from required type java.awt.Font
@@megha9307 I am going to take a wild guess at what your problem is, but without seeing all of your code and not just your player class, it is hard to tell, but I am going to give you a few things to look for and there is a good chance you will find it on your own and be a better programmer for it.
First, see if it helps to add
import javax.imageio.ImageIO;
to your entity class for reasons I explain below.
If that doesn't work and if you are using eclipse like Ryisnow and me, read the error line and see exactly what it reads. It will give you a lot of clues.
Remember that your player class extends the entity class. You pasted your code for the Player class. If you happen to forget an import in your Entity class, it can cause an error on your Player class and cause it not to work.
Be watchful of each time Ryi uses a variable or attribute from another class. You might be working in the Player class and think you should import something there when you should import something to the Entity class because that is where that item in question originates. The same goes for making variables public when you call them from a different class than where they were declared. In a video coming up there is an instance where Ryi forgets to make a certain variable public and has to go back and make it public, so the program will work.
I do not remember if this applies to both folders and packages, but this definitely applies to packages. Each time Ryi has you create a new package or a new folder, you have to import your main class or some other class to that new class you just created or vice versa, so it is not isolated and can talk to the rest of your program. Eclipse will often do this with a couple of clicks and Ryisnow will click so fast to generate that import automatically that if you blink, I assure you will miss it.
I have also had a few instances where Eclipse offered to generate that import line of code for Ryisnow, but it wouldn't do it for me, so I had to read the error details very carefully and figure out which import line of code I needed to add and add it manually.
Good luck and comment back when you figure it out because these comments help other people with their code also!
@@megha9307 Libbania Reyes had some good suggestions of a few things to check in a comment below also.
Excuse me my machine can't appear left sides "left1" and "left2". IDE is Eclipse and my machine is Mac.
can someone pls help me my square was moving but now it wont i followed every step