ref: 75dfc00c40c6d811143b3dfaca865e3caa48db68
parent: 7ed124593ebda443fc4d0f1439d1fd8dc602ce72
author: rodri <rgl@antares-labs.eu>
date: Sun Aug 1 11:11:30 EDT 2021
randomly position the ships, facing each other.
--- a/musw.c
+++ b/musw.c
@@ -124,7 +124,7 @@
0, 0, 1
}, R = {
cos(ship->θ), -sin(ship->θ), 0,
- sin(ship->θ), cos(ship->θ), 0,
+ sin(ship->θ), cos(ship->θ), 0,
0, 0, 1
};
--- a/universe.c
+++ b/universe.c
@@ -28,20 +28,34 @@
void
inituniverse(Universe *u)
{
- u->ships[0].p = Pt2(SCRW/2-50,SCRH/2-50,1);
- u->ships[0].θ = (180+45)*DEG;
+ int i;
+ double θ;
+ Point2 aimstar;
+
+ u->star.p = Pt2(0,0,1);
+ u->star.mass = 5.97e24; /* earth's mass */
+
+ θ = ntruerand(360)*DEG;
+ for(i = 0; i < nelem(u->ships); i++){
+ θ += i*180*DEG;
+ Matrix R = {
+ cos(θ), -sin(θ), 0,
+ sin(θ), cos(θ), 0,
+ 0, 0, 1
+ };
+
+ u->ships[i].p = addpt2(Pt2(0,0,1), mulpt2(xform(Vec2(1,0), R), 200));
+ aimstar = subpt2(u->star.p, u->ships[i].p);
+ u->ships[i].θ = atan2(aimstar.y, aimstar.x);
+ }
+
u->ships[0].mass = 10e3; /* 10 tons */
u->ships[0].kind = NEEDLE;
u->ships[0].fuel = 100;
- u->ships[1].p = Pt2(-SCRW/2+50,-SCRH/2+50,1);
- u->ships[1].θ = 45*DEG;
u->ships[1].mass = 40e3; /* 40 tons */
u->ships[1].kind = WEDGE;
u->ships[1].fuel = 200;
-
- u->star.p = Pt2(0,0,1);
- u->star.mass = 5.97e24; /* earth's mass */
}
Universe *