Cours Espace
int cx = 250;
int cy = 250;
int r = 100;
int rlune=30;
PImage lune;
PImage soleil;
PImage monde;
PImage asteroide;
PImage sun;
PImage espace;
int xlune=0;
int ylune=0;
int xasteroide=0;
int yasteroide=0;
int aasteroide=110;
int basteroide=90;
int [] positionLuneX;
int [] positionLuneY;
int compteurPositionlune=0;
PShape globe;
PShape Monde;
PShape Lune;
PShape Espace;
void setup()
{
size(500, 500, P3D);
monde = loadImage("monde.jpg");
soleil=loadImage("soleil.png");
lune=loadImage("lune.png");
asteroide=loadImage("asteroide.png");
sun=loadImage("sun.jpg");
espace=loadImage("espace.jpg");
globe = createShape(SPHERE, 35);
globe.setTexture(sun);
Monde = createShape(SPHERE, 20);
Monde.setTexture(monde);
Lune = createShape(SPHERE, 5);
Lune.setTexture(lune);
Espace = createShape(SPHERE, 2000);
Espace.setTexture(espace);
positionLuneX = new int [0];
positionLuneY = new int [0];
noStroke();
fill(255);
sphereDetail(40);
}
void draw()
{
background(0);
//image(espace,-100,-100,width*2,height*2);
camera(width/2, mouseY, mouseX, width/2, height/2, 0, 0, 1, 0);
if (!mousePressed) {
lights();
}text("(99942) Apophis en collision avec la Terre 13 avril 2036 ?", 20, 20);
text(" L'astéroïde mesurant moins d'un kilomètre de diamètre, ", 20, 50);
text("son impact n'aurait eu que des conséquences « régionales »", 20, 80);
text("demi-grand axe = 0.92 ua; période= 0,89 a", 20, 470);
text("périhélie 0.9 ua, aphélie = 1,1 ua", 20, 440);
text("inclinaison 3,3°", 20, 410);
float t = 0.25*millis()/1000.0f;
int x = (int)(cx+r*cos(t));
int y = (int)(cy+r*sin(t));
int xlune = (int)(x+rlune*cos(12*t));
int ylune = (int)(y+rlune*sin(12*t));
int xasteroide = (int)(cx+aasteroide*cos(0.89*t+ PI/2));
int yasteroide = (int)(cy+basteroide*sin(0.89*t+PI/2));
//positionLuneX[compteurPositionlune]=xlune;
positionLuneX= append(positionLuneX, xlune);
positionLuneY= append(positionLuneY, ylune);
println(positionLuneX.length);
for (int i=0; i<positionLuneX.length-1; i++) {
point(positionLuneX[i], positionLuneY[i]);
}
//positionLuneY[compteurPositionlune]=ylune;
compteurPositionlune++;
noFill();
ellipse(cx, cy, r*4/2, r*4/2);
pushMatrix();
translate(250, 250, 0);
//directionalLight(255, 255, 0, 10, -1, 0);
//ambientLight(0,0,255);
//texture(soleil);
//pointLight(255, 255, 0, width/2, height/2, 3000);
//rotateY(PI * frameCount / 500);
noStroke();
shape(Espace);
stroke(255);
//sphere(25);
popMatrix();
pushMatrix();
translate(250, 250, 0);
//directionalLight(255, 255, 0, 10, -1, 0);
//ambientLight(0,0,255);
//texture(soleil);
//pointLight(255, 255, 0, width/2, height/2, 3000);
rotateY(PI * frameCount / 500);
noStroke();
shape(globe);
stroke(255);
//sphere(25);
popMatrix();
pushMatrix();
translate(x, y, 0);
//directionalLight(255, 255, 0, 10, -1, 0);
//ambientLight(0,0,255);
//texture(terre);
//pointLight(255, 255, 0, width/2, height/2, 3000);
rotateY(PI * frameCount / 500);
noStroke();
shape(Monde);
stroke(255);
//sphere(25);
popMatrix();
pushMatrix();
translate(xlune, ylune, 0);
// directionalLight(255, 255, 0, 10, -1, 0);
// ambientLight(0,0,255);
//texture(Lune);
// pointLight(255, 255, 0, width/2, height/2, 3000);
rotateY(PI * frameCount / 500);
noStroke();
shape(Lune);
stroke(255);
//sphere(25);
popMatrix();
pushMatrix();
//translate(0,0,0);
rotateY(PI/250);
ellipse(cx, cy, aasteroide*4/2, basteroide*4/2);
image(asteroide, xasteroide, yasteroide, 10, 10);
popMatrix();
ellipse(x, y, rlune*4/2, rlune*4/2);
// translate(0,0,-750);
//rotateZ(0.5);
//rotateX(0.5);
//image (lune, xlune-10, ylune-10, 20, 20);
//image(terre, x-25, y-25, 50, 50);
//affichage_astre(soleil, 225, 225, 50, 50);
//image(soleil, 250-25, 250-25, 50, 50);
if ( xasteroide>x-10 && xasteroide<x+10 && yasteroide>y-10 && yasteroide<y+10) {
//noLoop();
text("Collision possible", 50, 110);
}
}
void affichage_astre( PImage astre, int positionX, int positionY, int tailleX, int tailleY) {
image (astre, positionX, positionY, tailleX, tailleY);
}