teyaaa12
teyaaa12
JCHJava Community | Help. Code. Learn.
Created by teyaaa12 on 1/1/2025 in #java-help
2d game java collision
yess
39 replies
JCHJava Community | Help. Code. Learn.
Created by teyaaa12 on 1/1/2025 in #java-help
2d game java collision
I think I have a problem with my collision logic in the collision checker class.
39 replies
JCHJava Community | Help. Code. Learn.
Created by teyaaa12 on 1/1/2025 in #java-help
2d game java collision
Yes, but I still have the same issue as in the video.
39 replies
JCHJava Community | Help. Code. Learn.
Created by teyaaa12 on 1/1/2025 in #java-help
2d game java collision
Oh, sorry! So, I removed the declaration of public int screenX and screenY from my Player class. However, if you're referring to this: screenX = gp.screenWidth / 2 + (gp.tileSize / 2);
screenY = gp.screenHeight / 2 + (gp.tileSize / 2); It's only in the Player class, and it represents the player's position on the screen.
39 replies
JCHJava Community | Help. Code. Learn.
Created by teyaaa12 on 1/1/2025 in #java-help
2d game java collision
here
39 replies
JCHJava Community | Help. Code. Learn.
Created by teyaaa12 on 1/1/2025 in #java-help
2d game java collision
these are the issues
39 replies
JCHJava Community | Help. Code. Learn.
Created by teyaaa12 on 1/1/2025 in #java-help
2d game java collision
The variables, such as solidarea, etc., represent the solid areas of the NPC and the player. I tried assigning them directly in my Entity class, but it does not resolve the issue of them getting stuck.
39 replies
JCHJava Community | Help. Code. Learn.
Created by teyaaa12 on 1/1/2025 in #java-help
2d game java collision
Actually, their values are the same, so should I remove those variables from the Player class since it is a subclass of the Entity class?
39 replies
JCHJava Community | Help. Code. Learn.
Created by teyaaa12 on 1/1/2025 in #java-help
2d game java collision
Yes, changing public void checkTile(Entity entity) to public void checkTile(Player entity) solves the issue of the player colliding with tiles that have collision. However, this causes a problem when I add NPCs, as the method then requires reverting to public void checkTile(Entity entity). According to Ryisnow, the method should remain as public void checkTile(Entity entity) for it to work without errors. The issue with public void checkTile(Entity entity) is that when my player touches a tile with collision, the player becomes stuck. Additionally, if the player touches an NPC, both the player and the NPC become stuck.
39 replies