YouTube video feedback [Video Tutorials for MonoGame]

Awesome, nice videos :slight_smile:

A bit of feedback/questions…

Generic Event Delegate
For your observer pattern (ie, events), if you were so inclined, you could use the more standard sender/args pattern that Microsoft uses. EventHandler has a generic type you can use so you don’t have to make new delegates, just new event arg types. For example…

class MyEventArgs : EventArgs
{
  public string EventMessage { get; private set; }

  public MyEventArgs(string message)
  {
    this.EventMessage = message;
  }
}

...

class SomeObject
{
  public event EventHandler<MyEventArgs> SomeEvent;

  void TestEvent()
  {
    if (this.SomeEvent)
      this.SomeEvent(this, new MyEventArgs("This is a test!"));
  }
}

I don’t think you have to inherit from EventArgs either, but you can to stick with how the rest of .NET sets up its events. I have found that having the sender associated with the event is helpful though.

Dangling Event Handlers
I think there might be a bit of a lifetime management issue in your code here, though I’m not 100% sure so I’ll just bring it to your attention and you can look into it. For example, in your UI class, you pass Hero in through the constructor and have it subscribe to the OnCollect event. Now Hero is attached to the UI class, but the UI class doesn’t keep a reference to Hero or unsubscribe from that event.

I think this can be an issue in cases where you want to destroy your UI object, but the Hero object sticks around. Maybe your Hero collects something and your UI changes, so you would destroy the old one and instantiate a new UI. If you were to do this, the UI object wouldn’t actually destroy as the Hero object would be holding a reference to it, keeping it alive. Every time the OnCollect event fires, you’ll actually get two events fired, one to the new UI object and one to the old.

To fix this, you can have your UI class keep a reference to the Hero object it was given then, in the UI object’s destructor, unsubscribe from OnCollect.

What you have here is probably fine since the UI object is likely to live as long as the Hero object in your particular example, but I figured I would point it out since this was not obvious to me when I first learned this stuff. To be fair though, I learned this back in like .NET 2.0 so maybe some work has been done there? Either way, I figured I would mention it.

ICloneable
For your prototype example, there is an interface built into .NET called ICloneable that you could use instead of defining your own, if you wanted to. I don’t think there’s anything wrong with using your own, per se, but using the .NET one might make interacting with other built-in things that expect ICloneable a smoother experience.


Anyway, I just wanted to mention those. I love these videos, keep them up! :slight_smile:

1 Like

Keep going! it will be very useful for future Monogame developers and I hope more people start using Monogame. I will start some kind of tutorials in a couple of weeks, trying to finish my game first.

1 Like
2 Likes
2 Likes

Nice and well done with the channel, you have a new sub so i can find you later :grinning:

2 Likes
1 Like
2 Likes

image

For future reference

For all of those, who don’t like the AI voice :slight_smile:
(My very first try, there are problems, I will work on it/myself. Have mercy.)

2 Likes

Should have started with this… :100:
Success100GIF

1 Like

Thanks!
There are steps in the evolution, that can’t be skipped.

1 Like

It’s a process :sake:

1 Like
2 Likes

The game is starting to shape up!

1 Like
3 Likes

Got a lot out of the way this summer, will be getting down to code soon, still got 170~ pages of RBs book to traverse, but will also review your videos too at some point as I plan to give it a go in a different way, keep at it!

Hey @Lubiii I have added you to a community magazine, do DM me if you would like a preview, I have also retagged this thread under the Showcase tag as Content is more for… questions, no idea why I did not spot this sooner, looking forward to the upcoming videos!

1 Like

There’s the Live playlist, that will autoupdate.
Happy to see anyone join me live!

2 Likes

Hey, I made a few one-stream challenges to make a game.

4 Likes