My Path 🛣 Through MonoGame and Beyond + Beginners Guides + XBOX/UWP

OH MY CODE!

I FIXED IT!

I got XAML UWP on my XBOX running, hopefully later I can learn to interact with the XAML UI from the game if not I will be forced to create a UI.

But for now, I HAVE VIDEO RUNNING TOO!

So, I reset my XBOX since my initial attempt and learned a whole bunch of other handy tips.

Cool Fact, when you reset an Xbox, you don’t need to erase the stored games!!! mega plus in anybody’s books.

So, for one, my USB dongle based wireless receiver keyboard and mouse kit works wonderfully :heavy_check_mark:
Next was setting up the dev tool, as mentioned already, download it from the Xbox store and follow the instructions on screen after launching the app, sign into your dev store, activate etc. :heavy_check_mark:
Restart into dev mode :heavy_check_mark:
Once in dev mode, connect your VS project and uplink it to the Xbox. :heavy_check_mark: Remember, VS2017 only
VS will warn you, you need a signed in account, end the debug run, back on your Xbox, tap on the app and it will give you a sign in option thing, this one works, not the one on the right for some reason, sign in using your developer account through this wizard and hesto-presto [made that up] you should see your email address in the list to the right now :heavy_check_mark:
Now, run your code again and viola, you are now on a new platform, congratulate yourself for the long coding sessions ahead, pat yourself on your shoulder and smile, you just joined thousands of other developers :heavy_check_mark:

So, back to that other thing, the XAML UI interacts with my game pad perfectly, now the issue I was having with the frame being off a bit was, I was not using: graphics.IsFullScreen = true; Which stretched the game window to the screen bounds, I thought to try this after seeing my XAML UI was displaying over the white area you can see in a previous video post. :heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark::heavy_check_mark:

Also, for some strange reason my video plays perfectly fine now, audio too! :heavy_check_mark:

So, there are some oddities out of the way for now, just need to get back to studying again.

Took a break to refresh after getting my Xbox, and it was totally worth it, got to use GamePass and tried a bunch of Indie games and wow, super inspired and motivated to try making something now, highly recommend it!

Next I just need to understand how the whole getting stuff from Tom works, any links or tips is welcome :bowl_with_spoon:.

EDIT

The same issue occurred, the one that made me reset my Xbox, I can no longer access the store for some reason.

Will see what else I can try and hopefully find a solution…

EDIT

Update, so, it’s still being a pain, however, GamePass games do not require the store to download, you can do this through the game pass list in your apps and games listing, so, I think the only issue I might have is accepting next months Gold games, I may try this through the website which allows you to push the games to your console, a little like a Kindle book.

I will overlook this for now as resetting my console often, feels a pain and a chore, not to mention setting up Dev mode over and over again.

If someone knows a fix, please do mention, not just for my sake, for everyone’s sake.

EDIT

Also note, you will get an error when re-singing-in your test account, just ignore it as it signs in anyway.

Very annoying, honestly.

EDIT

Another update, so, tried loading a project onto the Xbox again and got the sign in issue again, so, again, highlighted the app on the Xbox and selected sign in, had to use my login, for me I chose PIN as my verification. re-ran debug in VS and it all worked, I should add that this is after restarting from normal mode.

EDIT

Final update for this post, I GOT VS2019 TO DEPLOY TO MY XBOX! That is I had to start my project in VS2017, build, then open the project in VS2019, for some reason it worked this time despite nothing being updated, which it complained about before…

Just remember to press the Home button and sign in and then sign your test account in too. :pray:

Sorry for the delay guys, sprained my ankle… :confounded::scream::sob::dizzy_face: I do not like taking NSAIDs so you can understand, having to take a total of 2052mg [3x684mg with a minimum of 5 hours between dosages with food] of Ibuprofen daily is not exactly what I want to be doing… for the record, not a doctor and seriously seek professional advice before you take any drugs kids! Learn more here [Bing Search Result on NSAIDs and their side effects]

[Ok, medical side track over, back to MonoGame stuff]

Next up is fiddling with the XAML UI, hopefully I can avoid any frame drops, with it being quite a few years since the writing of the book I am using. I am however currently limited by my 6th Gen i7 6770HQ Skull Canyon NUC, so, when I eventually get my next system a 10th Gen i7 Surface laptop 3 15", [Yes, only in the Business division which I think is rather stupid of them {The consumer edition has an AMD :rolling_eyes: processor with a Surface Edition GPU chip}] but that is so costly and so many months away for now, I should still get pretty good 60fps; fingers crossed. But, I do have an XBOX ONE X :slight_smile:.

For now, I will hop from the beginning of Chapter 3 and shoot over to Chapter 13 and get some UI going, this will frazzle my brain a bit but I do have some experience with XAML pages, so, hopefully not so much scrambled eggs, but more sunny side up? :egg:

A reminder for the book:

I have read pretty much all of Chapter 12 though, which is why it looks slow in my progress, and some of Chapter 11 too.

Currently reading past page 433… in Chapter 13.

Hopefully my next post - unlikely today - will showcase a UI interface experience where I demonstrate a menu button which switches between the various window display options - not in the book - just my way of testing the scenario. There is a surprise trick to this, wait for the video! There will also be a video or two, as I wholly intend to test on the XBOX as well. In case it was not obvious already, you can now find I added XBOX to this threads title :slight_smile: as I am now committed to both Windows 10 Store and XBOX development.

I am yet to explore the two options for XBOX submission, as such that information will be here in about a years time when I actually have something to submit to those two programmes [I will only submit to one of them however]. The reason being, it helps if you have something to show while trying to join, and one of them requires it, if I recall correctly.

For beginners out there reading this, you may be wondering why is this guy specifically talking about Windows 10 and XBOX and not the other platforms such as MacOS/iOS and Android. Well my baby Yoda - No not seen the movie, pretty sure it was an old thing too - let me explain as best I can whilst writing this whilst in excruciating pain.

Each platform has it’s own UI coding stuff, you have platform specific UI coding, text boxes, input boxes, buttons, URL buttons, video frames and HTML frames etc. And then there is the Platform Independent - that means code that works regardless of what platform you are running the code on - UI interfaces which are either a pre-existing library - you know, like the one you found on GitHub and forgot about - or coded from scratch, - Yes, self torture is a common practice amongst us coders - using your own code.

So, long story short, as I am very content with UWP aka Windows 10/XBOX development, I can safely stick to utilising the XAML UI, however, I will find out in the next 24 hours whether or not it is a good idea.

// Partial Rant Begins
Now, I should point out that the Surface NEO and DUO - which are out within the next year - will be an exciting platform to code against, as they are dual screen devices, and I should point out now for those unaware that the DUO - the mobile phone - will be running Android, so this begs a question from me, can I still code using XAML for the UI or will I have to code a UI anyway, further down the line? For now, this question remains unanswered and I for one, want my stuff on the DUO, but I will be getting the NEO regardless, so perhaps, just getting the DUO to do Phone specific things will be more ideal, but again, as Microsoft has created an app converter for other platform programmers to cross convert their apps to work on UWP, I am pretty sure they may do the reverse and create a one touch solution for Visual Studio 2021 - YES IT IS DUE SOON! in the coming 6 months - to enable deployment to the DUO, or if it will be done in the cloud through the Dev portal dashboard thing, which makes me wonder if we should skip VS2019 support for templates, though I suspect the NuGet stuff may circumvent this, I just hope it really is a one click solution and fully functioning out of the box, but the more I learn, the more I may be involved, hopefully.
// Partial Rant Ends

Having gone through that little escapade there, I think I might try to get through Chapter 13 this evening and post the results shortly after. It’s one thing to shoot through a book and show stuff working, yet another thing altogether to comprehend every scenario and explain or demonstrate it well. I do read verbatim.

How do I end this post?

Unless it’s changed since the last time I worked on it, it can support up to 8 controllers at once. I believe it can have more profiles signed in than that, but without doing some kind of special handling / hotseat setup you’re looking at a maximum of 8 for normal operation.

1 Like

Thank you so much, 8 is perfect! sadly I will only be able to test this when I stock up on well, 8 pads………. yeah… I have two for now though :slight_smile: Technically 3 but the sticks on one are umm, broken, too much speedrunners :smile: and I found out the hard way that you need the rubber that’s on the pad to keep a stick cover on… who knew lol :rolling_eyes: but I suppose it can still be used, so I just need 5 more pads, or 6 before I head over to a show floor.

Your current project there sounds interesting to me, anything like Shadow Tactics: Blades of the Shogun? https://en.wikipedia.org/wiki/Shadow_Tactics:_Blades_of_the_Shogun

Only played maybe half an hour of that game, currently going through Castlevania: SOTN [60~% EDIT of 200.6%], might attack that game next after it with a detour through FFVII beforehand.

Again, thank you so much for clarifying that.

EDIT

Got around to making my calendar for 2020 - it’s massive - and outlined that I must complete my current book on MonoGame through to January 5th, at which point I must move onto other books and my 2020 plan for global domination! - well not yet - or at least push forward with improving my skills in multiple areas, including drawing and languages, which means, the rest of this year is clean-up time for me.

Post your plans in my General Conversation thread!

Just getting out of the tail end of recovery and figured, best do a tutorial to get back into shape, today has been a wonderful day to me, so I thought I best share something nice back.

I present:
Mana Meter Tutorial

Save this image - Original name ‘Mana Meter.png’ -, I created it myself so you are welcome to utilise it however you wish to, I did however realise I kind of forgot to make an empty circle lol, anyway, for the purpose of this tutorial, this will do.

Step 1
Follow my guide on the Pipeline tool in my Road to MonoGame thread linked in the first post here to output an xnb file to follow along with this tutorial, or if you prefer simply load the PNG into your project but remember to alter your code as needed, and then add the file to your project.

Step 2
Let’s add some fields in our code:

Look here in Game1:

public class Game1 : Game
{
    GraphicsDeviceManager graphics;
    SpriteBatch spriteBatch;
    ...
    ...

Just below that, make your code look like so:

public class Game1 : Game
{
    GraphicsDeviceManager graphics;
    SpriteBatch spriteBatch;

    private Texture2D PartialTexture;
    public int animationframe = 0;
    public int timercount;
    ...
    ...

And in your Load():

        // TODO: use this.Content to load your game content here
        PartialTexture = Content.Load<Texture2D>("Mana Meter");

And then in Update():

        // TODO: Add your update logic here

        if (timercount < 150)
        {
            timercount++;
        }
        else
        {
            animationframe++;
            timercount = 1;
        }

        if (animationframe > 7)
            animationframe = 1;

And finally in Draw():

    protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.CornflowerBlue);

        // TODO: Add your drawing code here
        spriteBatch.Begin();
        spriteBatch.Draw(PartialTexture, new Vector2(200, 200), new Rectangle(animationframe * 64, 0, 64, 64), Color.White);
        spriteBatch.End();

        base.Draw(gameTime);
    }

And then set your system to x64 and build/run…

And you should see that result.

Now I could explain what the code is doing but then again, your actual implementation would differ anyway, so have a play about and see what you come up with.

A neat trick however, using a photo manipulation application, say Photoshop, strip the colour away from the image, make it grey scale, keeping the visual effects, you can then repurpose the same graphic to represent multiple meters, simply by changing that colour flag from white, to a choice colour of yours.

Next, possibly not today or possibly today, my XMAL navigation demo.

Valentine out.

Unfortunately, I have been thwarted by a threading issue, I may try to revisit delegates and Async to see if I can get something going but unfortunately I am stuck with a UI thread call issue and it should not actually be an issue as I am doing the call in the pages cs code… weird…

Perhaps I just need a fresh look on the issue, as such I may revisit it tomorrow, or simply skip it for the time being as I still have the option of creating a UI from scratch either way, which would actually mean if I choose to, I could publish to more platforms.

Either way, sorry, but I will try again, hopefully the previous tutorial was useful regardless.

Have a wonderful week ahead all.

Hopefully have something to post in the coming three days.

Valentine out.

So.……

I got that thing working…….

I may leave it at this for now, but still got more to play with, such as pages and navigation but getting the UI thread to play nice, needed fresh eyes for sure, the code setup is a little too much for me to write a tutorial but I may do one in 2020 when I become more versed.

Time to study onwards.

Expect another follow-up demo with pages later today or tomorrow.

Valentine out.

EDIT

Got bored and ran the code on my Xbox, works perfectly fine!

So.……………… I realise these periods don’t actually slow you down from clicking PLAY below:

I finally sat down and did it, now obviously there are many things to code against, such as pausing gameplay rendering [it continues to run in the background!] and how you go about handling input, probably a mode switch I presume.

But for now I can resume the book and go about building my game engine…

Basically, I created a XAML page called options, set up the button to navigate to it in the main window and back, created said new page in code, which navigates to that, sets up the menu items, you can use the gamepad to control everything and I did not even have to program the text not being a hit target! it just works magically as you see it in the video! I have so many option selectors to play with, I may go through them in a few months time when I really get into Option Menus.

Just wanted to share this wonderful nugget with you all and I consider this my first Milestone point.

Obviously there are further considerations to go through at this point, such as the Game Start-up behaviour, main menu, gameplay and the most important of all, content loading management, going to be a fascinating time ahead… looking forward to solving those issues as they present themselves.

Time to resume my studies with refocussed eyes.

Valentine out!

Tiny update, dealing with other things, but my Xbox started behaving like normal after a few days now, I can access the store again in normal mode.

Strange but it happened, just updating that point here.

Additionally, I got capture set up, no idea why it comes out grainy for the dev mode but under normal play it works just fine?

Anyway, I added music now, and yes, the app plays the music, no post editing for me, will try to rotate my music choices but I have a small selection for now.

I think this will be an improvement from my shaky phone captures :slight_smile:

Valentine out!

Another brief update, fiddled with the volume slider, now I am having UI issues not drawing correctly, but it is something I can tackle at a later point in time as currently my feeling is, I will end up creating a simple UI eventually unless I iron out my XAML issues.

Basically running in 4K now on the desktop @150% scaling, I put together a rudimentary connection with the mediaplayer to adjust the volume according to the slider, now, oddly it stores on exit of the page, but I need to work out what the initialise trigger is to get it to either read the current value or load one from data file in future.

For now, it does what is required of it. I can simply set the volume lower in code going forward. not tested on Xbox yet but perhaps after I get SFX going and some visual trigger settings.

Thanks for catching up with me.

Valentine.

Thanks for sharing. Questions:

Source code?

Also, when you added the music, did you intend to eliminate the sound effects of manipulating the controls?

1 Like

Which code, and umm the system sounds are quite low in general, still early days for me with such material and it may be a month or so before I tackle it again.

Code to play or code to manipulate the music or code to load?

Code to manipulate is incomplete at this stage as I need to figure out how to store and prevent the controls from reseting once set, the other issue is the UI dies when clicking some controls.

Thanks.

Valentine.

I thought that since this was a thread for beginners that there may be shared source code for whatever is demo’ed in the thread. So I meant “all the code”.

No clue where you got that idea, it doesn’t say that anywhere here, but if you were more specific, I may be able to oblige but right now not for my demo content.

Aiming to post more updates soon, just sorting some hard life choice things out.

Oh this is going to be fun to step back to after half a year… I wonder if I can use VS19 with my XBOX?

So I got 3.8DevBranch working on my XBOX with Visual Studio 2019, though having issues with output display, might have to work on 3.7 for a while to test but that feels backwards…

Still trying to figure it out.

I hope someone can help, I have tried so many things, and one time I got it working, the next day it went back to doing this, does anyone know how to solve this issue?

This is DevBranch3.8+ UWP on XBOX, on desktop it runs fine, on console, it shows that offset. sometimes it states 1920x1080 and sometimes a random number like that.

Any help much appreciated so I can get writing tutorials!

EDIT

I should point out that is happens in a clean app as well.

EDIT

OOOOOOOOOOOOOOOOOOH I LOVE CODING!!!

Fixed it, will try to remember to add it to my next tutorial.

Oh finally, I can get back to coding!

**

> Fix for UWP 3.8DevBranch template

**

You need to have:

using System;
...
using Windows.ApplicationModel;
using Windows.ApplicationModel.Activation;
...
using Windows.UI.ViewManagement;
using Windows.UI.Xaml;
using Windows.UI.Xaml.Controls;
...
using Windows.UI.Xaml.Navigation;

In your App.xaml.cs

And then just at the start of everything:

/// <summary>
/// Provides application-specific behavior to supplement the default Application class.
/// </summary>
sealed partial class App : Application
{
    static string deviceFamily;

Add that field static string deviceFamily;

And add:

    //API check to ensure the "RequiresPointerMode" property exists, ensuring project is running on build 14393 or later
    if (Windows.Foundation.Metadata.ApiInformation.IsPropertyPresent("Windows.UI.Xaml.Application", "RequiresPointerMode"))
    {
        //If running on the Xbox, disable the default on screen pointer
        if (IsXbox())
        {
            Application.Current.RequiresPointerMode = ApplicationRequiresPointerMode.WhenRequested;
        }
    }

Before the closing bracket of public App()

And then add:

/// <summary>
/// Detection code in Windows 10 to identify the platform it is being run on
/// This function returns true if the project is running on an XboxOne
/// </summary>
public static bool IsXbox()
{
    if (deviceFamily == null)
        deviceFamily = Windows.System.Profile.AnalyticsInfo.VersionInfo.DeviceFamily;

    return deviceFamily == "Windows.Xbox";
}

Immediately after public App()

And then the top of OnLaunched() should look like this:

/// <summary>
/// Invoked when the application is launched normally by the end user.  Other entry points
/// will be used such as when the application is launched to open a specific file.
/// </summary>
/// <param name="e">Details about the launch request and process.</param>
protected override void OnLaunched(LaunchActivatedEventArgs e)
{

    // By default we want to fill the entire core window.
    ApplicationView.GetForCurrentView().SetDesiredBoundsMode(ApplicationViewBoundsMode.UseCoreWindow);

#if DEBUG
    if (System.Diagnostics.Debugger.IsAttached)
    {
        this.DebugSettings.EnableFrameRateCounter = true;
    }
#endif
...
}

Just after that #endif ' you should see 'Frame rootFrame = Window.Current.Content as Frame;....

An additional thing to add:

Add this to public Game1()
_graphics.IsFullScreen = true;

And viola, that’s the full screen template fixed.

Now I think it’s @harry-cpp I should ping to fix this?

Also the XAML pages simply show:

xmlns:local="using:UwpGame">

All the time, this is App.xaml

And the same in GamePage.xaml, it does not appear to cause any issues and I can manually correct it but, um it might fail validation and cause page change issues? I think I noticed this work half the time that it would state the project name, so something is broken somewhere, wish I knew how to fix it but right now, VS hookups are not my scene.

EDIT

Also to note, max 17763 and min 14393 target platforms are required.

Oooh, I forgot to put up the font.xnb tutorial :scream:

Bump me if someone needs it as I have finally worked it out more than I had before.

I will actually duplicate a tutorial from another thread which is incoming shortly today despite the house falling on me.

Back in the swing of things!

:sake:

Here’s the missing tutorial: