1 #include "app/Application.h"
3 #include "graphics/Canvas.h"
4 #include "graphics/Window.h"
5 #include "world/Entity.h"
6 #include "world/World.h"
13 void make_planet(World &world, Vector<int> center, int radius) {
14 const Vector<int> begin(0, 0);
15 const Vector<int> end(world.Size());
16 const int sqrad = radius * radius;
18 for (Vector<int> pos(begin); pos.y < end.y; ++pos.y) {
19 for (pos.x = 0; pos.x < end.x; ++pos.x) {
20 Vector<int> diff(center - pos);
21 int sqdist = Dot(diff, diff);
22 if (sqdist <= sqrad) {
23 world.SetMass(pos, 1e10);
24 world.SetColor(pos, Color(0x00, 0x00, 0xA0));
26 world.SetMass(pos, 0);
27 world.SetColor(pos, Color(0x00, 0x00, 0x00, 0x00));
36 int main(int argc, const char *argv[]) {
37 SDL sdl(SDL_INIT_VIDEO);
41 Vector<int>(800, 600),
44 Canvas canv(win.CreateCanvas(
48 World world(Vector<int>(500, 500));
49 make_planet(world, Vector<int>(250, 250), 220);
52 e.vel = Vector<float>(-19, 19);
56 Application app(canv, world);