diff --git a/Axolotl2D.Example/Axolotl2D.Example.csproj b/Axolotl2D.Example/Axolotl2D.Example.csproj index e80a955..c3612b5 100644 --- a/Axolotl2D.Example/Axolotl2D.Example.csproj +++ b/Axolotl2D.Example/Axolotl2D.Example.csproj @@ -12,15 +12,15 @@ + - - + + - - + diff --git a/Axolotl2D.Example/ExampleGame.cs b/Axolotl2D.Example/ExampleGame.cs index 4d74de0..df96866 100644 --- a/Axolotl2D.Example/ExampleGame.cs +++ b/Axolotl2D.Example/ExampleGame.cs @@ -2,6 +2,7 @@ using Axolotl2D.Cef; using Axolotl2D.Drawable; using Microsoft.Extensions.Logging; +using System.Numerics; using System.Reflection; namespace Axolotl2D.Example @@ -22,6 +23,8 @@ public ExampleGame(IServiceProvider services, ILogger logger, Sprit // It is recommended to hook OnLoad to load assets OnLoad += Load; + OnDraw += Draw; + this._logger = logger; this._assetManager = assetManager; this._cefBrowserManager = cefBrowserManager; @@ -29,11 +32,15 @@ public ExampleGame(IServiceProvider services, ILogger logger, Sprit _song = audioPlayer.LoadSong(Assembly.GetEntryAssembly()!.GetManifestResourceStream("Axolotl2D.Example.Resources.Music.SpaceJazz.wav")!); } + private void Draw(double frameDelta, double frameRate) + { + + } + public void Load() { // preload assets - _assetManager.LoadSprite("mochicat", Assembly.GetEntryAssembly()!.GetManifestResourceStream("Axolotl2D.Example.Resources.Sprites.mochicat.png")!); - _assetManager.LoadSprite("rei", Assembly.GetEntryAssembly()!.GetManifestResourceStream("Axolotl2D.Example.Resources.Sprites.rei.png")!); + _assetManager.LoadSprite("logo", Assembly.GetEntryAssembly()!.GetManifestResourceStream("Axolotl2D.Example.Resources.Sprites.logo.png")!); _cefBrowserManager.RegisterBrowser("github", "https://naamloos.github.io/Axolotl2D.Webtest/"); _cefBrowserManager.RegisterBrowser("google", "https://google.com"); diff --git a/Axolotl2D.Example/Resources/Fonts/ComicMono.ttf b/Axolotl2D.Example/Resources/Fonts/ComicMono.ttf new file mode 100644 index 0000000..9bc7354 Binary files /dev/null and b/Axolotl2D.Example/Resources/Fonts/ComicMono.ttf differ diff --git a/Axolotl2D.Example/Resources/Sprites/logo.png b/Axolotl2D.Example/Resources/Sprites/logo.png new file mode 100644 index 0000000..022bfeb Binary files /dev/null and b/Axolotl2D.Example/Resources/Sprites/logo.png differ diff --git a/Axolotl2D.Example/Resources/Sprites/mochicat.png b/Axolotl2D.Example/Resources/Sprites/mochicat.png deleted file mode 100644 index d98dcb4..0000000 Binary files a/Axolotl2D.Example/Resources/Sprites/mochicat.png and /dev/null differ diff --git a/Axolotl2D.Example/Resources/Sprites/rei.png b/Axolotl2D.Example/Resources/Sprites/rei.png deleted file mode 100644 index 28e5c26..0000000 Binary files a/Axolotl2D.Example/Resources/Sprites/rei.png and /dev/null differ diff --git a/Axolotl2D.Example/Scenes/ExampleScene.cs b/Axolotl2D.Example/Scenes/ExampleScene.cs index eb00db5..9630ebc 100644 --- a/Axolotl2D.Example/Scenes/ExampleScene.cs +++ b/Axolotl2D.Example/Scenes/ExampleScene.cs @@ -9,16 +9,14 @@ namespace Axolotl2D.Example.Scenes [DefaultScene] public class ExampleScene : BaseScene { - private const int QUAD_COUNT = 9; + private const int QUAD_COUNT = 4; private const int MOVE_SPEED = 5; private float _currentXPos = 0; private bool _goesRight = true; private float _currentRotation = 0; - private BaseDrawable? _object1; - private BaseDrawable? _object2; - private BaseDrawable? _object3; + private BaseDrawable? _logo; private IMouse? _mouse; private IKeyboard? _keyboard; @@ -42,22 +40,14 @@ public override void Draw(double frameDelta, double frameRate) { for (int i = 0; i < QUAD_COUNT; i++) { - BaseDrawable? thisSprite; - if (i % 3 == 0) - { - thisSprite = _object1; - } - else if (i % 3 == 1) - { - thisSprite = _object2; - } - else - { - thisSprite = _object3; - } - thisSprite!.Rotation = _currentRotation; - thisSprite!.Draw(new Vector2(_currentXPos, i * 74), new Vector2(50, 50)); + _logo!.Rotation = _currentRotation; + _logo!.Draw(new Vector2(_currentXPos, i * 150), new Vector2(160, 100)); } + + // Squish the width and height at random speeds + float squishWidth = 160 + (float)(Math.Sin(_currentRotation * 2) * 80); + float squishHeight = 100 + (float)(Math.Cos(_currentRotation * 3) * 50); + _logo!.Draw(new Vector2(300, 300), new Vector2(squishWidth, squishHeight)); } public override void Load() @@ -68,9 +58,7 @@ public override void Load() // It is not recommended to load Sprites any time a scene is initialized, as it can cause memory leaks. // At this moment it is not possible to do this any other way. This will be fixed in the future. - this._assetManager.TryGetSprite("mochicat", out _object1); - this._assetManager.TryGetSprite("rei", out _object2); - _object3 = new SimpleQuad(_game, new Vector2(0, 0), new Vector2(50, 50)); + this._assetManager.TryGetSprite("logo", out _logo); _mouse = _game.GetMouse(); _keyboard = _game.GetKeyboard(); @@ -92,7 +80,7 @@ public override void Unload() public override void Update(double frameDelta) { - float maxX = _game.Viewport.X - 50; + float maxX = _game.Viewport.X - 160; float deltaPosition = MOVE_SPEED * ((float)frameDelta * 60); _currentXPos += _goesRight ? deltaPosition : -deltaPosition; @@ -108,7 +96,7 @@ public override void Update(double frameDelta) } if (_keyboard!.IsKeyPressed(Key.Space)) - _game.ClearColor = Color.Red; + _game.ClearColor = Color.FromHTML("#00BBFF"); else _game.ClearColor = Color.FromHTML("#0088FF");