Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

So, I'm new to Java and I want to get a sprite to move around the screen, like a tile-based movement. I really would like some help and some resources or tutorials could work. I've done a little C#, but I couldn't seem to get it.

share|improve this question
add comment

2 Answers 2

Might as well learn it from Stanford right? The video lectures there are rather good for someone just starting out. You'll use Karol the Robot as your guide to learning to program. Once you get more comfortable with the higher level concepts you can dig into the source for Karol and learn how actually do the drawing and moving around.

share|improve this answer
add comment

This is relatively a language independent question. though my java is a little light, but the logic is the big thing here.

Tile systems are relatively straight forward, but still equally as difficult as continuous motion, in that instead of incrementing with respect to time

x += 5*time;

you instead add a fixed amount

x += tileWidth;

so for example if you have a character that holds a position you would just have.

if(button.press.up){
    character.position.y -= tileHeight;
}
if(button.press.left){
    character.position.x += tileWidth;
}

and the reverse for the other directions. the big thing here is instead of moving with respect to time, or some counting your moving with respect to fixed numbers. though this is primarily for rectangular tiles (square if tileHeight = tileWidth). if your doing different shape tiles (hexagonal, triangular, etc...) then your going to have different math, but the concept of moving at fixed increments is the key here.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.