Jump to content
  • Advertisement
Sign in to follow this  
prof_89

problem with java game !!

This topic is 4313 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi, i have a problem with my beginning of an RPG game... But if you try the game you can see that you get stuck almost everywhere in the map, you can also walk on the water... anyone knows why? Link to game, sourcecode + whole package of game http://www.freewebs.com/prof_89/appletgame/spel.html - Där finns appleten med så långt vi kommit - "alla filer" is the package with all game content thanks in advance //jonathan [Edited by - prof_89 on January 26, 2007 4:06:07 AM]

Share this post


Link to post
Share on other sites
Advertisement
In your check function, I think you flipped the xy positions:

public void check(String dir){
int check_left = Player_x-1;
int check_right= Player_x+1;
int check_up = Player_y-1;
int check_down = Player_y+1;

if( dir == "left" ){
if( coll_map[Player_y][check_left] != 1 )
{
player = playerLeft;
x-=speed;
repaint(x, y, 20, 40);
repaint(x+20, y, 20, 40);
}
}


if( dir == "right" ){
if( coll_map[Player_y][check_right] != 1 )
{
player = playerRight;
x+=speed;
repaint(x, y, 20, 40);
repaint(x-20, y, 20, 40);
}
}

if( dir == "up" ){
if( coll_map[Player_x][check_up] != 1 ) { player = playerUp;
y-=speed; repaint(x, y, 20, 40); repaint(x,y+20,20,40);}
}
if( dir == "down" ){
if( coll_map[Player_x][check_down] != 1 ) { player = playerDown;
y+=speed; repaint(x, y, 20, 40); repaint(x,y-20,20,40);}
}
}

For left and right, you put Player_y in the x index

Share this post


Link to post
Share on other sites

well, you were almost right... but my x and y coordinates are litte wierd, but thanks to you i noticed...

i had to put the Player_x in the y field...dont really know why but it works so..

thank you so much :P

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!