The .NET on AWS Show, featuring Shaun Lawrence!

The .NET on AWS Show, featuring Shaun Lawrence!

In this episode, we discuss the evolution of cross-platform development with Xamarin.Forms and .NET MAUI, highlighting the benefits of shared code. We also discussed the potential for disruption in the mobile and AI spaces, with a focus on the importance of open source maintainers. We also show off' Shaun's game engine for .NET Maui, Orbit!

Brandon Minnick
Amazon Employee
Published May 20, 2024

Listen to the Audio Podcast

Listen to the Audio Podcast

Watch the Live Stream



 Brandon Minnick 1:10
Hello, everybody, and welcome back to another episode of the dotnet on AWS Show. I'm your host, Brandon Minnick. And actually with me today is no co host, Francoise, we hope you're doing better. He had a family emergency. But we have such an amazing guest today that I figured we'll just jump straight into it. So Shan Shan Lawrence, welcome to the show.
Shaun Lawrence 1:34
Hi, Brendan. Hello, everyone. Thank you very much for having me.
Brandon Minnick 1:38
Yeah, thanks so much for joining us shun especially, you know, we're just chatting. And it feels like I haven't even been on the show in a while because I was on vacation as getting some r&r in the Dr. Didn't make him Republic during the last show. But so good to have you, Sean. For folks who haven't met you before, who are you? What do you do?
Shaun Lawrence 2:01
Yep. So covered my name. My name is John Lawrence. Software engineer, I freelance software engineer here in the UK. I guess my day job is less exciting than the side projects. But I work with yourself on the on the open source dotnet married community toolkit, as well as a few other distractions that I've created and play around with. I've also recently written a book called introducing dotnet Maori might talk about later. So yeah, I mean, a lot of my guess the fundamental bits that I work on is Maori related. So I fully bought into
Brandon Minnick 2:41
Yeah, this episode we're leading relating heavily into into dotnet into mobile. I think as most folks know, I've been a longtime Xamarin Forms Xamarin, employee, longtime Xamarin, developer, Maori developer, as well. And yeah, like Sean mentioned, we've been working together for, gosh, years now. The Xamarin community toolkit, the dotnet Malli community toolkit. And Shawn has been doing so much amazing work for for the community for Dynamat lead developers everywhere that it only felt fair to bring him on and let him show off all the amazing things he's doing. But Shawn, before we, before we get into that, I'm curious, how did you get started with C sharp, let's go way, way back. The how you got started, and then how'd you end up into mobile?
Shaun Lawrence 3:34
So I guess almost go back to the beginning of my career. My first tech job started off maintaining an old C++ video surveillance library software. But thankfully, about a year or two in, they decided they wanted to migrate to a more modern piece of technology. They adopted WPF. And I think it was product Avalon at the time, so it's still in beta when we started working with it. And then, yes, I've worked with dotnet ever since up until this week, where I've actually jumped back to a little bit of C++. That's only a temporary Yeah. But yeah, I mean, obviously, the mobile so actually, I always remember it was when the iPhone first came out, a friend sat me down and said, this thing is going to be big, I think you should learn this. So he gave me a an old copy of a object, how to teach yourself Objective C effectively build an app with it. And then sent me a side project that he didn't want to do. There was some some driving driving factor there. But yeah, I mean, I played around with Objective C wasn't necessarily the most pleasant of languages, obviously, that evolve to Swift or got replaced by Swift, which is a much more pleasant language, and then you will see that how some dotnet has then brought in some of the fancy things. So nice to have multiple languages evolving and therefore driving each other to be better. Yeah, yeah. So I mean, I used the use of build side projects for mobile, for people to build mobile applications, then that kind of merged into the day job. About 10 years ago, I built some people, some build some apps for a client. Again, that was with Swift, and then we built the equivalent in Java, for Android, and then which someone said, oh, there's this thing called Xamarin Forms. Why don't we try and build the same thing again? Using? Which we did, and it was? Yeah, I mean, I've not really looked back to be honest. Just having the core shared value? Well, I've so much shared code, it's it really is. It doesn't make sense. I don't think to go native unless you really, really need the performance, things like that. But majority of apps that I've built, don't really rely on that.
Brandon Minnick 6:15
I am heavily biased, but I also wholeheartedly agree. I love that story, Shawn, because you mentioned you got into mobile, because a friend kind of pulled you aside and said, Hey, I think this is gonna be the next big thing. And that's, that's kind of how I felt at the time. And, but I wasn't doing any, any programming back then. I was working my first job out of college as a as a test engineer. So I was writing like a little bit of code, but mostly doing integration testing and systems level testing. But yeah, I had the exact same feeling I it was one of those things to me, where I kind of saw that, that revolution, that big wave hitting, just like with kind of that Internet revolution or bubble might be a better word for it that spring up in the late 90s. I remember thinking myself, like, I want to be a part of this. Maybe Maybe it's just gonna be another bubble like the the internet bubble burst and what 9899, but I want it oh, I want to be here for it. Because, yes, like, I don't see these going anywhere, either. So far, I'd say that, but for us paid off.
Shaun Lawrence 7:36
Yep. Yeah, definitely. I mean, that's not necessarily. I mean, like the projects I started off with, I deliberately undercharged massively, so I could learn the technology. So I wouldn't say I made a lot of money out of. But yeah, I think it has obviously become a massive ecosystem in itself. You see how much dread to think how much the big companies make out of out of, but it is a it's become an every part of every person's life, really, not every person, but you know what I mean, a very big part of everyday life.
Brandon Minnick 8:15
Yeah, it's funny you say that, because I was I still am actually in Romania. I'm here in Bucharest, beautiful, beautiful Romania, and was at a conference, the conference is actually in Yosh. This weekend, which, for anybody who's never heard of dotnet days, Romania, and you're near Yosh, go check it out. Fantastic conference. Beautiful city. I was blown away by the beauty of Yash is my first time visiting. But all that to say, I got to speak on an AI panel, which was pretty cool. Because when they asked me to speak on, I said, I'm not an AI expert, but I certainly have opinions on it. And it was moderated by a friend of the show, Richard Campbell. And he brought up the the idea that or maybe just the fact the observation that our interfaces haven't really changed in 20 years. It's because we've, we've got computers, and we had the advent of the Internet. And then we got mobile. And everything's still very similar. Like, yeah, our phones are faster, our screens are denser, and apps are hopefully better. But he kind of pointed out that there's a, an opening that's kind of primed for disruption, which, of course, then we joked about the humane AI pin which give them credit. They're getting there. They're working on something new. But yeah, it's interesting that this this new platform that we've been working on and kind of built our careers around has been so stable, so successful, but yeah, I'm curious. What, what are your thoughts around that? Do you See anything like the next big thing? Or is that the AI search bar chatbot going to be replacing?
Shaun Lawrence 10:11
Yeah, you're right. I mean, the general shift in UI is recent low, you know, I mean, over the years, just kind of between flatten gradients, you know, there's kind of weather. And we jumped between that. In terms of the next big thing. I don't know. I mean, obviously, everyone is saying AI or copilot. I think there are a lot of good use cases. There's some that I would like some that I'd like to consider investigating. Obviously, it's time and effort, which is going to be a hurdle. But one, one that's that springs to mind is as open source maintainer is. We sometimes spend a lot of time explaining code bases, problems, to newcomers, people keen to come on board and actually help us maintain or contribute to the software. I mean, chatbot could do a very good job of that. I think, being able to relieve some of the burden of an open source maintainer.
Brandon Minnick 11:22
Yeah, certainly. Yeah, don't ask me to gray one. But I agree. Maybe get help if you're listening. Give us one. But actually, that was one of the I think one of the points we all agreed on on the panel was that you. A lot of the will say, mundane, or boring tasks will quickly be replaced. And a big one that another panelist brought up was summarizing pull requests. So you write all this code, you put all this work into your repository, you submit a pull request, but now somebody has to review it. So like, I have to ping shot and be like, Hey, look at all that code I wrote, try to figure out my intent. I'm gonna explain it the best that I can. But you know, at the same time, I'm the one who wrote it. So like, not only my bias, but also I'm kind of too deep in the weeds to be the best person to explain it. Be the best person to document it. And I haven't tried it yet. But there is apparently AI, summarized, or AI generated summaries from pull requests have. Have you gotten to play around with
Shaun Lawrence 12:36
that? I haven't. I've seen it in action. I've seen the pull requests and the commits as well. There's, there's a, you can do it with great chat in Visual Studio, or visual vs. Code. I can't remember which one I saw. Yes, I know. Yeah. It's good. I mean, I know I initially thought I still quite like writing what I've done just to also sometimes double check. I know what I've done. But that comment about bias? Because like you say, obviously, writing it. You do you know what you've done in your why you've done it. Having someone else summarize it, and maybe you question whether you have done the right thing is also quite a bit.
Brandon Minnick 13:19
Yeah, I remember even just you and I were reviewing a pull request for a bug fix on the dynamic community toolkit. And one of the fixes or the first fix that was proposed, you commented that okay, well, I think this is there for a reason. And I was like, Yeah, well, actually. And then I checked into this, like, I since I wrote the code is like, here, here is the reason that I did that. But, you know, code doesn't necessarily explain intent. And when Yeah, somebody else comes along, or heck, even even me looking at my own code a month later. Like, I remember, like, I put that there for a reason. I don't know if so. Yeah, we'll see. I mean, hopefully, mobile apps are still around for a while. I love making them. I love working on them. But I'd love to actually talk more about the book that you've published, is I am insanely proud of slash jealous slash in awe. That you were able to do this, you're gonna find the time to do it. It's a book on Maui. But I think First things first. We should probably explained what is done at Maui, Shawn. Yep, sure.
Shaun Lawrence 14:33
But on that point, you have equally put in a lot of effort in terms of your video course. So I see. I mean, certainly Maui is an evolution from Xamarin Forms. They went from version six. We started the version. Sorry, Sam reforms, version five. Documentary became version six. It gave Microsoft a license to make We break a few things and do things in a way that they hope wished Xamarin Forms had evolved to. But essentially, it is a framework for building cross platform applications for now multiple idioms. So you've got desktop being Mac, a catalyst, don't Mac, Mac OS, and when Windows, and then you've got mobile being iOS and Android. And you've also had the option to build for your smart fridges as well, the Tizen platform, but that's not maintained by Microsoft is maintained by Samsung, but it's also a big company to be backing it.
Brandon Minnick 15:37
Yeah, I think for, for me, for us, for everybody listening. We're all done at Mac or dotnet developers. And so the the big, big value proposition for me was I wanted to make mobile apps, but I didn't want to have to learn Objective C, I didn't wanna have to learn Swift or Android. So so how is it and how does that work shown? Doing everything in C Sharp? And how does that integrate in with native platforms.
Shaun Lawrence 16:07
So you've got two options as well, I know Maui is Xamarin Forms, which is the cross platform nature, you've still got the dotnet. For the platforms, you've got dotnet for Android dotnet for iOS. So if you wanted to be get as close to the platform implementations as possible, you could go with dotnet for iOS. And you follow the same kind of constructs that you'd follow the same constructs that Apple provide. So you'd have an app delegate, a UI view, if you wanted to add something to the to the UI or UI button if you want to stick a button on the UI. And Microsoft provide the conversion between the two. So you, you're writing C sharp, but it is interacting with Apple's frameworks, UI kit?
Brandon Minnick 16:58
Any of those, right? Yeah, it's still using the actual native API's that Apple provides.
Shaun Lawrence 17:06
Yes, precisely. And then using that, then Microsoft did then created Maori, which is an abstraction on top of it to allow you to then say I want to put a button on screen, you use their types being a button, and it will then map down to each platform implementation. So you've got a UI button on iOS, a button on Windows? Some button widget on on iOS, Android. Yes. So Microsoft do a lot of the heavy lifting. But they don't necessarily give provide everything. So I don't know if anyone's worked with other kinds of cross platform application, I always remember PhoneGap. Back in the day, which had its merits at time. Yep, that would provide you with an API to interact with. But then getting outside of that became cumbersome. You can, you can still interact with the same layer that you would on a native platform. So if you wanted to interact with big game game controllers on on the platforms, so obviously Maori doesn't ship with that by default, because it's probably not going to be get a lot of usage. But there is a there's a game kit framework on iOS, and Mac catalyst, then there's, I forget the name, I've got it written down somewhere on on Android. So you can write your own abstraction layer and then delegate down to the platform specific layers and interact with them as you as you wish. And for that, you can just use the apple or the platform vendors documentation, because there's there's a direct mapping from Microsoft to those vendors. And you can write the code in C Sharp, which is probably one of the biggest selling points. That's
Brandon Minnick 18:59
the best part. Right? Exactly. Yeah, I think that's my favorite thing with with dotnet Maui is that, like you mentioned, Microsoft puts a ton of work into mapping every API. So if it exists in Objective C, they map that API to an API for us to hit and C sharp. And so everything we're doing and interacting with is still going down through the native API's the native platform native operating system. And I think the benefits there is there's there's really nothing you can't do. Like, like you said, some some some abstractions will say cross platform abstractions have been provided to us out of the box. But even if something doesn't already exist, if it exists on Apple, if exists for Android, then you can still do it. In C sharp so there's really not there's not much limitation there. And there's the other cross platform tooling like flutter, React Native, which, first of all, don't use C sharp. So Big thumbs down. Now just get there. They're also really good. So if you're, if you're a JavaScript developer, you can use React Native to build mobile apps. And if you're a dart developer, you can use flutter. But yeah, like a big difference is flutter essentially just draws redraws the UI for you. So it might look like it's a native iOS or native Android app. Really, if you can picture it, they just have a blank canvas. And they're, they're drawing on a button. And they've, they've just gotten really good at styling it so it looks like the native button. And when you tap it, it'll act like a native button. But
Shaun Lawrence 20:52
although I think you mentioned key difference here, there is no is the styling with something like flutter is it looks the same on all platforms, doesn't it? Whereas Maui looks as it as it would render on the platform itself. So button rendering on Android would not look the same as a bathroom rendering on iOS necessarily.
Brandon Minnick 21:16
Right? Yeah, so. So definitely benefits for all of them. But we are the dotnet on AWS show. So I think we can be heavily biased towards dotnet and recommend everybody do it. So. So for folks looking to learn more about dotnet, Malley, the books called introducing dotnet, Maui by Sean Lawrence actually introducing dotnet. Now, Colin, build a deployed cross platform applications using C sharp for dotnet and multi platform app UI. So search out for this book. What, what level programmer level developer is, should I learn C sharp first, then grab this book to learn done it Malli? If I'm already done at Maui developer looking to publish my first app, maybe I've never done that before. Is this book also for me?
Shaun Lawrence 22:10
Yes, I mean, I tried to keep the audience spectrum as wide as possible. So there is expectation that, you know, some level of C sharp and dotnet. I don't teach the fundamentals of that. But you don't need any experience with me to pick this book up. I hope that I might have exposed some things to more seasoned developers as well. But never guarantee I do walk through would create an app from scratch and go all the way through to how you might test it. And then there is a bit at the end on how you might distribute it. That mostly talks around the nuances around distribution and the common problems rather than actually walking you through how to actually distribute, distributing it was quite difficult to get down in written form, given lots of UI, just basically be screenshots of a website and would most likely be out of date as soon as it was printed. So opted to just actually talk around the problems that you most likely hit and explain some of the concepts like what capabilities are on iOS and entitlements. This is like that things that you will crop into building an app, because you'll most likely want to use some level of feature that you have to jump through some hoops to explain to Apple why you want to use them.
Brandon Minnick 23:34
It's it can be the hardest part. I remember making my first app and getting ready to deploy it. And I thought it was good. I thought it was done. Because I'd written all the code and written some tests and make sure everything looks good, and it was working. But then yeah, you start go through these steps to deploy to the stores. And man, Apple makes you jump through a lot of hoops. Android's a little bit easier, but even still, like, you still have to stuff to create all the images, the icons, you have to set up your store profile. It was very eye opening to me seeing all this extra work you have to do and it is what it is. It has nothing actually to do with dotnet Maui apps, because you would have to do the same thing. If you are building your app in Objective C is with Java or Kotlin. So it's it's good to see you've got written down and yeah, I saw teller, I think our friends in base who just published a blog post going through how to publish two things, specifically the iOS App Store for a dotnet Maui app, because I saw that article pop up and I was like, oh, that's that's ambitious. I wonder how he summarized it. And yeah, just like you said, it's a lot of screenshots. It's a lot Here's what this looks like, here's what signing or signing certificates look like, here's what provisioning profiles are, here's what our entitlements are. And it's all the things we do, just so we can get you the mobile apps, you know and love. Because it's, it's a good thing. It benefits it benefits the end user, it's there's a lot of security involved in there so that we can, or so that you don't accidentally install a fake version of an app and accidentally install malware on your phone. And so that the mobile app developer has to tell you, they're going to do push notifications, or they're going to need access to your photos library, so that you give them permission to do that first. And so it's, it's all good things. But my goodness, you can take a whole month just trying to figure that out for the first time. It's not
Shaun Lawrence 25:59
a pleasant experience isn't. Always remember, you work so hard. And you're pretty much always guaranteed to get a rejection from Apple on your first try. Because you always Yeah, yeah, but but on your point of not not of it being security, not being able to install things. This phone is an old Android device may well be a brick now because my daughter just installed what seems to be something harmless an app off the Play Store. And it's now got a corrupt it refuses to boot says some level of corruption on that. So it's
Brandon Minnick 26:36
Oh, wow,
Shaun Lawrence 26:37
I am a big advocate for the checks that they do put in place. I mean, they could it could be coincidence. But
Brandon Minnick 26:48
yeah, that's fascinating. I've, I've never seen an example of it just aware that it could happen. But yeah, certainly something you want to want to avoid. But someone else I'd love to dive into Shawn, because you've got the book on dotnet Maui. So make sure to check it out. If you're interested in learning, dotnet Maui. But also, you've created a really, really cool dotnet Maui library called orbit. And as far as I'm aware, this is first of its kind, the only thing that exists like this for dine in Maui. What is orbit?
Shaun Lawrence 27:31
It's a distraction from when I was writing the book, it was summer. So actually tie it back a little bit on what you mentioned about flutter about something being drawn on screen. I got quite interested in when I was researching that topic, and being able to put something in the book. And therefore I decided I would play around with building a game in dotnet Maori using the concepts that are available in the in the in Maori as well. So these are this is using their unified API. So there's a they give you a canvas to draw on. And then you can there's not too many things you can do. But I've tried to abstract that away into a little game engine now as well. So as I was trying to write the book, I thought, This seemed for fun. And I don't know if I've got it somewhere there was a sketch, I'd always had this idea of a game that I couldn't tell whether it be fun or not, because some of the concepts might work they might not. So I thought, well, I need an excuse to try and build the game. And then I think I had more fun trying to learn how to build a game than actually building the game or playing the game. So yeah, like the other thing I didn't mention, in my past, I have dabbled with Unity have built a game for a client. And therefore we had a little bit of idea and an understanding of how an engine would work or how you interact with them. Not from a concept of building one, but that was that was part of this fun as well.
Brandon Minnick 29:10
Yeah, so is see these buttons here interesting.
Shaun Lawrence 29:19
But at least on GitHub,
Brandon Minnick 29:22
Oh, interesting. So yeah, just want to get the diagram on on display. So for for folks listening along. We're we're looking at at Sean's Orbot repo on GitHub. And you have a an image here a diagram here called the game of game loop approach where I see it's a bunch of arrows and circles, but we've got process input points to update game points to render points to wait and then circles back around a process input. Is this the game engine that you were mentioning?
Shaun Lawrence 30:00
Oh, yes, yeah. So I guess the fundamental difference between building what's considered a typical game and a typical business application is, a business application will wait for interaction interrupts. So it's waiting for someone to touch the screen or type something in a game as they're sitting, constantly updating, or constantly looping and checking the, that's how you check to see if anything's done. That might feel similar to like a real time system, if anyone's worked on something like that. So like a SCADA system where you're controlling machinery. In a similar way, you have to be constantly checking and making sure that your performance and yes, so as you mentioned, there are there are, there are only really three key parts to the flow, the weight is more just making sure that you're doing at a consistent rate. But yes, typically, you've purchased some user input. So that would be like I mentioned before, pulling some game controller input, or the user could touch the screen at the BGA. Now you've got so many other bits of functionality you could utilize. So what was the Xamarin Essentials is now baked in, you could use the gyroscope, GPS coordinates, if you wanted to build a Pokemon clone or something like that. And then the next step in a game engine, you would then use that input, and then you'd update the state of the game. So if a user had a button pressed on a controller, maybe at the right arrow, then you could move the character, tell the state behind the scenes that the characters move by a certain amount. And then you'd render that new state on the next frame. And these typically loops every 16 milliseconds. So it's, it's not something obviously, the user notices, and the shoot really badly performant code, which I've done quite frequently. Yeah. Shadows shadows are a nightmare if you put those on and on rendering. That's why I'd hold off on that.
Brandon Minnick 32:00
So this essentially interesting, because you mentioned something that I wasn't aware of, I mean, granted, I've I've made games for the app stores, but never, never ones that needed a game engine like this. And I've seen your demo this, and it's very much like real time inputs, it's just, you know, for sure. Like side scrolling game you would play on on a console, this kind of what these games are. And so yeah, mentioning this, this game loop, and that the game game engines like Unity, don't use interrupts instead, they essentially pull. Is that right? Am I understanding that correctly?
Shaun Lawrence 32:46
The typical interactions that you would do, yes, you do. You add an object to your scene. And so you add a character in there, then you typically you'd have those two key methods, which would be, you could update the state, and you could render that state into some time, sometimes some, some of the frameworks will abstract the render to a point as well. So you don't have to worry about that it's more, you only have to deal with updating the state and it will know how to draw it, because you might add an image to it. And it knows how to render the image for you.
Brandon Minnick 33:19
So I'm curious why that is. Because if most of us watching, I'm sure we've all built a credit apps in dotnet, where you have a textbox that you can click a submit button. And we we handle that submit button tap from the user as an event event fires, so very much interrupt model. Whereas this seems like every 16 milliseconds, it'll poll to see what the updates are, is, is the reason game engines do this. This approach is to is that to avoid, like race conditions, or deadlocks or two conflicting inputs, and having to update the screen and choose which ones which.
Shaun Lawrence 34:05
So I mean, I mean, Unity Now certainly has some level of UI. It didn't have it when I when I started using the framework, so they have kind of moved towards giving you that ability to interact with something like that, how the underlying fundamentals work, I don't know how they've met that. But I suspect is that that model works for the majority of the game, therefore, you don't necessarily move outside of that paradigm for something else. I know that has, I would say a recent shift, but it's probably a good number of years ago now that they did introduce the idea of being able to like stick a button on screen. And you can react to that.
Brandon Minnick 34:46
Yeah, I guess my question or concern that I'm coming up with in my head, is that like, let's say, I move the character forward and then like, I can Well, milliseconds later, press jump. If if there were both interrupts and they both fired immediately. I can see how that might cause conflicting inputs where, oh, no, I wanted the character before. But now instead of moving forward, he's jumping straight up and down. And was thinking about in terms of this game loop, if it's waiting to check all the inputs every 16 milliseconds, then you can render it both at the same time. So you know, I'm going forward, and I'm going to jump forward, you kind of have a state almost like a old school state machine that keeps track of where everything is and what to update.
Shaun Lawrence 35:40
Yeah, and yeah, I mean, actually, the altered state machine approach works very well in this kind of scenario, because you want to avoid the, the nuances when you're, you know, I mean, where you could run into like an obscure scenarios where you might be half jumping, or you wipe the state of jumping because you're doing something else.
Brandon Minnick 36:02
Right? Do you even have a demo of the game? To show?
Shaun Lawrence 36:07
Yes, we can try and do that if I haven't.
Brandon Minnick 36:17
And, and, and while you're bringing it up, I'll share why orbit is such a big deal is most, I'd say most done at Maui apps. Are? What's it? Yeah, those credit apps, right? The ones I was just describing where, in probably most apps on your phone are our credit apps where, you know, crud, create, read, update, delete, not, not a bad word, crud, but basically, like, you know, I took a flight to Bucharest today. So I opened up my fly Delta app to get my boarding pass. And you know, we're, essentially all that app is doing and interacting with the user is just, you know, we're tapping buttons. I'm submitting my passport information I'm pulling to refresh. So kind of basic common interactions. Whereas when you get outside of that, and this is where I lose all expertise. Yeah, we get outside of that, and you have a character moving on the screen, and the screen is gonna refresh 60 120 times a second. And how all that works together. I don't know. And I'd say well, there's I don't know is there's never been a game engine for dotnet Maui. So yeah, let's let's, let's kick off the demo and see how this works. And you can explain to us what's going on under the hood.
Shaun Lawrence 37:47
Yep, sure. So this is the original idea that I came up with was the idea of a spaceship that will be orbiting a planet. And it's kind of crossed over from planetary defense, jumping past and asteroids. The idea is that your your ship is orbiting the planet, so it's using the, the rotation of the planet, and obviously, the gravity to allow you to move it, I will add that to ship my version of the library onto nougat as a pre release, I've disabled collision detection, which is why
Brandon Minnick 38:28
asteroids hitting the Earth and hitting the spaceship, that's okay.
Shaun Lawrence 38:31
But essentially, yeah, so the idea would be that you had some level of resource being your battery capacity, your battery would only recharge while you're in light of the sun. So there is a shadow here that you should notice eventually, the ship will go into come and therefore it won't continue to recharge. So that's the health actually this bar on the left is the battery and then the only two things you can do is you can speed it up by clicking on the right side of the screen or slow it down by clicking on the left and to be slightly more accessible or you can stick buttons on the screen as well just so it's obvious to the screen reader and this becomes a quite a value or a really nice mix of what you can do because I think we've got the the concepts sorry I don't know if you can hear the music but there's music playing in the background and it's
Brandon Minnick 39:22
no doubt
Shaun Lawrence 39:27
really showing the ability to meet it was just say I yes, yeah the mix so you've got the the ability to render on the screen like you can see we've got these mostly images with some level of bounding boxes that you can put in place you can slow it down and you can see that the bullets that are firing because the the trajectories of the the asteroids and and where it would collide, once it hits. And then you've got the mixture of having these these are just buttons from to Maui, and then you've got buttons here as well. So you've got the complete ability to mix them the two pieces of technology together to draw on screen or that use mouse itself. And in actual fact, the image on the background is just an image control because it doesn't need to be redrawn every 16 milliseconds because it's stuck.
Brandon Minnick 40:24
Oh, interesting. So, okay, so every, see if I can describe everything that's going on on the screen, we've got asteroids flying towards the planet, you've got a spaceship orbiting around it that is shooting out, we'll say lasers to defend the Earth. And so what you're saying is we have a background image of space, there's galaxies. And since that's static, we have that it's just basically a static image. And then all the other things we're seeing on screen. What are those? Those are images as are PNG files, those are being moved around refreshing at a certain rate, what's going on here?
Shaun Lawrence 41:05
Yes. So I mean, I could probably share a little bit of code if that's absolutely. I've got a few. I've got a folder called games in this repo, which is, I guess, my sample apps. Fairly recently, I gave a talk at NDC. I think there's started Feb now. And the talk content was within this within a game itself. So there's a you can run that up here as well add a little signal our integration as well to vote on the content. What are we looking at? Yes, so the main page is been assembled, sorry, Brendan. But you can see it's relatively straightforward. We've got a grid, then we have an image. And then on top of that, we've got a game scene view, which is a concept construct that comes with my library. It mostly just inherits from the dotnet Maui graphics view, which provides a lot of this provides the ability to draw on the screen. I've just abstracted it. So you get slightly more game engine friendly methods rather than the dotnet Maori callbacks. And it provides full interaction support, which is quite nice. So you can have touch support. That includes mouse support as well. And then there's also a hover as well. So if someone does have a mouse, and you could provide different inputs or out visuals based on whether they've got their mouse over the certain item, like a button, if you did decide to render your own button, then a label and then so yeah, I've just very crudely created some pop ups. So they just render on screen. So there's a border here with a, an image in it, and another border with it. So that's the pause button. And then there's some other bits to show that there's a there's a pause menu, so then you've got some other buttons to resume. And then you've got the ability to style it with some funky shapes that comes with it. So that's this slightly angled corners on two of the pop ups.
Brandon Minnick 43:17
So it looks like the the code we're looking at right now is kind of the, the that static base page. So everything that's not moving, like left and right buttons on the screen that background on the screen, this is this is the code we're looking at here. Yes. And
Shaun Lawrence 43:33
then we can jump over to actually. So typically, what you end up having is you have a level which would be a scene and then objects within that scene. So there are two scenes, there's the home scene and the main scene. So the scene is before you click play, it's just got a few of the same objects that you would see in the main scene. This has a few more. So you've got ship, we had a ship, sun, the planet, some battery and some indicators, battery level PlayerHealth, the ability to launch asteroids, and then some version information and the score display. The beauty is that you can use dependency injection, which is a I mean, you could use it in Xamarin Forms anyway. But it's all baked into dotnet Maori now, using the generic app post builder pattern, which is really quite nice. Another really good selling point of using Maori allows you to transition between other dotnet code bases easier, in my opinion, because the the bootstrapping should feel familiar across the across the different frameworks. So we can have a look. And then we've got a ship. That's audio game objects, and then there's a ship and this is where you can then so I mean, I've always here I've tried to kind of show how you might use some good solid principles. So you have something that does one specific task. And then because through again, through the magic of dependency injection, you can whether you want to have something as transient. So obviously get started re instantiated every time you need one, or you could scope it. So actually, every level load there was it's a scope is created, meaning that you could refer to a single instance of something for the life of the level, throw it away, and then get a new one on the next load. Which makes it a bit easier for state management because you don't have to then like tidy things up if you're gonna have a singleton. So I think that's where scoping really comes in.
Brandon Minnick 45:36
I just realized how much cooler Dependency injection is. And lifetime of objects in dependency injection. We're talking about gains. I, I've never thought about it like that before. But yeah, you're right, you do scope. Scope is an object to the level of the game or your Singleton is going to be there all time. Maybe that's your hero, and they're gonna always gonna have the same life Level to Level. Oh, gosh, that's so cool. I feel like that's how we should describe and teach dependency injection. Let's build a game. And now it's going to make sense. Yeah, yeah, that's
Shaun Lawrence 46:15
a good idea. I use a very different explanation in my book, or my wife speaking. But yeah, maybe I need to.
Brandon Minnick 46:27
Yeah, my second book. We're now using the the orbit game engine in the book describing dependency injection.
Shaun Lawrence 46:36
Easy, I like it. Yeah, so at the moment, like I said, so we said that there's two key callbacks or two key methods that you care about an object and a scene as well, they implement the same underlying interface, you've got the ability to update. So that's updating the state. So therefore, what you would do is you update your selection, you update the states based on what's happened, and over how long period of time it's taken to to happen. So if you imagine if you if you're holding a button down, so we're shifting the ship, this might not be the this might be an okay, example, I have to check what thrust as you imagine that you're, if you're not being called back on a on a completely regular basis. So if you might, if you're being called back, or 16 milliseconds, then 10 milliseconds and 20 milliseconds. 20 is obviously a bad example given. And that will be higher than that means we'll be rendering frames quicker than you would see some gesture Yes. But if you, if you use the time taken since the last callback, as a multiplying factor, then you can still provide a smooth transition, irrespective of how frequent how, whether you're being called back at an exact regular bid on an exact regular basis. Now we're talking milliseconds, so it's most likely the human is not going to see it anyway. But if you've got enough in there that might slow it down. There are things to consider there might be other things to consider if you're slowing it down enough, but they are the users know.
Brandon Minnick 48:30
What I'm saying Shawn is, like right now we're looking at the the source code for the ship, and ship inherits from game object. And earlier, we were looking at the class, which is called main page, and that inherited from game scene. Maybe its main c and Zarya, so main scene inherits from game scene, the various objects that appear on the screen inherit from game object is, is that kind of is it really just that easy? So you create your scenes, you create your objects? It looks like here in main scene you're adding those objects in? So I see like add son, ad ship, and orbit essentially takes it from there.
Shaun Lawrence 49:21
Yeah, yeah, yes, mostly. So the bit that I haven't got to yet, at the moment, you're still responsible for determining how to render things I'd actually like to be. So if you're going to have an image and your things just speak, then you don't even have to worry about doing that rendering. I could do that for you. But at the moment, you have to do a bit of you might need to translate where it is and rotate it. But you can do that in relatively few lines of code.
Brandon Minnick 49:48
Interesting. So because I'm seeing Yeah, a lot of math here. It's yes, you're essentially looking at what how much time has passed and where the object should be now on the screen when I Many renders.
Shaun Lawrence 50:02
Well, that's nice separation between update and render. So where it is on screen is a result of update, and then rendered is literally where it is droid on screen. So you've got the separation there.
Brandon Minnick 50:16
How do you know where it is inside the render method.
Shaun Lawrence 50:22
So it's so actually, the bit that we only care about is the angle of rotation in this scenario, that if you look at the ship, we can see here, what it's actually doing is it's, it's, it's just being rotated around the central point of the screen. So actually, the simplest approach there is to translate to the center of the screen and then rotate the canvas. Got the maths is only involved in working out where on screen it is, where it currently is not where it where it's changed from words to. So this is just a bit of trigonometry to work out where we're going. I'll be honest, I've, I've, I've really had to go back to high school maths. realize how lucky I was in some of these bits?
Brandon Minnick 51:23
Yeah, you got to brush up on your orbital mechanics so that you can render your spaceship properly.
Shaun Lawrence 51:35
Thanks, I thought you mentioned So there, there are two key components? Well, the two key components you really care about would be a scene, which is a level and an object, which is anything within an object within a scene, whether it's a tree that you can interact with, or whether it's a player, obviously, using some sensible level of design, so you're not having an object that does more than it should. And then the other bit, so we had main page, the other bit that you have to care about, is a type called the game Scene Manager. And that's how you load the level. And that's responsible for creating the new scope. So you could just tell it to load a new scene over type. And at the moment, you have to tell it, the UI view that you have to put you want to put it into UI view is a bad thing. That's an app and Apple term, the view or the element to the game scene view that you want to put it in? Yeah, and those are all types that come with the engine. There's, there's there's a number in here, but most of them all objects in a manager and view.
Brandon Minnick 52:49
And those those objects, so we see the you know, the spaceship and the asteroids, are those? Are you hand drawing those? Or is that as easy as just adding a PNG file to your game and pointing it at an existing image?
Shaun Lawrence 53:05
No, at the moment like it is being rendered. But I think you'll see I've turned off collision detection, but it is just a case of knowing where it is and where it's rendering. This bit, I think it's going to be one of the next things I'm going to encapsulate in order to just make it easier, because that's probably mostly just boilerplate. It's going to be quite common. The purpose of building this now is to work out what the kind of what the common use cases are going to be. And then kind of abstract that into something that could be reusable. So yeah, one of the next ones will be will be drawing images.
Brandon Minnick 53:44
Oh, cool. Yeah,
Shaun Lawrence 53:46
I mean, the other the other beauty is you don't have to draw images, if you really wanted to, you've got access to the canvas, you could draw shapes, if you really wanted to. So as another example, there's I've been trying to build an air hockey table and that that is just just drawing an ellipse because very complex.
Brandon Minnick 54:08
Very cool. So you mentioned orbits currently in pre release. So if we go to Nougat how do we find that nougat? Is it orbit?
Shaun Lawrence 54:18
I had no let's me I created it and then I discovered that somebody had to a bit that's I
Brandon Minnick 54:32
was wondering, did nobody take the the nougat package name orbit that would have been so cool.
Shaun Lawrence 54:40
Pitching center orbital engine for orbital engine was already taken also taken, I think.
Brandon Minnick 54:49
Very cool. So we've only got a couple minutes left, but what what's next for orbit before we wrap up
Shaun Lawrence 54:56
so the My plan is to try and find ways of simplifying some of the usage. So whether you're drawing an image, we just abstracted away and you don't have to worry about it. And then some level of basic collision detection. So I have had the code in the game, but I've didn't push it into a nice API. And rather than putting something out and breaking people, I thought I would just take it out for the first release. But that's something I'm currently working on to get some level of collision detection. But that becomes a bit complex when you deal with different shapes and movement and whatnot. So it might not be a one size fits all. But hopefully, it'll be an extensible API. So if it doesn't work, you can. You could still bend it to suit your needs.
Brandon Minnick 55:50
Very cool. Sham, or if anyone
Shaun Lawrence 55:51
else comes up with an idea. That'll be next.
Brandon Minnick 55:55
Yeah. Speaking of which, were where can folks find you if somebody wants to join in and help out with orbit? Or if somebody is reading the book and has a question? Where can they find you online? So
Shaun Lawrence 56:08
the best place would probably Twitter or x, which is apigenin, which is there on the screen? Or LinkedIn? Sure know what's on there.
Brandon Minnick 56:19
Yeah, so that's big J. ing to UN
Shaun Lawrence 56:25
digital aging.
Brandon Minnick 56:28
Highly British just saying it. fantastical. John, thanks so much for joining us on the show today. Thanks for teaching the world about dotnet Maoli. Obviously, if you are interested in learning Malley, make sure to pick up John's book. Getting started with our introducing dotnet, Maui, and Jim John, for selfishly, for me, thank you for all the work you've done as well. You've done a ton of work with dotnet Maui community toolkit. We've been working on that for a couple years now and couldn't have done it without you. So glad, glad to be going through going through the world with you on that project as well. So, thanks so much again, Shawn. And thank you for watching. Don't forget to like and subscribe so you never miss another episode of the dotnet Navy AWS show. We'll be back in two weeks and you could always find us and our audio podcast, same name dotnet on AWS show. You'll see it all over Spotify, Apple podcast, wherever you find your podcasts. You can find us there. Thanks again for watching, and we'll see in two weeks. Thanks

Any opinions in this post are those of the individual author and may not reflect the opinions of AWS.