dimanche 27 novembre 2022

لعبة hockeyball بواسطة الشبكة !


















هذه اللعبة ستكون اول نموذج تعليمي بحيث سأقوم توضيح جميع الخطوات برمجة الالعاب من النقطة صفر الى مستوى الاعتراف , الدروس ستكون على شكل اجزاء متسلسلة , اشير في الاخير ان هذه الدروس موجهة لمن لديهم ادنى معرف عن البرمجة نظريا و الرياضيات مستوى ثانوي على الاقل
1/ اختيار لغة البرمجة المناسبة
2/ علاقة شاشة الكمبيوتر بالهندسة ثنائية الابعاد
3/ مفهوم الرسومات و تحويلها الى تعليمات رقمية
4/ مبدأ حركة الرسومات في الشاشة
5/ تفاعل الفأرة و لوحة المفاتيح مع الكمبيوتر
7/ فيزياء الحركة و اصطدام الرسومات
8/ ادارة الاحداث و توجيهها
9/ مبدأ الذكاء الاصطناعي و تطبيقاته في الالعاب
10/ برمجة العاب عن طريق شبكة LAN


 

mercredi 2 novembre 2022

double pendulum

 





float theta1,vtheta1,theta2,vtheta2;

float x1,y1,x2,y2;
float vx,vy;
float g=9.8;
float l= 4;
void init() {
theta1 =0; vtheta1 = 0.0;
theta2 =0; vtheta2 = 0.0;
//l= density*l;
}
void motion(float dt) {
float a= 2;
float b= cos(theta1-theta2);
float c= cos(theta1-theta2);
float d = 1;
float b1= vtheta1*vtheta2*sin(theta1-theta2)-2*g/l*sin(theta1)+ax*vx;
float b2 = -vtheta1*vtheta2*sin(theta1-theta2)-g/l*sin(theta2)+ay*vy;
float det = a*d-b*c;
float r1= (d*b1-b*b2)/det;
float r2= (-c*b1+a*b2)/det;
vtheta1+= dt*r1;
vtheta2+= dt*r2;
// vtheta1+= dt/l*(ax*cos(theta1)+sin(theta1)*(-g+ay));
// vphi+=dt/(l*sin(phi))*(ax*sin(phi)-ay*cos(phi));
theta1+= vtheta1*dt;
vtheta1*=0.98;
// vtheta2+= vtheta1+dt/l*(ax*cos(theta2)+sin(theta2)*(-g+ay));
theta2+= vtheta2*dt;
vtheta2*=0.98;
vx+=dt*ax;
vy+=dt*ay;
}
void pendulum() {
strokeWeight(10);
k=100;
float theta1,vtheta1,theta2,vtheta2;
float x1,y1,x2,y2;
float vx,vy;
float g=9.8;
float l= 4;
void init() {
theta1 =0; vtheta1 = 0.0;
theta2 =0; vtheta2 = 0.0;
//l= density*l;
}
void motion(float dt) {
float a= 2;
float b= cos(theta1-theta2);
float c= cos(theta1-theta2);
float d = 1;
float b1= vtheta1*vtheta2*sin(theta1-theta2)-2*g/l*sin(theta1)+ax*vx;
float b2 = -vtheta1*vtheta2*sin(theta1-theta2)-g/l*sin(theta2)+ay*vy;
float det = a*d-b*c;
float r1= (d*b1-b*b2)/det;
float r2= (-c*b1+a*b2)/det;
vtheta1+= dt*r1;
vtheta2+= dt*r2;
// vtheta1+= dt/l*(ax*cos(theta1)+sin(theta1)*(-g+ay));
// vphi+=dt/(l*sin(phi))*(ax*sin(phi)-ay*cos(phi));
theta1+= vtheta1*dt;
vtheta1*=0.98;
// vtheta2+= vtheta1+dt/l*(ax*cos(theta2)+sin(theta2)*(-g+ay));
theta2+= vtheta2*dt;
vtheta2*=0.98;
vx+=dt*ax;
vy+=dt*ay;
}
void pendulum() {
strokeWeight(10);
k=100;
x1=k*l*sin(theta1)+x0;
y1=k*l*cos(theta1)+y0;
x2=x1+k*l*sin(theta2);
y2=y1+k*l*cos(theta2);
stroke(255);
float k=1000;
stroke(255);
line(x0,y0,x1,y1);
line(x1,y1,x2,y2);
stroke(255,0,0);fill(255,255,0);
// ellipse(x1,y1,60,60);
fill(200,0,0);noStroke();
lights();
//ambientLight(0,0,0,0,-1,0);
lightSpecular(255,255,255);
directionalLight(200,100,100,-1,0,-1);
specular(200);
pushMatrix();
translate(x1,y1);
sphere(50);
popMatrix();
pushMatrix();
translate(x2,y2);
sphere(60);
popMatrix();
noFill();stroke(200);
ellipse(x0,y0,60,60);
ellipse(x0,y0,10,10);
}

Hologram