// Schwarzschild. // Okay, this will let us drive a spaceship around a black hole. Here we go: // first create an abstract object, since I guess we will in principle simulate more things. class thing { float r, phi, rdot, phidot; float s; float x,y; // also keep track of x and y coords. thing (float r_in, float phi_in, float rdot_in, float phidot_in) { // just initializes it. r = r_in; phi = phi_in; rdot = rdot_in; phidot = phidot_in; s = 0; x = r*cos(phi); y = r*sin(phi); } void update() { // update the accel values, etc. // GR version: rdot += ((r-rh)*pow(phidot,2) + pow(rdot,2)*(3*rh/(2*r*(r-rh))) - (rh*(r-rh))/(2*pow(r,3)))*deltaT; //rdot += (-G/pow(r,2)+ r*pow(phidot,2))*deltaT; phidot += (rdot*phidot*((3*rh - 2*r)/(r*(r-rh))))*deltaT; r += (rdot*deltaT); phi += (phidot*deltaT); x = r*cos(phi); y = r*sin(phi); // update the proper time. s += (1 - rh/r)*deltaT; } } // schwarzschild radius. float rh = 100; float init_r = 300; float init_phidot = 0.00137; // create the ship. thing ship = new thing(init_r,0,0,init_phidot); // create the coin thing coin = new thing(init_r,1.5,0,init_phidot); int ship_width = 30; int jet_width = 10; int coin_width = 20; color jet_color = color(252,96,5); //color bh_color = color(137,203,242); color bh_color = color(0,0,0); color ship_color = color(181,195,203); color coin_color = color(255,255,0); color heart_color = color(255,255,255); color star_color = color(40,40,80); //color star_color = color(20,20,80); color bg_color = color(0,0,60); float rocketAcc = 0.01; // overall thing for dimensional reasons. float deltaT = 0.5; //float beep_rate = 500; float beep_rate = 100; float min_scale = 1; float T = 0; //float s = 0; // proper time. // this is the number of timesteps that we go through before it displays it. // (40 is like arcade game. 20 is introspective enough that you can see things.) int display_rate = 30; int score = 0; PFont f; // the star locations int num_stars = 1000; //int num_stars = 0; int[] starsX = new int[num_stars]; int[] starsY = new int[num_stars]; int[] starSize = new int[num_stars]; int starMaxSize = 7; /* @pjs font="Arial.ttf"; */ void setup() { size(800,800); background(0,0,60); frameRate(30); for (int i =0; i