Windows 7 Forums
Welcome to Windows 7 Forums. Our forum is dedicated to helping you find support and solutions for any problems regarding your Windows 7 PC be it Dell, HP, Acer, Asus or a custom build. We also provide an extensive Windows 7 tutorial section that covers a wide range of tips and tricks.

Windows 7: 2D Smooth Character Control

24 Jun 2013   #1

Microsoft Windows 7 Ultimate 64-bit SP1
2D Smooth Character Control

I know this isn't primarily a programming forum, but everyone is so helpful I figured someone might be able to help. I am currently working on a 2D game in Java and have a character moving on a 2D plane. Right now the control is pretty choppy and I would like to smooth it out. Here is the relevant code I have:
	public void moveUp() {
		if(dy-1 > -maxSpeed){

	public void moveLeft() {
		if(dx-1 > -maxSpeed){

	public void moveDown() {
		if(dy+1 < maxSpeed){

	public void moveRight() {
		if(dx+1 < maxSpeed){

	public void update(applet applet) {
		distanceToCentre = Math.sqrt((x+dx+(size/2)-1-349)*(x+dx+(size/2)-1-349)+(y+dy+(size/2)-1-349)*(y+dy+(size/2)-1-349));
		x += dx;
		y += dy;
		System.out.println(x + " " + y + " " + distanceToCentre);
I was thinking about using some sort of function that the derivative gets smaller as the input increases (like log(x)/log(10)) but using log in Java takes too long.
My System SpecsSystem Spec

Thread Tools

Similar help and support threads for2: 2D Smooth Character Control
Thread Forum
How much RAM will I need to run Skyrim smooth? Gaming
Smooth scrolling Customization
WMP Video too smooth Music, Pictures & Video
Smooth Edges Themes and Styles
Smooth scrolling? General Discussion
Slow deletes (character by character) General Discussion

Our Sites

Site Links

About Us

Find Us

Windows 7 Forums is an independent web site and has not been authorized, sponsored, or otherwise approved by Microsoft Corporation. "Windows 7" and related materials are trademarks of Microsoft Corp.

Designer Media Ltd

All times are GMT -5. The time now is 12:14 PM.
Twitter Facebook Google+

Windows 7 Forums

Seven Forums Android App Seven Forums IOS App