As the topic states, I need to be able to move my mouseX “outside” of the screen, as if my screen was endless. I need it to be able to endlessly rotate a box on the x axis. The cursor should not leave the screen at any point, and can not be confined to center, as this will mess up the rotating.
Aghh I think I know what he means - back in a sec.
Can’t use the mouseMoved method because once the mouse reaches the left / right display edges any mouse move events will be for the y axis value only.
You need to base the X rotation on the mouse X position so perhaps in the middle 70% no rotation only rotate if the moseX is in the 15% either side of the display. Or something along those lines. the 15% on each side the camera speed
As some parts of the code has been written with the help of a friend, I do not exactly know what those parts of it do, although I get the general idea behind it.
We start by creating some global variables, and I can tell you that float bspeedX[...] and boolean input1[...] is not used. The float gravity=0.3; is not used either.
The cameraSpeed and cameraRotateY in setup() is used to set, of course the speed and rotation. Without those, the camera function wouldn’t work.
The try { robot = new Robot();} is used later in the code, for the camera function.
In draw() the box is drawn, speed, position and acceleration is created, as well as initializing the robot function for the camera. In draw() we also create several voids, one of them being the drawGrid(gridCount); gridCount was created as a global variable. void drawGrid is pretty self explanatory, it is used to create the grid, by drawing lines.
From int getSketchCenterX() to void updateRotation() we create the camera function. The general idea is there, although I am afraid I can’t quite explain this part. I would like to guess that it constrains the mouse, stores the location and updates the camera according to the location changes of the mouse. The robot function is used here as well.
We move down to the movement, which was also not written by me. The movement works as it should, although I would like it to be different. void keyPressed() registers the keys pressed, and updates the pressedDir accordingly. I would like to believe that this is used in PVector getMovementDir() and then used in the draw() PVector function (PVector accel) to update the movement.
The boolean w,s,a,dPressed is used to help keep track of what keys are pressed, and later used in keyReleased to figure out if the user already is moving in the opposite direction of what the user is now pressing (user presses ‘s’, is user already pressing ‘w’?)
That should be a rough explanation of the code, how crude it might be. My apologies for not being able to explain it better. Now, about the code you have written, with the jump function, would you be able to send it to me?
Cheers!
Been having troubles with the jump function for a while. I got it to jump, but never bounce. This is a tremendous help.
It seems that the player slightly floats above the grid. If this is intended, then disregard the rest of this comment. If not, it’s an easy fix by removing +player.bsize/2 from gridLevelY = height/2+player.bsize/2; in setup()
@Chrisir
I also noticed that one was able to jump, well, infinitely. This is fixed by replacing whatever is inside void startJump() { (I can’t remember) with if (bpos.y == height/2-bsize/2) { jump=true; jumpcounter=0; playermoveY=-21; }
Then the player should only be able to jump when standing on ground.
While the mouse is hover your window, click and hold the mouse button. As long as you hold it down, your mouse position will update even when outside of your window.