Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (498)
Games in Android Showcase (115)
games submitted by our members
Games in WIP (563)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  How do I make mouse movement natural?  (Read 1780 times)
0 Members and 1 Guest are viewing this topic.
Offline DurzoBlint15

Senior Newbie





« Posted 2012-03-28 00:22:52 »

I need to make the mouse movement in my game have a natural feel to it like any other FPS. Also, how could I loop the mouse around in the screen so the mouse doesn't go off the screen when I move it? I'll only post the classes which I think will have to do with this problem.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
179  
180  
181  
package me.kenneth.game;

import java.awt.Canvas;
import java.awt.Color;
import java.awt.Cursor;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Image;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.image.BufferedImage;

import javax.swing.JFrame;

import me.kenneth.graphics.Screen;
import me.kenneth.input.Controller;
import me.kenneth.input.InputHandler;

import java.awt.image.BufferStrategy;
import java.awt.image.DataBufferInt;
import java.awt.image.MemoryImageSource;

public class Window extends Canvas implements Runnable {
   
   public static final long serialVersionUID = 1L;
   public static final int WIDTH = 800;
   public static final int HEIGHT = 600;
   public static final String TITLE = "MineGame Pre-Alpha 0.2";
   
   private Thread thread;
   private boolean running = false;
   private BufferedImage img;
   private Screen render;
   private int pixels[];
   private Game game;
   private InputHandler input;
   private int newX = 0;
   private int oldX = 0;
   private int fps = 0;
   
   public Window() {
      Dimension dim = new Dimension(WIDTH, HEIGHT);
      setPreferredSize(dim);
      setMinimumSize(dim);
      setMaximumSize(dim);
      render = new Screen(WIDTH, HEIGHT);
      img = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
      pixels = ((DataBufferInt) img.getRaster().getDataBuffer()).getData();
      game = new Game();
      input = new InputHandler();
      addKeyListener(input);
      addFocusListener(input);
      addMouseListener(input);
      addMouseMotionListener(input);
   }
   
   public void start() {
      if (running) return;
     
      running = true;
      thread = new Thread(this);
      thread.start();
   }
   
   public synchronized void stop() {
     
      if (!running) return;
     
      running = false;
      try {
         thread.join();
      } catch (InterruptedException e) {
         e.printStackTrace();
         System.exit(0);
      }
     
   }
   
   public void run() {
     
      int frames = 0;
      double unprocessedSeconds = 0;
      long previousTime = System.nanoTime();
      double secondsPerTick = 1 / 60.0;
      int tickCount = 0;
     
      while (running) {
         
         this.requestFocus();
         
         long currentTime = System.nanoTime();
         long passedTime = currentTime - previousTime;
         previousTime = currentTime;
         unprocessedSeconds += passedTime / 1000000000.0;
         boolean ticked = false;
         
         while (unprocessedSeconds > secondsPerTick) {
            ticked = true;
            tick();
            unprocessedSeconds -= secondsPerTick;
            tickCount++;
            if (tickCount % 60 == 0) {
               System.out.println(frames + "fps");
               fps = frames;
               previousTime += 1000;
               frames = 0;
            }
         }
         
         if (ticked) {
         }
         
         render();
         frames++;
         
         newX = InputHandler.mouseX;
         if (newX > oldX) {
            Controller.turnRight = true;
         }
         if (newX < oldX) {
            Controller.turnLeft = true;
         }
         if (newX == oldX) {
            Controller.turnLeft = false;
            Controller.turnRight = false;
         }
         oldX = newX;
         
      }
     
   }
   
   private void tick() {
     
      game.tick(input.key);
   }
   
   private void render() {
     
      BufferStrategy bs = this.getBufferStrategy();
      if (bs == null) {
         createBufferStrategy(3);
         return;
      }
     
      render.render(game);
     
      for (int i = 0; i < WIDTH * HEIGHT; i++) {
         pixels[i] = render.pixels[i];
      }
     
      Graphics g = bs.getDrawGraphics();
      g.drawImage(img, 0, 0, WIDTH, HEIGHT, null);
      g.setFont(new Font("Verdana", 0, 20));
      g.setColor(Color.WHITE);
      g.drawString(String.valueOf(fps), 20, 20);
      g.dispose();
      bs.show();
     
   }
   
   public static void main(String[] args) {
     
      Image cursor = Toolkit.getDefaultToolkit().createImage(new MemoryImageSource(16, 16, new int[16 * 16], 0, 16));
      Cursor blank = Toolkit.getDefaultToolkit().createCustomCursor(cursor, new Point(0, 0), "blank");
      Window game = new Window();
      JFrame frame = new JFrame(TITLE);
      frame.add(game);
      frame.setResizable(false);
      frame.setVisible(true);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setLocationRelativeTo(null);
      frame.pack();
      frame.getContentPane().setCursor(blank);
     
      game.start();
     
   }

}


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
package me.kenneth.game;

import java.awt.event.KeyEvent;

import me.kenneth.input.Controller;

public class Game {
   
   private int time;
   public Controller controls;
   
   public Game() {
      time = 0;
      controls = new Controller();
   }
   
   public void tick(boolean[] args) {
      time++;
      boolean forward = args[KeyEvent.VK_W];
      boolean back = args[KeyEvent.VK_S];
      boolean right = args[KeyEvent.VK_D];
      boolean left = args[KeyEvent.VK_A];
      boolean jump = args[KeyEvent.VK_SPACE];
      boolean crouch = args[KeyEvent.VK_CONTROL];
      boolean run = args[KeyEvent.VK_SHIFT];
      controls.tick(forward, back, left, right, jump, crouch, run);
   }
   
   public int getTime() {
      return time;
   }

}


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
package me.kenneth.input;

public class Controller {
   
   public double x, z, y, rotation, xa, za, rotationa;
   public static boolean turnLeft = false, turnRight = false;
   public static boolean walk = false, crouchWalk = false, runWalk = false;
   
   public void tick(boolean forward, boolean back, boolean left, boolean right, boolean jump, boolean crouch, boolean run) {
     
      double rotationSpeed = 0.025;
      double walkSpeed = 0.5;
      double jumpHeight = 2;
      double crouchHeight = 1.3;
      double xMove = 0;
      double zMove = 0;
     
      if (forward) {
         zMove++;
         walk = true;
      }
     
      if (back) {
         zMove--;
         walk = true;
      }
     
      if (right) {
         xMove++;
         walk = true;
      }
     
      if (left) {
         xMove--;
         walk = true;
      }
     
      if (turnLeft) {
         rotationa -= rotationSpeed;
      }
     
      if (turnRight) {
         rotationa += rotationSpeed;
      }
     
      if (jump) {
         y += jumpHeight;
         run = false;
      }
     
      if (crouch) {
         y -= crouchHeight;
         run = false;
         crouchWalk = true;
         walkSpeed = 0.2;
      }
     
      if (run) {
         walkSpeed = 1;
         runWalk = true;
      }
     
      if (!forward && !back && !right && !left && !run) {
         walk = false;
      }
     
      if (!crouch) {
         crouchWalk = false;
      }
     
      if (!run) {
         runWalk = false;
      }
     
      xa += (xMove * Math.cos(rotation) + zMove * Math.sin(rotation)) * walkSpeed;
      za += (zMove * Math.cos(rotation) - xMove * Math.sin(rotation)) * walkSpeed;
     
      x += xa;
      y *= 0.5;
      z += za;
      xa *= 0.1;
      za *= 0.1;
      rotation += rotationa;
      rotationa *= 0.1;
     
   }

}


1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
package me.kenneth.input;

import java.awt.event.FocusEvent;
import java.awt.event.FocusListener;
import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;
import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

public class InputHandler implements KeyListener, FocusListener, MouseListener, MouseMotionListener {

   public boolean[] key = new boolean[68836];
   public static int mouseX;
   public static int mouseY;
   
   @Override
   public void mouseDragged(MouseEvent event) {
     
     
     
   }

   @Override
   public void mouseMoved(MouseEvent event) {
     
      mouseX = event.getX();
      mouseY = event.getY();
     
   }

   @Override
   public void mouseClicked(MouseEvent event) {
      // TODO Auto-generated method stub
     
   }

   @Override
   public void mouseEntered(MouseEvent event) {
      // TODO Auto-generated method stub
     
   }

   @Override
   public void mouseExited(MouseEvent event) {
      // TODO Auto-generated method stub
     
   }

   @Override
   public void mousePressed(MouseEvent event) {
      // TODO Auto-generated method stub
     
   }

   @Override
   public void mouseReleased(MouseEvent event) {
      // TODO Auto-generated method stub
     
   }

   @Override
   public void focusGained(FocusEvent event) {
      // TODO Auto-generated method stub
     
   }

   @Override
   public void focusLost(FocusEvent event) {
     
      for (int i = 0; i < key.length; i++) {
         key[i] = false;
      }
     
   }

   @Override
   public void keyPressed(KeyEvent event) {
     
      int keyCode = event.getKeyCode();
      if (keyCode > 0 && keyCode < key.length) {
         key[keyCode] = true;
      }
     
   }

   @Override
   public void keyReleased(KeyEvent event) {
      int keyCode = event.getKeyCode();
      if (keyCode > 0 && keyCode < key.length) {
         key[keyCode] = false;
      }
     
   }

   @Override
   public void keyTyped(KeyEvent event) {
      // TODO Auto-generated method stub
     
   }
   
   

}
Offline GabrielBailey74
« Reply #1 - Posted 2012-03-28 01:09:06 »

That code is off of a Video on YouTube pertaining to creating a 3D fps using pure pixels/textures.
Believe I fixed it or he later released the fixes.
I'll look for the methods to fix the ease of the mouse movement, but the direction of the player's movement still is glitched depending on which degree of (90) the mouse is.

I'll just post all the classes you posted / the ones needing updating:

Controller class:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
public class Controller {

   public static double x;
   public static double z;
   public static double rotation;
   public double xa;
   public double za;
   public double rotationa;
   public double y;

   public Controller() {
   }

   public static boolean turnLeft = false;
   public static boolean turnRight = false;
   public static boolean walk = false;
   public static boolean crouchWalk = false;
   public static boolean runWalk = false;

   public void tick(boolean forward, boolean back, boolean left,boolean right, boolean jump, boolean crouch, boolean run,boolean turnRight2, boolean turnLeft2) {
      // Here we cast the rotationSpeed to 0.002 * the mouseSpeed.
     double rotationSpeed = 0.002 * Display.MouseSpeed;
      double runSpeed = 1;
      double jumpHeight = 0.9;
      double crouchHeight = 0.3;
      double walkSpeed = 0.7;
      double xMove = 0;
      double zMove = 0;

      if (turnLeft || turnLeft2) {
         rotationa -= rotationSpeed;
      }
      if (turnRight || turnRight2) {
         rotationa += rotationSpeed;
      }
      if (forward) {
         zMove += walkSpeed;
         walk = true;
      }
      if (back) {
         zMove -= walkSpeed;
         walk = true;
      }
      if (right) {
         xMove += walkSpeed;
         walk = true;
      }
      if (left) {
         xMove -= walkSpeed;
         walk = true;
      }
      if (jump) {
         y += jumpHeight;
         run = false;
      }
      if (crouch) {
         y -= crouchHeight;
         walkSpeed = 0.2;
         run = false;
         crouchWalk = true;
      }
      if (run) {
         walkSpeed = runSpeed;
         walk = true;
         runWalk = true;
      }
      if (!forward && !back && !right && !left) {
         walk = false;
      }
      if (!crouch) {
         crouchWalk = false;
      }
      if (!run) {
         runWalk = false;
      }
      xa += (xMove * Math.cos(rotation) + zMove * Math.sin(rotation))
            * walkSpeed;
      za += (zMove * Math.cos(rotation) + xMove * Math.sin(rotation))
            * walkSpeed;
      x += xa;
      y *= 0.9;
      z += za;
      xa *= 0.1;
      za *= 0.1;
      rotation += rotationa;
      rotationa *= 0.5;
   }
}


Window or Display class:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
69  
70  
71  
72  
73  
74  
75  
76  
77  
78  
79  
80  
81  
82  
83  
84  
85  
86  
87  
88  
89  
90  
91  
92  
93  
94  
95  
96  
97  
98  
99  
100  
101  
102  
103  
104  
105  
106  
107  
108  
109  
110  
111  
112  
113  
114  
115  
116  
117  
118  
119  
120  
121  
122  
123  
124  
125  
126  
127  
128  
129  
130  
131  
132  
133  
134  
135  
136  
137  
138  
139  
140  
141  
142  
143  
144  
145  
146  
147  
148  
149  
150  
151  
152  
153  
154  
155  
156  
157  
158  
159  
160  
161  
162  
163  
164  
165  
166  
167  
168  
169  
170  
171  
172  
173  
174  
175  
176  
177  
178  
public class Display extends Canvas implements Runnable {

   private static String V = "0.07";
   private int[] pixels;
   public static final String title = "EliteFront Pre-Alpha " + V + "";
   /*
    * 0.00: Basic Display Window.
    * 0.01: Rendering + alpha pixel support.
    * 0.02: Ceiling + floor environment + Basic 3D Support.
    * 0.03: Key/Mouse support + movement.
    * 0.04: Render Distance Limiting + Gradient paint shadow.
    * 0.05: Removed mouse cursor, added mouse interaction/turning.
    * 0.06: Walls,Textures (Entity Creation).
    * 0.07: First 3D Object, crash fix.
    * 0.08: Clipping, object textures, mouse movement speed detection.
    */

   public static final int WIDTH = 800;
   public static final int HEIGHT = 700;
   private static Thread t;
   private static boolean running = false;
   private Screen screen;
   private BufferedImage img;
   private Game game;
   private int fps;
   public InputHandler input;
   private int newX = 0;
   private int oldX = 0;
   public static int Dimension3D = 3;
   public static JFrame frame;
   public static int MouseSpeed;

   public Display() {
      Dimension size = new Dimension(WIDTH, HEIGHT);
      setPreferredSize(size);
      setMinimumSize(size);
      setMaximumSize(size);
      screen = new Screen(WIDTH, HEIGHT);
      game = new Game();
      img = new BufferedImage(WIDTH, HEIGHT, BufferedImage.TYPE_INT_RGB);
      pixels = ((DataBufferInt) img.getRaster().getDataBuffer()).getData();
      input = new InputHandler();
      setFocusable(true);
      addKeyListener(input);
      addFocusListener(input);
      addMouseListener(input);
      addMouseMotionListener(input);
   }

   public static void main(java.lang.String[] args) {
      BufferedImage cursor = new BufferedImage(16, 16,
            BufferedImage.TYPE_INT_ARGB);
      Cursor blank = Toolkit.getDefaultToolkit().createCustomCursor(cursor,
            new Point(0, 0), "blank");
      Display game = new Display();
      frame = new JFrame();
      frame.add(game);
      frame.setResizable(true);
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setTitle(title);
      frame.getContentPane().setCursor(blank);
      frame.pack();
      frame.setVisible(true);
      frame.setLocationRelativeTo(null);
      game.start();
   }

   void start() {
      if (running)
         return;
      running = true;
      t = new Thread(this);
      t.start();
   }

   public void run() {
      int frames = 0;
      double unprocessedSecond = 0;
      long previousTime = System.nanoTime();
      double secondsPerTick = 1 / 60.0;
      int tickCount = 0;
      boolean ticked = false;
      while (running) {
         long currentTime = System.nanoTime();
         long passedTime = currentTime - previousTime;
         previousTime = currentTime;
         unprocessedSecond += passedTime / 1000000000.0;
         requestFocus();
         while (unprocessedSecond > secondsPerTick) {
            tick();
            debug(400, 222);
            unprocessedSecond -= secondsPerTick;
            ticked = true;
            tickCount++;
            if (tickCount % 60 == 0) {
               fps = frames;
               previousTime += 1000;
               frames = 0;
            }
         }
         if (ticked) {
            render();
            frames++;
         }
         render();
         frames++;
            // Here is where the NEW mouse controlling is handled (Basing the mouse movement off of the mouse speed)
        newX = InputHandler.MouseX;
         if (Controller.rotation != 0 || Controller.rotation == 0) {
            if (newX > oldX) {
               Controller.turnRight = true;
            }
            if (newX < oldX) {
               Controller.turnLeft = true;
            }
            if (newX == oldX) {
               Controller.turnLeft = false;
               Controller.turnRight = false;
            }
            MouseSpeed = Math.abs(newX - oldX);
            oldX = newX;
         }
      }
   }

   private void debug(int max, int desired) {
      Random r = new Random();
      int results = r.nextInt(max);
      if (results == desired) {
         System.gc();
         System.runFinalization();
         System.out.println("DEBUGGED");
      }
   }

   private void render() {
      BufferStrategy bs = this.getBufferStrategy();
      if (bs == null) {
         createBufferStrategy(Dimension3D);
         return;
      }
      screen.render(game);
      for (int i = 0; i < WIDTH * HEIGHT; i++) {
         pixels[i] = screen.pixels[i];
      }
      Graphics g = bs.getDrawGraphics();
      final Graphics2D g2d = (Graphics2D) g;
      g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING,
            RenderingHints.VALUE_TEXT_ANTIALIAS_ON);
      g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING,
            RenderingHints.VALUE_ANTIALIAS_ON);
      g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
            RenderingHints.VALUE_RENDER_QUALITY);
      g.drawImage(img, 0, 0, frame.getWidth() + 10, frame.getHeight() + 10,
            null);
      g2d.setFont(new Font("Verdana", 3, 20));
      g2d.setColor(Color.YELLOW);
      g2d.drawString("Current Fps: " + fps, 10, 20);
      g.dispose();
      g2d.dispose();
      bs.show();
   }

   private void tick() {
      game.tick(input.keys);
   }

   public static void stop() {
      if (!running)
         return;
      running = false;
      try {
         t.join();
      } catch (InterruptedException e) {
         e.printStackTrace();
         System.exit(0);
      }
   }
}


InputHandler class:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
32  
33  
34  
35  
36  
37  
38  
39  
40  
41  
42  
43  
44  
45  
46  
47  
48  
49  
50  
51  
52  
53  
54  
55  
56  
57  
58  
59  
60  
61  
62  
63  
64  
65  
66  
67  
68  
public class InputHandler implements KeyListener, FocusListener, MouseListener,
      MouseMotionListener {

   public InputHandler() {
   }

   public static int MouseX;
   public static int MouseY;
   public static int mouseButton;

   public boolean[] keys = new boolean[68836];

   /** INPUT RELATED METHODS */
   public void mouseDragged(MouseEvent m) {
   }

   public void mouseMoved(MouseEvent m) {
      MouseX = m.getX();
      MouseY = m.getY();
   }

   public void mouseClicked(MouseEvent m) {
      mouseButton = m.getButton();
   }

   public void mouseEntered(MouseEvent m) {
   }

   public void mouseExited(MouseEvent m) {
   }

   public void mousePressed(MouseEvent m) {
   }

   public void mouseReleased(MouseEvent m) {
   }

   public void focusGained(FocusEvent f) {
   }

   public void focusLost(FocusEvent f) {
      for (int i = 0; i < keys.length; i++) {
         keys[i] = false;
      }
   }

   public void keyPressed(KeyEvent e) {
      int key = e.getKeyCode();
      if (key > 0 && (key < keys.length)) {
         keys[key] = true;
      }
      if (key == 27) {
         System.gc();
         Display.stop();
         System.exit(0);
      }
   }

   public void keyReleased(KeyEvent e) {
      int key = e.getKeyCode();
      if (key > 0 && key < keys.length) {
         keys[key] = false;
      }
   }

   public void keyTyped(KeyEvent e) {
   }
}

Offline ra4king

JGO Kernel


Medals: 346
Projects: 3
Exp: 5 years


I'm the King!


« Reply #2 - Posted 2012-03-28 03:35:51 »

Way too much code posted, most people here will TL;DR and not read this.

Based on the OP's question, I believe you want the mouse to stay invisible and hidden so when you move it, it moves the player in game but the mouse stays hidden?

This is done by resetting the mouse to the center of the screen after it is moved. It is done by using the java.awt.Robot class. Beware that moving the mouse using Robot.mouseMove also throws a mouse event.

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline GabrielBailey74
« Reply #3 - Posted 2012-03-28 04:04:37 »

Way too much code posted, most people here will TL;DR and not read this.

Tell me why out of all the members i was 90% sure 'ra4king' was going to come along and say 'that's too much code posted...' or 'do this instead'.
lol  Huh Huh

Offline Fokusas

Senior Member


Medals: 3
Projects: 1



« Reply #4 - Posted 2012-03-28 07:19:33 »

Trust me you aren't alone thinking that way  Grin and most don't troll about it  Grin. And that makes illusion that your the one and only  Grin  Grin  Grin.
Offline ra4king

JGO Kernel


Medals: 346
Projects: 3
Exp: 5 years


I'm the King!


« Reply #5 - Posted 2012-03-28 07:36:10 »

O_o I was only pointing something out :/ Cry

Offline ReBirth
« Reply #6 - Posted 2012-03-28 11:34:00 »

I hate to admit but ra4king has point, we have pastebin feature which will reduce my pain in scrolling down to post this.

Offline GabrielBailey74
« Reply #7 - Posted 2012-03-29 06:20:31 »

What would be nice is if you could hide a code block beneath a lolol so you have to click to reveal/hide, it just blacks everything out atm..

Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

radar3301 (12 views)
2014-09-21 23:33:17

BurntPizza (30 views)
2014-09-21 02:42:18

BurntPizza (20 views)
2014-09-21 01:30:30

moogie (20 views)
2014-09-21 00:26:15

UprightPath (28 views)
2014-09-20 20:14:06

BurntPizza (32 views)
2014-09-19 03:14:18

Dwinin (48 views)
2014-09-12 09:08:26

Norakomi (74 views)
2014-09-10 13:57:51

TehJavaDev (102 views)
2014-09-10 06:39:09

Tekkerue (50 views)
2014-09-09 02:24:56
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!