My Path šŸ›£ Through MonoGame and Beyond + Beginners Guides + XBOX/UWP

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? Shadow Tactics: Blades of the Shogun - Wikipedia

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:

I think this is a good place to put thisā€¦

Assuming that works, you should see 10,000 sprites rendered on an XBOX ONE X, using around 84MB and sub 10% CPU, and barely any GPU of a single GPU Engine, as far as I am aware, we can only access a single GPU Engine via UWP/C#, unsure as of yet about more than a single CPU thread however.

I did try 20,000 objects, but it did not like that from a single batch loop.

Back to studying for me.

EDIT

OK, video compression and too much movement is causing issues with playback, hopefully you can see it clearlyā€¦

Here is another video showing just 500 objects:

It refuses to embed again, oh wellā€¦

1 Like

I also recently updated the Fullscreen fix for UWP XAML XBOX development:

3.8 NuGet XBOX Template Fullscreen Fix (monogame.net)

So, here is another video and a screengrab:

Screenshot_2021-11-03_12-18-57_mini

I have added a simple benchmark, I am still reading through a book by the way.

EDIT

I am hitting 31-60 fps typical, luckily, I do not plan to throw so many objects on screen at a time, and without optimisations.

EDIT

This is fun, but even the Xbox cannot capture so many similar patterns properly lol

PLANETAS
What you may be able to read is 4099 objects and 60 fps and 60 draw calls in the upper left corner

MG server is being weird, it is flagging sub 4MB images as being too large O.O

EDIT

This is super confusing:

03-11-2021_15-20-09-dmp2ldc1

120FPS? wtf?

I have since enabled AMD VRR and 36bit colour and full RGB, but seeing 120FPS is so comforting :slight_smile: