BlazingShadow Posted September 10, 2012 Author Share Posted September 10, 2012 Okay I know a decent amount of java, but one thing I can't get my head around is making a top down system where wasd is used to move and the character always faces the mouse, and not some sort of tile based movement, smooth movement.Any help?Thanks in advance Link to comment Share on other sites More sharing options...
aaaron Posted September 10, 2012 Share Posted September 10, 2012 ```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 More sharing options...
Jeff Posted September 10, 2012 Share Posted September 10, 2012 > 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 More sharing options...
BlazingShadow Posted September 10, 2012 Author Share Posted September 10, 2012 No my java skills have been focused on minecraft modding and tower defence games, neither of which use any form of controlled movement, and besides, i know how to do the basics such as what Aaron said, my main issue is making it smooth movement Link to comment Share on other sites More sharing options...
Sealbreaker Posted September 10, 2012 Share Posted September 10, 2012 How about an example of what you mean with "smooth movement". Do you mean pixel-based movement (not tilebased like eclipse) ?-seal Link to comment Share on other sites More sharing options...
Zzbrandon Posted September 11, 2012 Share Posted September 11, 2012 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) Link to comment Share on other sites More sharing options...
westin444 Posted September 11, 2012 Share Posted September 11, 2012 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 More sharing options...
BlazingShadow Posted September 11, 2012 Author Share Posted September 11, 2012 > 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 More sharing options...
BlazingShadow Posted September 11, 2012 Author Share Posted September 11, 2012 > 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 More sharing options...
westin444 Posted September 11, 2012 Share Posted September 11, 2012 Ok well I wasn't sure.My suggestion would be to use some type of speed based system. A certain amount, say 5 is taken from your current rate every loop, and every loop 'W' is pressed, 6 is added. Then at the end you simply add the speed to your current position. Link to comment Share on other sites More sharing options...
Sealbreaker Posted September 12, 2012 Share Posted September 12, 2012 I'm pretty sure you can find tutorials on that by just googlin'… If you can't find an example in java, you can still adapt the code and make it work in java with some changes most of the time.-seal Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now