How to make a simple space invaders style game in windows form with C# coding

Поделиться
HTML-код
  • Опубликовано: 25 авг 2024
  • Written tutorial - www.mooict.com...
    In this tutorial we will make a simple and fun space invaders style game called sad invaders. Yea let that sink in for a second. OK we're good now. Basically I just changed a few things around for the game tutorial and change the player character to a high definition triangle and the invaders to a super sophisticated sad face image i made in power point.
    In the initial tutorial, we manually add the invaders to the form, tag them and then use a for each loop to animate and interact with them in the game. This version of the game is made through the code mainly, we are setting up the variables, adding time, key down and key up events. We create few different custom classes that create the invaders for the game, make bullets that shoot from the player and shoot down towards the player also we are spawning the and animating the invaders.
    What we are doing in this project is that we are taking the existing tutorial from MOO ICT website links above and more functionality to it and making it more interactive.
    It was a lot of fun making this game, I hope you enjoy it. As always keep programming, stay well, stay safe and Moo Out.

Комментарии • 29

  • @mooict
    @mooict  3 года назад

    Download this project here github.com/mooict/Space-Invaders-Style-Game-Tutorial-Windows-Form

  • @felixlll1407
    @felixlll1407 3 года назад +1

    Cheers for the videos, it's been a great help in giving ideas. I've been looking all around for some tutorials for games as I'm trying to make a connect 4 from windows form.

  • @sret919
    @sret919 3 года назад +1

    Thanks a lot for this tutorial, your channel looks very nice :)

    • @mooict
      @mooict  3 года назад +1

      Thank you 😊

  • @lukaasg3476
    @lukaasg3476 4 года назад +1

    Nice video again !

    • @mooict
      @mooict  4 года назад

      Thank you 😊

  • @BrianOfAteionas
    @BrianOfAteionas 4 года назад +1

    Well, after watching a 4hr C# basics video, and then following this video, my code at least has no errors, but the enemy bullets never appear, the player bullet is static and shows, but doesn't move, and for some reason I only ever get 2 enemies on screen at a time, but what did i expect, I took a C, and an x86 asm (if you can believe it) programming course 15 years ago and that's my only experience with programming so what did I expect LOL. In any case, it was fun and I learned some things. Thanks!

    • @mooict
      @mooict  4 года назад

      Hey Brian glad you liked the tutorial. I'm working on making better ones it's still very much work in progress. I did learn C when I was at uni haven't used it since but it's a real beast . I find C# comfortable to use and learn.

    • @BrianOfAteionas
      @BrianOfAteionas 4 года назад +1

      @@mooict Good to know! I'll be looking out for more tutorials. :) Also, I fixed my code. It was a couple mistakes within the long for loop (fair enough, that was the hard bit). Now I'm working on trying to get the enemy bullets to spawn from random enemies rather than the top of the screen. Not sure yet how I will accomplish that but it will be a fun puzzle for me. :)

  • @frantisekkratochvil4654
    @frantisekkratochvil4654 3 года назад +1

    I LOVE YOU

  • @arvsnacs422
    @arvsnacs422 3 года назад

    Done it. Thanks.

  • @EpTechie
    @EpTechie 3 года назад

    Thanks buddy :-)
    Can you show instructions on how to add sounds, please? 👍

  • @mushnine8621
    @mushnine8621 4 года назад

    This is great thanks! I'm trying to make a board game in C# (I'll probably try Draughts first), do you have any suggestions?

    • @mooict
      @mooict  4 года назад

      If you are interested in board games then check out the battleship tutorial you can probably make your game similar to that framework.

  • @AndrieRodriguez-hj3dm
    @AndrieRodriguez-hj3dm Год назад

    Why my bullet are invisible?

  • @joseflores-fv7fk
    @joseflores-fv7fk 2 года назад

    solo disparan los enemigos pero no se ven en la pantalla solo disparan cuando yo disparo a los enemigos cuando inicio el juego

  • @panther7584
    @panther7584 4 года назад

    Excellent video! How do I script enemies to shoot?

    • @mooict
      @mooict  4 года назад

      Hi, one of the way you can do this is pick a random enemy when the game is running and spawn the bullet from location of that enemy. There are lots of different ways to do this I think have a go at it see what it works out

  • @alazarn7
    @alazarn7 3 года назад

    why are you all creating projects in wf and not in wpf ???

    • @mooict
      @mooict  3 года назад

      Some are in Windows form and some in wpf. I have labelled all of them so you see which is made with wpf ones if needed.

  • @petraziller522
    @petraziller522 2 года назад

    can anyone tell me ... my "player" doesnt stop on the end of screen, it goes out and out of the screen it will be shoot by sadbullets. ???

    • @mooict
      @mooict  2 года назад

      Yes because the bullet is aimed at the player so even outside the scope of this level the bullet will follow the player picture box.

    • @petraziller522
      @petraziller522 2 года назад

      @@mooict thanks, and how can i stop my player running outsite? only with canvas? or is there something easier

  • @cristis.3724
    @cristis.3724 3 года назад

    Hello ! How can I change the image of the enemy bullets? I want to put meteorites instead.

    • @mooict
      @mooict  3 года назад +1

      Hi, you can make the bullet picture box bigger by adding to the height and width of the picture box and add your picture to it same way we have done for the invaders picture boxes.

    • @cristis.3724
      @cristis.3724 3 года назад

      @@mooict so.. I managed to add the meteorites but I don't know how to remove the enemy's bullets. Right now If I'm trying to play, both meteorites and bullets are coming to kill me. Do you have any idea how could I change my code so I'm attacked just by meteorites and my player would fire bullets? I will let the code below, maybe will help

    • @cristis.3724
      @cristis.3724 3 года назад

      private void makeBullet(string bulletTag)
      {
      PictureBox bullet = new PictureBox();
      bullet.Image = Properties.Resources.bullet;
      bullet.SizeMode = PictureBoxSizeMode.StretchImage;
      bullet.Size = new Size(5, 20);
      bullet.Tag = bulletTag;
      bullet.Left = player.Left + player.Width / 2;
      PictureBox meteor = new PictureBox();
      meteor.Size = new Size(30, 50);
      meteor.Image = Properties.Resources.meteor;
      meteor.Tag = "meteor";
      meteor.SizeMode = PictureBoxSizeMode.StretchImage;
      meteor.Left=player.Left + player.Width / 2;
      this.Controls.Add(meteor);
      if ((string)bullet.Tag == "bullet")
      {
      bullet.Top = player.Top - 20;
      }
      else if((string)bullet.Tag == "meteor")
      {
      bullet.Top = -100;
      }
      this.Controls.Add(bullet);
      bullet.BringToFront();
      }

    • @mooict
      @mooict  3 года назад

      @@cristis.3724 this is the make bullet function it will create a bullet when we press the space bar. So having both meteor and bullet created in this method will make both when the place presses space. You need to make a separate function for the meteor and you can make like a countdown integer in the game for example if the meteor countdown goes below 0 then run the meteor function. The reset that integer to 10 or sometime. Have a go at this and see how it works for you.
      Also you wrote bullet.top -=100 instead of meteor.top on the else if statement.