]Hello,
i m making a tiled super mario game and i dont really have much experience on game development.The game is going quite well and it works all fine but i have some flickering when the map moves and also at collision on the x-axis although the character stops for awhile if you keep pressing to move forward you can pass through.
I have 2 maps[][] in the game and if the character moves after the half of the screenWidth the dx(difference in x) is summed and the offset is created(by dividing with the tile size) then all the image from the real map[][] of the game are passed to the map[][] of the screen
this is the checkCollision on x(on y there is a gravity method)
private void checkForCollision(){
for(int i = 0; i <world.NumberTilesWidth; i++){
for(int j=0 ; j<world.NumberTilesHeight-2;j++){
if( world.isSolid[i][j] && marioRect.getBounds().intersects(world.blocks[i][j+1].getBounds()) ){
setXDirection(0);
}
}
}
}
and this is the movemap method
public void moveMap(int dx){
offset += dx;
if(offset/16 ==1){
offset = 0;
tileoffset ++;
for(int j=0;j<NumberTilesScreenHeight;j++){
for(int i=0;i<NumberTilesScreenWidth;i++){
{
if(i+offset<=NumberTilesWidth)
screenImg[i][j] = blockImg[i+tileoffset][j];
}
}
}
}else if(offset/16 ==-1){
offset = 0;
tileoffset --;
for(int j=0;j<NumberTilesScreenHeight;j++){
for(int i=0;i<NumberTilesScreenWidth;i++){
{
if(i+offset<=NumberTilesWidth)
screenImg[i][j] = blockImg[i+tileoffset][j];
}
}
}
}
}
can anyone give me a point to fix that flickering stuff