What a day it was today! Life kind of got in the way as I had to renew my driver’s license, but I did manage to get it done and soldier on. Things are very slow going at the moment and as things stand right now I’ll most likely miss the deadline, but I’ll still try to get something playable. I am still planning on publishing so I’ll definitely have to take time and spend it on polishing.
The outcome of today was that I managed to hook up my DDD Gravity Simulation to Unity. The glue that holds everything together is, in all honesty, a big bleeding mess. I’m slowly in the process of migrating some of my domain entry points into singletons or hopefully abstracting it behind some service layer. I do foresee quite a bit of work, but it is definitely making my life easier in terms of how to go about with adding new functionality now. I’m also quite excited about my gravity simulation implementation.
Below is the singleton in which I’m managing most of the process. It’s currently more of a collection object that keeps track of all the bodies that exert a force on your ship.
The collection of bodies do most of the heavy lifting as seen below:
I’ve decided to have the Body class accept the simulation object it should be added to. I’m still deciding on whether I should just directly fetch the singleton, but for now this should be fine. There is also still some logic missing to remove a body from the simulation, but that should be trivial to add now.
I’m also aware that using HashSet as a collection should silently ignore adding duplicates, but I prefer to do check if a object exists in case I might want to add some extra logic related to adding duplicates. It’s also just a bit more explicit and would allow for swopping out the backing structure without the worry that I lose my uniqueness.
The other plus side is I’m now calculating a net force vector. That would allow me to draw a nice HUD arrow that can display the current gravity vector applied to your ship.
Carry on wayward stars
I’m now getting ready to add a nice parallaxing background to assist with a more visual aid towards player movement. The only current indication that the ship is moving is the offset the camera is using. It’s not obvious enough and I believe having a nice starry background would really help. That’s it for today!