This was my extracurricular activity for the weekend. I was curious to play around with sensors in a .NET MAUI application, so for this exercise, I set out to:
So once again, the thought of ‘why not?’ came up, and I thought I could use that information to make a small spaceship game.
The first thing I did was create a project in Visual Studio using the .NET MAUI template and give it a name. For this case, I used MauiGyras.
I started with the object I wanted to move, so I designed a small spaceship using SkiaSharp. To do this, in the MainPage.xaml, I removed the default content and placed a canvas:
All the painting and what we want to do will happen in the PaintSurface event of the canvas, so we will subscribe to the event in the constructor like this:
What does the method do in broad terms? It generates the image of a spaceship using simple shapes: the cabin is a blue triangle, two wings are blue, the cockpit is a yellow circle, and the thrusters are two red circles. It also receives some parameters, such as the canvas to be able to paint it and the center points of the screen. Now we need to call the method, and we will do this in the PaintSurface event, so you just need to call the DrawSpaceship method: