There’s again a problem…the camera should be more closer to the player… it’s very far…
Please tell how can I do such
That’s also the z value. Make it bigger
Thanks…
It worked
Sir,please also tell how can I make my player move left or right when the device is tilted
Left and right would be change of x in translate command
No idea about tilt
Use keys
Ok
One more thing…
How can I make obstacles appear in the way of the player, which the player could move aside and avoid hitting them?
https://editor.p5js.org/Nis_Collect/sketches/hqNc_rtFI
Here’s my code but there’s only obstacles which changes its place.
I need more obstacles, like they apper in some games.
I have no idea
Chrisir
…
Please try sir, please ask someone if you can.
I am a beginner and also I don’t know anyone who can answer me
except you and other over this forum
You have to do some work and cannot ask everything here…
Look at tutorials about arrays
and examples about movement
here the obstacle is resetted every time it leaves the screen. You only have ONE obstacle but it reappears again and again.
You can steer the player with
- the a key - right
- d key - left
- s key stop
var zplane = -500;
var zob = -300;
var Tobx;
var playerX = 0;
function setup() {
createCanvas(500, 500, WEBGL);
avoidClipping();
}
function draw() {
background(220);
// translate(-width,-height);
if(zob>300) {
zob = -300;
Tobx = random(-110, 110);
}
{ // obstacle
push();
translate(Tobx, 60-30, zob);
fill(255);
stroke(0);
box(60, 60, 60);
pop();
}
push();
translate(0, 60, zplane);
fill(0);
box(500, 20, 120000); // floor
pop();
fill(250, 1, 5); // RED / player
translate(playerX, 50, 200 + 10 * 5);
box(55, 65, 55);
stroke(255);
zob += 2;
zplane += 2; //5;
if(key=='a')
playerX-=2;
if(key=='d')
playerX+=2;
if(key=='s')
playerX+=0;
}
function avoidClipping() {
// avoid clipping (at camera):
// https : //
// forum.processing.org/two/discussion/4128/quick-q-how-close-is-too-close-why-when-do-3d-objects-disappear
perspective(PI / 3.0, width / height, 1, 1000000);
} //func
Consider becoming an autodidact.
One of the best tools in a programmers tool chest is knowing the resources available to you and learning to navigate them.
This is a very short list:
Resources < Click here to expand !
I encourage you to review the resources available here:
- The Processing website has references, examples, tutorials, etc.
https://processing.org/ - The Processing PDE (IDE) has lots to offer!
An exploration of the tabs will reveal what is available; libraries, tools and local examples there. - The Coding Train
https://www.youtube.com/channel/UCvjgXvBlbQiydffZU7m1_aw
https://thecodingtrain.com/ - Happy Coding
Processing Tutorials - Happy Coding - The source code can give insight if you are adventurous:
GitHub - processing/processing: Source code for the Processing Core and Development Environment (PDE)
Many of the Processing functions are here:
processing/core/src/processing/core/PApplet.java at master · processing/processing · GitHub - The Processing Foundation
https://processingfoundation.org/
Check out the tabs.
In the education tab, there is a reference to the Coding Train. - And the Internet.
:)
:)