It's my first try in game development. I'm good at programming, but I've been a bit scared about game development. You've made it easy for me to start. You deserve millions of subscribers. Thank you!
Hello Kaarin! Firstly, I want to adress one issue that I saw some people including me had: changing the hitbox height to 27 * SCALE pixels started causing strange problem that made our little pirate go insane. Apparently "inAir" flag was lighting up although player character was walking on the ground. The problem doesn't show up if we use for the SCALE whole numbers, so I came to conclusion that the function isEntityOnFloor() checks float values that are always rounded down while casting to int in isSolid() function. So I came with kinda bad looking solution, that I have no idea if it won't mess something up: public static boolean isEntityFloating(Rectangle2D.Float hitbox, int[][] levelData) { float yOffset = hitbox.y + hitbox.height + 1; if(yOffset != (int) yOffset) { yOffset = (int) yOffset + 1; } return isTransparent(hitbox.x, yOffset, levelData) && isTransparent(hitbox.x + hitbox.width, yOffset, levelData); } *Despite me using functions with opposite logic than yours those 4 first lines of rounding up Y values apparently helps for now... Okay, so... Secondly, I want to thank you for all the work and love you have put in this tutorial series!!! I am total noob at java and started learing it 2 weeks ago. After finishing java basics tutorial I found your video and I don't regret watching it. I learned a lot of new and useful things, that will not be only helpful in game dev but in java programming as a whole. I can't wait to watch the rest! If I ever hear one of my friends from university will start learning this beatiful language I will deffinetly recommend them this tutorial ;) I hope your channel will blow up, because you deserve it 💚
Hey. Thanks for the comment. Regarding this issue you speak of, I think we solve it later, by making sure that the width and height cannot have any decimal. As of this video, the height is set by height * Scale. But later we say: (int)(height * Scale) By doing this, we can have scale 1.5 for example, but the height of the hitbox, does not contain any decimals. I do like it though when people address bugs on their own. And thank you for the kind words. I hope you learn more from the coming episodes of this tutorial. :D
Good afternoon everyone, i am currently having an intermittent issue where my sprite is landing one tile above trhe floor, wondering if anyone has seen the or has a solution.
When I run my program and press Space, if my character hits the roof, he doesn't fall back. He stays there with a jumping animation. Never stopping or falling. Any help? Edit: Apparently, every time my character hits his head anywhere, he gets stuck. :(
@@KaarinGaming I spent a good time checking my code and didn't find the problem. So I decided to change things myself. The only thing I changed was "airSpeed = fallSpeedAfterCollision;" to "airSpeed = 0;" And it fixed it. However, now, for some reason, the character doesn't display the walking animation. When I press A or D, he walks, but he does the falling animation instead. I'm sorry to bother you or anyone that could help me. I'm really getting crazy here, you know? ;-; Anyhow, thanks a lot for commenting. I love that you reply to the comments, even old ones like mine.
Nevermind. My "fallSpeedAfterCollision;" was equal to "0.5f - Game.SCALE" instead of "0.5f * Game.SCALE". The weird animation is still happening, though.
The player goes offscreen and get stuck in the upper black texture when I jump =/ Edit: found the error, I typed '+' instead of '*' at 'return currentTile * Game.TILES_SIZE;'
Hey me again, PROBLEM! If I change my gravity speed to be faster than my jump speed or vise versa, I lose or gain pixels when landing on a tile. I have been working on this for over a week, my brain is exploding. Even went back to simple math thinking I did something wrong but still not a clue! Hope this finds you
Hello. Not quite sure what you mean. The default speeds are different and gravity is 0.04f and jumpspeed is -2.25f so one is faster than the other already.
Changing the hitbox to 27 gave a bug where the hitbox got stuck at 1 pixel above the floor. This was because of the SCALE being 1.5f. I fixed it by casting 27*SCALE to an (int). Here's to hoping this doesn't break anything in the future. Also because of messing with SCALE made me notice that the player moved way faster in a smaller window because playerspeed wasn't multiplied by SCALE.
Hi kaarin, I encountered a bug. Whenever I press the jump and i don't hit anything (top or side) my character stays on the air about 1 block high until I click any operational key. My hitbox is lower than the tile size. hope someone can help me
hello, i have a bug here on short, falling is overloading the running animation and it seems like there's a problem of priority? when i remove it, the overloading is gone. if you are still here, kaarin, i summon thee. prythee all-knowin one, bless a servant with thy knowledge! private void setAnimation() { int startAni =playerAction; if(moving) { playerAction = RUNNING; } else playerAction = IDLE; if (inAir){ if(airSpeed
Hi Kaarin, first of all thank you for the content. At this very point of the tutorial I tried to add a simple png as background, but despite being relatively light (75 ko), game started to be much slower, you know why???
Hi Kaarin, your videos are so great and clear. However I am in a problem with a difference player_sprites, can you tell me where you can edit and make your spites to a matrix of action, and how can you do that ?
Thanks for the kind words. The assets are not made by me. I find them on itch.io If you use different sprites, the size difference will cause issues. The code is mot designed for anything bigger than the size of a tile.
Hello Kaarin, I encountered an issue where my player lands one tile higher instead of landing on the ground. I've tried reducing the size of my player sprite and that apparently worked, but I just cant get to fix it when the size of my player sprite is large. Thank you for the help in advance and great series! Edit: I found the fix, but now my jump animations dont work
@@_joselp5186 hello, I fixed this issue by scaling down my sprite and making my hitbox smaller. Apparently setting the hitbox's size larger or equal to the tile size reproduces this issue scale down the player hitbox smaller than the tile size itself, that fixes the issue. eg: tile size is of 32x32, then set your hitbox to be of around 21x25 (this worked for me)
@@Meykaye Hey thanks for writing back. I did end up finding that out and scaling down. However since I’m using a different character sprite I found online he ended up looking pretty small compared to the rest of the level. Not sure if it looks bad or not. Might have to find a different sprite or just use the one in the video. Anyways thanks for the help!
I also found your character will fall down as soon as you start the game by moving the check to see if the player is on the ground to just below the first moving = false; in updatePos() ^-^
How to fix this problem: Exception in thread "main" java.lang.NullPointerException: Cannot load from object array because "lvlData" is null at utilz.HelpMethods.IsSolid(HelpMethods.java:29) at utilz.HelpMethods.IsEntityOnFloor(HelpMethods.java:64) at entities.Player.loadLvlData(Player.java:173) at main.Game.initClasses(Game.java:39) at main.Game.(Game.java:27) at main.MainClass.main(MainClass.java:6) ???
Hi Kaarin! First of all, this series is extremely helpful to improve in game-development! Thank you for that! I am currently coding it 1:1 in my project to learn how to actually code it, but I got a Problem and I don't know how to fix it: Sometimes (which is kinda confusing me) the KeyListener isn't registered in the start. And therefore I cant move the Player. This Problem isnt always there so Its hard to debug, cause I can't really reproduce it. Any Ideas? I already added gamePanel.setFocusable(true) before requesting the focus. I saw that in a previous episode in the Comments. regards ^^ Edit: after joining the discord I saw I have to add the line gamePanel.requestFocusInWindow(); I did that now. Since then it worked well. Lets see if that was the error ^^
i think i need more words to understand methods. GetMyOwnJavaPlatformerGameEntityYPositionUnderMyOwnJavaPlatformerGameLevelRoofOrMyOwnJavaPlatformerGameLevelAboveFloor. TADA!!!
Hey guys! :D
What would you like to see next in the tutorial?
Leave a comment below.
Cheers !
Attacking enemies and collectibles would be great ! These tutorials are amazing by the way keep up !
You have a bug in the game, when you hold the A and D keys down the character is showing the running animation.
You are right.
Something we will have to address in the next episode =)
Same thing happen if you hold W and S@@spencerhammond5031
It's my first try in game development. I'm good at programming, but I've been a bit scared about game development. You've made it easy for me to start. You deserve millions of subscribers. Thank you!
Thank you!
I'd love multiple levels or maybe a menu state!
Thank you so much for everything, you help me a lot with my asignments!
What can I do if my hitbox have a greater width and height than 1 tile?
sometimes, when i jump, the player gets teleported one block above the ground (as if there was an invisible block). what could be the cause?
Hello Kaarin! Firstly, I want to adress one issue that I saw some people including me had: changing the hitbox height to 27 * SCALE pixels started causing strange problem that made our little pirate go insane. Apparently "inAir" flag was lighting up although player character was walking on the ground. The problem doesn't show up if we use for the SCALE whole numbers, so I came to conclusion that the function isEntityOnFloor() checks float values that are always rounded down while casting to int in isSolid() function. So I came with kinda bad looking solution, that I have no idea if it won't mess something up:
public static boolean isEntityFloating(Rectangle2D.Float hitbox, int[][] levelData) {
float yOffset = hitbox.y + hitbox.height + 1;
if(yOffset != (int) yOffset) {
yOffset = (int) yOffset + 1;
}
return isTransparent(hitbox.x, yOffset, levelData) &&
isTransparent(hitbox.x + hitbox.width, yOffset, levelData);
}
*Despite me using functions with opposite logic than yours those 4 first lines of rounding up Y values apparently helps for now...
Okay, so... Secondly, I want to thank you for all the work and love you have put in this tutorial series!!! I am total noob at java and started learing it 2 weeks ago. After finishing java basics tutorial I found your video and I don't regret watching it. I learned a lot of new and useful things, that will not be only helpful in game dev but in java programming as a whole. I can't wait to watch the rest! If I ever hear one of my friends from university will start learning this beatiful language I will deffinetly recommend them this tutorial ;)
I hope your channel will blow up, because you deserve it 💚
Hey. Thanks for the comment.
Regarding this issue you speak of, I think we solve it later, by making sure that the width and height cannot have any decimal.
As of this video, the height is set by height * Scale.
But later we say:
(int)(height * Scale)
By doing this, we can have scale 1.5 for example, but the height of the hitbox, does not contain any decimals.
I do like it though when people address bugs on their own. And thank you for the kind words. I hope you learn more from the coming episodes of this tutorial. :D
What do you do if your sprite has a smaller width than one tile but has a taller height than one tile? (This tutorial is super helpful btw thank you)
did you solved it?
Good afternoon everyone, i am currently having an intermittent issue where my sprite is landing one tile above trhe floor, wondering if anyone has seen the or has a solution.
Thanks a lot!
fire
When I run my program and press Space, if my character hits the roof, he doesn't fall back. He stays there with a jumping animation. Never stopping or falling. Any help?
Edit: Apparently, every time my character hits his head anywhere, he gets stuck. :(
Take a look at github for the code. Most likely you missed a + or minus, or something else tiny
@@KaarinGaming I spent a good time checking my code and didn't find the problem. So I decided to change things myself.
The only thing I changed was
"airSpeed = fallSpeedAfterCollision;"
to
"airSpeed = 0;"
And it fixed it. However, now, for some reason, the character doesn't display the walking animation. When I press A or D, he walks, but he does the falling animation instead.
I'm sorry to bother you or anyone that could help me. I'm really getting crazy here, you know? ;-;
Anyhow, thanks a lot for commenting. I love that you reply to the comments, even old ones like mine.
Nevermind. My "fallSpeedAfterCollision;" was equal to "0.5f - Game.SCALE" instead of "0.5f * Game.SCALE".
The weird animation is still happening, though.
Nice!
When i got time over, i try to assist with what i can.
Discord is also a good place to get help from. As long as you are specific
For some reason my character flashes, disappearing for a frame at the switch between jumping and falling animation 🤔
This is because we have yet to reset the animation when switching. Comes in the next ep :)
Same here
The player goes offscreen and get stuck in the upper black texture when I jump =/
Edit: found the error, I typed '+' instead of '*' at 'return currentTile * Game.TILES_SIZE;'
Well done!
Hey me again, PROBLEM! If I change my gravity speed to be faster than my jump speed or vise versa, I lose or gain pixels when landing on a tile. I have been working on this for over a week, my brain is exploding. Even went back to simple math thinking I did something wrong but still not a clue! Hope this finds you
Hello.
Not quite sure what you mean. The default speeds are different and gravity is 0.04f and jumpspeed is -2.25f so one is faster than the other already.
Changing the hitbox to 27 gave a bug where the hitbox got stuck at 1 pixel above the floor. This was because of the SCALE being 1.5f. I fixed it by casting 27*SCALE to an (int). Here's to hoping this doesn't break anything in the future.
Also because of messing with SCALE made me notice that the player moved way faster in a smaller window because playerspeed wasn't multiplied by SCALE.
You sir, are 100% right. It also felt off to me how the speed increases when decreasing the scale ^^
Hi kaarin, I encountered a bug. Whenever I press the jump and i don't hit anything (top or side) my character stays on the air about 1 block high until I click any operational key. My hitbox is lower than the tile size. hope someone can help me
i have the same bug.
hello, i have a bug here
on short, falling is overloading the running animation and it seems like there's a problem of priority? when i remove it, the overloading is gone.
if you are still here, kaarin, i summon thee. prythee all-knowin one, bless a servant with thy knowledge!
private void setAnimation() {
int startAni =playerAction;
if(moving) {
playerAction = RUNNING;
}
else
playerAction = IDLE;
if (inAir){
if(airSpeed
Hey.
Most of these issues are easiest solved by looking up the code on github :)
@@KaarinGaming thank you, forgot to update the comment! actually i managed to solve the problem!
Nicee
Hi Kaarin, first of all thank you for the content. At this very point of the tutorial I tried to add a simple png as background, but despite being relatively light (75 ko), game started to be much slower, you know why???
Hey. We add backgrounds and many images in the game. Make sure you did it correctly. Take a look on github for help or discord.
Nice Episode. When I am changing the size of the hitbox from 28 to 27 the walking animation is buggy. Do you know what could be the problem there?
Thanks.
Hard to tell, you can always compare the code on github or join discord and explain your problem more in details there.
Hi Kaarin, your videos are so great and clear. However I am in a problem with a difference player_sprites, can you tell me where you can edit and make your spites to a matrix of action, and how can you do that ?
Thanks for the kind words. The assets are not made by me. I find them on itch.io
If you use different sprites, the size difference will cause issues. The code is mot designed for anything bigger than the size of a tile.
Hello Kaarin, I encountered an issue where my player lands one tile higher instead of landing on the ground. I've tried reducing the size of my player sprite and that apparently worked, but I just cant get to fix it when the size of my player sprite is large. Thank you for the help in advance and great series!
Edit: I found the fix, but now my jump animations dont work
Hey I’m having the same problem here. What’d you do to fix it?
@@_joselp5186 hello, I fixed this issue by scaling down my sprite and making my hitbox smaller. Apparently setting the hitbox's size larger or equal to the tile size reproduces this issue
scale down the player hitbox smaller than the tile size itself, that fixes the issue.
eg: tile size is of 32x32, then set your hitbox to be of around 21x25 (this worked for me)
@@Meykaye Hey thanks for writing back. I did end up finding that out and scaling down. However since I’m using a different character sprite I found online he ended up looking pretty small compared to the rest of the level. Not sure if it looks bad or not. Might have to find a different sprite or just use the one in the video. Anyways thanks for the help!
I also found your character will fall down as soon as you start the game by moving the check to see if the player is on the ground to just below the first moving = false; in updatePos() ^-^
:( How is it possible that a 30mim video becomes 2 hours
Make a 3D game one day pls
One day maybe =)
I really need to catch up to you, I'm way too far behind 😵💫
Lucky for you, the videos will stay up :)
How to fix this problem:
Exception in thread "main" java.lang.NullPointerException: Cannot load from object array because "lvlData" is null
at utilz.HelpMethods.IsSolid(HelpMethods.java:29)
at utilz.HelpMethods.IsEntityOnFloor(HelpMethods.java:64)
at entities.Player.loadLvlData(Player.java:173)
at main.Game.initClasses(Game.java:39)
at main.Game.(Game.java:27)
at main.MainClass.main(MainClass.java:6) ???
check when you are initializing the array. it should be early enough, before any other operations take it over.
Hi Kaarin!
First of all, this series is extremely helpful to improve in game-development! Thank you for that!
I am currently coding it 1:1 in my project to learn how to actually code it, but I got a Problem and I don't know how to fix it:
Sometimes (which is kinda confusing me) the KeyListener isn't registered in the start. And therefore I cant move the Player. This Problem isnt always there so Its hard to debug, cause I can't really reproduce it.
Any Ideas?
I already added gamePanel.setFocusable(true) before requesting the focus. I saw that in a previous episode in the Comments.
regards ^^
Edit:
after joining the discord I saw I have to add the line gamePanel.requestFocusInWindow();
I did that now. Since then it worked well. Lets see if that was the error ^^
Thanks man! :D
i think i need more words to understand methods.
GetMyOwnJavaPlatformerGameEntityYPositionUnderMyOwnJavaPlatformerGameLevelRoofOrMyOwnJavaPlatformerGameLevelAboveFloor.
TADA!!!