Bonjour a tous ,
Je suis étudiant en l1 math , et j'ai pris une option Info Algo et programmation .
J'ai un projet qui consiste a faire un tetris en java .
J'ai commencé à créer le programme où j'ai créé une pièce " la barre " elle s'affiche bien , la pièce descend , elle bouge à droite et à gauche , mais je n'arrive pas à la faire tourner correctement .
le prof m'a donné quelques informations mais cela ne fonctionne toujours pas .
pour créer la pièce j'ai créé 4 points p1,p2,p3,p4 avec chaqu'un des coordonnées en x et y .
j'utilise cette formule pour tourner la pièce :
Merci si quelqu'un peut m'aider .
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13 p.p1.x= (int) (Math.cos(Math.PI/2)* ( p.p1.x - p.p1.x ) - Math.sin(Math.PI/2) * ( p.p1.y - p.p1.y )+p.p1.x); p.p1.y= (int) (Math.cos(Math.PI/2)* ( p.p1.y - p.p1.y ) - Math.sin(Math.PI/2) * ( p.p1.x - p.p1.x )+p.p1.y ); p.p2.x= (int) (Math.cos(Math.PI / 2)* ( p.p2.x - p.p1.x) - Math.sin(Math.PI / 2) * ( p.p2.y - p.p1.y)+ p.p2.x ); p.p2.y= (int) (Math.cos(Math.PI / 2)* ( p.p2.y - p.p1.y) + Math.sin( Math.PI / 2) * ( p.p2.x - p.p1.x)+p.p2.y ); p.p3.x= (int) (Math.cos(Math.PI/2)* ( p.p3.x - p.p1.x) - Math.sin( Math.PI/2) * ( p.p3.y - p.p1.y )+ p.p3.x ); p.p3.y= (int) (Math.cos(Math.PI/2)* ( p.p3.y - p.p1.y ) + Math.sin(Math.PI/2) * ( p.p3.x - p.p1.x )+p.p3.y ); p.p4.x= (int) (Math.cos(Math.PI/2)* ( p.p4.x - p.p1.x) - Math.sin(Math.PI/2) * ( p.p4.y - p.p1.y ) + p.p4.x); p.p4.y= (int) (Math.cos(Math.PI/2)* ( p.p4.y - p.p1.y ) + Math.sin(Math.PI/2) * ( p.p4.x - p.p1.x )+ p.p4.y );
Alexmax3







Répondre avec citation



Partager