Can u post a place were we can get the src code because i can't figure out this bug i have and i just really want to compare side by side view of mine to yours to see what is wrong. thanks so much---TekkitWizard
can you post the gamepanel class and the main one, finish the tutorial but i cant seem to make to work, also on your page you dont have those 2 clases uploaded :P
I started about 1.5 years ago during the summer. Once you figure out the basics, you can move onto the more challenging topics like game programming without much difficulty.
Hey man i have added to the padding just like you did but my player still doesn't move right on the blocks. Should i just add to all the offsets? What should i do?
Wow man I cant stop commenting on your vids. Good job once again despite this being 2+ years ago
There is still a bug. I noticed that when you jump near a block and move into it, it teleports the player to the top and messes up the screen. Any fixes?
Ill post my code below.
```
public class Player extends Rectangle {
public static final long serialVerionUID= 1L;
private boolean topCollision = false;
private double moveSpeed = 5;
private double x,y;
private int width,height;
public boolean right = false, left = false, jumping = false, falling = false;
private double jumpSpeed = 15;
private double currentJumpSpeed = jumpSpeed;
private double maxFallSpeed= 5;
private double currentFallSpeed = 0.5;
public Player(int width, int height){
x = GamePanel.WIDTH / 2;
y = GamePanel.WIDTH / 2;
this.width = width;
this.height = height;
}
public void tick(Block[] b){
int iX = (int)x;
int iY = (int)y;
for(int i= 0; i < b.length; i ++) {
// right
if (Collision.playerBlock(new Point(iX + width + (int)GameState.xOffset, iY + (int) GameState.yOffset + 2 ) , b[i])
|| Collision.playerBlock(new Point(iX + width + (int)GameState.xOffset, iY + height + (int)GameState.yOffset - 1), b[i])) {
right = false;
}
//left
if (Collision.playerBlock(new Point(iX + (int)GameState.xOffset - 1, iY + (int) GameState.yOffset + 2) , b[i])
|| Collision.playerBlock(new Point(iX + (int)GameState.xOffset - 1, iY + height + (int)GameState.yOffset - 1), b[i])) {
left = false;
}
//top
if (Collision.playerBlock(new Point(iX + (int)GameState.xOffset+1, iY + (int) GameState.yOffset) , b[i])
|| Collision.playerBlock(new Point(iX + width + (int)GameState.xOffset-1, iY + (int)GameState.yOffset), b[i])) {
jumping = false;
falling = true;
}
//bottom
if (Collision.playerBlock(new Point(iX + (int)GameState.xOffset + 2, iY + height + (int) GameState.yOffset - 1) , b[i])
|| Collision.playerBlock(new Point(iX + width + (int)GameState.xOffset - 1, iY + height + (int)GameState.yOffset+ 1), b[i])) {
y = b[i].getY()- height - GameState.yOffset;
falling = false;
topCollision = true;
}else{
if(!topCollision && !jumping){
falling = true;
}
}
}
topCollision = false;
if(right){
GameState.xOffset+= moveSpeed;
}
if(left){
GameState.xOffset-= moveSpeed ;
}
if(jumping){
GameState.yOffset-=currentJumpSpeed;
currentJumpSpeed -= 1;
}
if(currentJumpSpeed
Can u post a place were we can get the src code because i can't figure out this bug i have and i just really want to compare side by side view of mine to yours to see what is wrong. thanks so much---TekkitWizard
Sure, I'll have it up on here: www.github.com/pj6444
Thanks so much--TekkitWizard
@@PatrickFeltes it's not there...
can you post the gamepanel class and the main one, finish the tutorial but i cant seem to make to work, also on your page you dont have those 2 clases uploaded :P
Hey! Great tutorial! For how long time have you been programming in Java?
I started about 1.5 years ago during the summer. Once you figure out the basics, you can move onto the more challenging topics like game programming without much difficulty.
My code is exactly like yours but my block still doesn't move on the blocks. I can't figure out what is happening please help!
+KozzyMoto Never mind I just increased the amount added to the offset and it works fine now
+KozzyMoto Hey i have the same problem did you add to all the offsets?
just to the last two y offsets
Hey man i have added to the padding just like you did but my player still doesn't move right on the blocks. Should i just add to all the offsets? What should i do?
I realize Im pretty off topic but does anybody know of a good site to stream new tv shows online?
@Fisher Junior I watch on Flixzone. You can find it on google =)
@Jamal Conor Yea, have been watching on Flixzone for since march myself :)
@Jamal Conor Thank you, signed up and it seems like a nice service =) I really appreciate it!
@Fisher Junior you are welcome xD
Make More!
More should be coming this weekend!