Jump to content
Search In
  • More options...
Find results that contain...
Find results in...

[Java] need some dumbass basics


BlazingShadow
 Share

Recommended Posts

```

import java.awt.event.KeyEvent;

import java.awt.event.KeyListener;

public class Game implements KeyListener {

private void init() {

addKeyListener(this);

}

@Override

public void keyPressed(KeyEvent e) {

if (e.getKeyCode() == 87) {

System.out.println("W Pressed!");

//Up Movement Code

}

if (e.getKeyCode() == 65) {

System.out.println("A Pressed!");

//Left Movement Code

}

if (e.getKeyCode() == 83) {

System.out.println("S Pressed!");

//Down Movement Code

}

if (e.getKeyCode() == 68) {

System.out.println("D Pressed!");

//Right Movement Code

}

}

}

```

Here's the concept of movement. Not smooth, but it can get you started.
Link to comment
Share on other sites

> Here's the concept of movement. Not smooth, but it can get you started.

This assumes you already have some sort of entity system in place.

If you're having trouble with this, I'm not convinced you know that much Java. If you really do know a bit, look into slick, it's what I use and it's very simple. There's plenty of tutorials to help you.
Link to comment
Share on other sites

What I think he may be asking for is simply making a smooth transition from tile to tile.

EX: The entity doesn't simply jump between tiles, it has to move over to the next one pixel by pixel, yet pressing a movement key only once will move you a whole tile.

That's my best guess.
Link to comment
Share on other sites

> What I think he may be asking for is simply making a smooth transition from tile to tile.
>
> EX: The entity doesn't simply jump between tiles, it has to move over to the next one pixel by pixel, yet pressing a movement key only once will move you a whole tile.
>
> That's my best guess.

I think you may have misread my original post, I said "Not some kind of tile based movement" What I'm after, is a pixel by pixel movement, where for example spamming wasd wasd wasd would cause you to travel in a circle, if you try that with aaron's code, you will notice it is rough and jittery, also a slight amount of deceleration would be nice, meaning you let go of s and you slide downwards to a halt.
Link to comment
Share on other sites

> Download A Blank RSPS and just script in it that's how i learned Java really simple ![:P](http://www.touchofdeathforums.com/community/public/style_emoticons/<#EMO_DIR#>/tongue.png)

Eww.. if by RSPS you mean Runescape Private Server, no. I don't even want to touch runescape, unless I'm throwing it into an incinerator.
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...