A Smoll game engine
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

49 lines
1.3 KiB

11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago
  1. using Raylib_cs;
  2. using Smoll;
  3. using Smoll.Ex1;
  4. using Smoll.Ex2;
  5. Raylib.InitWindow(800, 600, "Smoll");
  6. Layer layer = new Layer();
  7. Layer debugLayer = new Layer(Layer.DrawMode.Debug);
  8. Engine engine = new Engine();
  9. engine.AttachModule(new Smoll.Ex2.RaylibAssetManagerModule());
  10. engine.AttachLayer(layer);
  11. engine.AttachLayer(debugLayer);
  12. /* */
  13. var player = new Entity(layer);
  14. debugLayer.Attach(player);
  15. player.Attach(new Transform2DComponent(128, 128, 0, 1));
  16. player.Attach(new CrosshairGizmoComponent());
  17. player.Attach(new ExampleInputComponent(250f, 0.35f));
  18. player.Attach(new InertiaComponent(0.999f));
  19. var entity = new Entity(player);
  20. entity.Attach(new Transform2DComponent(-16, -16, 0, 4));
  21. var ship = new SpriteComponent("Ship.png");
  22. ship.zOrder = 1;
  23. entity.Attach(ship);
  24. var entity2 = new Entity(entity);
  25. entity2.Attach(new Transform2DComponent(5, -10, 0));
  26. entity2.Attach(new SpriteComponent("Laser.png"));
  27. var arrow = new ArrowComponent(2, 0);
  28. arrow.rawValue = new System.Numerics.Complex(0, -48);
  29. entity2.Attach(arrow);
  30. entity2.Attach(new ExampleShootingInputComponent());
  31. /* */
  32. while(!Raylib.WindowShouldClose()) {
  33. engine.Update();
  34. Raylib.BeginDrawing();
  35. Raylib.ClearBackground(Color.White);
  36. engine.Draw();
  37. Raylib.DrawFPS(0,0);
  38. Raylib.EndDrawing();
  39. GC.Collect(0);
  40. }
  41. Raylib.CloseWindow();