How to make a simple T Rex endless runner game in windows form and c#

Поділитися
Вставка
  • Опубліковано 10 лют 2025
  • Images and written tutorial here - www.mooict.com...
    In this tutorial we are going to make a simple endless runner similar to the dinosaur game from chrome browser. This is a endless runner so the objective of this game is to jump over the obstacles and score as high as possible.
    We are making this game in visual studio with windows form and c# programming language. In this game we will use label, picture boxes and timer. Download the images from the link above and you follow along the tutorial as we will make this game scratch. We will go over some of the core programming techniques such as resetting the game so you can play again, timer event, key down and key up event inside of windows form. Its a fun little game to practice programming with. I hope you find it useful.
    Moo Out.

КОМЕНТАРІ • 153

  • @mooict
    @mooict  3 роки тому +4

    Download this project here github.com/mooict/T-Rex-Endless-Runner-Game-in-Windows-Form

  • @igorkamerzan
    @igorkamerzan 4 роки тому +11

    Dude your tutorials are awsome. Others look like beautifully packed shit. But yours are straight coding. Thanks for all the things you do to us.

    • @bojohannesen4352
      @bojohannesen4352 7 місяців тому

      *Awesome

    • @hfauyr
      @hfauyr 5 місяців тому

      @@bojohannesen4352 u replied a little bit late...man

    • @bojohannesen4352
      @bojohannesen4352 5 місяців тому

      @@hfauyr And?

    • @hfauyr
      @hfauyr 5 місяців тому

      @@bojohannesen4352 andd it doesnt matter if he spelled something wrong he was just complimenting the man + who asked for a correction

    • @bojohannesen4352
      @bojohannesen4352 4 місяці тому

      @@hfauyr When did I ask for YOUR opinion? Exactly. I didn't. And you gave it anyway. That's how comments work.

  • @turboeddy
    @turboeddy 3 роки тому +2

    Thank you
    I've just coded my first game in c# following your guide.

    • @mooict
      @mooict  3 роки тому +2

      First of many 👍

  • @cska_hn
    @cska_hn 8 місяців тому +1

    Bro your tutorials are always good! Tks for showing me straight code. Hope you'll be better and better day by day.

    • @mooict
      @mooict  8 місяців тому

      Thank you ☺️

  • @d4rius591
    @d4rius591 3 роки тому +4

    Thank you so much for all the tutorials sir learn a lot compared to online class ❤️

  • @anderssvenson5034
    @anderssvenson5034 8 місяців тому

    Thank you for this tutorial you helped me pass my class

  • @jakubdrazkowski5780
    @jakubdrazkowski5780 4 роки тому +10

    Bruh... I LOVE YOUR TUTORIALS!!!!

  • @beamz4303
    @beamz4303 3 роки тому +1

    Keep doing this Tutorials, You are perfect for beginners :)

  • @karanveersingh5911
    @karanveersingh5911 Рік тому +1

    It was amazing help in my project

  • @matteodragoni9108
    @matteodragoni9108 Рік тому +2

    Useful!

    • @mooict
      @mooict  Рік тому

      Glad it was helpful!

  • @jamesvind9045
    @jamesvind9045 4 роки тому +1

    Very helpful! Thank you very much :)

  • @eventtus1748
    @eventtus1748 4 роки тому +1

    Thank u i really learned alot in this vid i think i would leave unity!

    • @mooict
      @mooict  4 роки тому

      Hi thanks for the compliment, these tutorials mainly cover basics of programming. if you are interested in games development I would strongly recommend learn and master unity.

  • @arvsnacs422
    @arvsnacs422 4 роки тому +1

    Thanks. Ive done it. Next stop will be your pacman.

  • @cokoprens5067
    @cokoprens5067 2 роки тому +1

    thank you dude

  • @04-jayeshkumargupta8
    @04-jayeshkumargupta8 3 роки тому

    Nice tutorials

  • @yazanjordan3103
    @yazanjordan3103 3 роки тому +1

    hey please help iam stuck i reacherd to min 20:57 my trex is moving with the obstacles i reviewd the video step by step but i coundnt find any mismatch with my code what could be wrong?????

    • @mooict
      @mooict  3 роки тому

      Check the t Tex tag in the properties, if there is a tag then remove it

    • @yazanjordan3103
      @yazanjordan3103 3 роки тому

      @@mooict yesss exactly thank you so much ... i dont know how it writen there i didnt write it u saved me

  • @mad5411
    @mad5411 2 роки тому +2

    Nise

  • @izio1111
    @izio1111 Рік тому

    thanks for the content. kind of wish you were better at explaining cos i had such a difficult time learning this or even understanding.

  • @martin_skachkov6016
    @martin_skachkov6016 3 роки тому

    Interesting video but I can't quite get in 12:36 this foreach. What is "Control" and "this.Controls". I will be so thankful if you explain it. :)

    • @mooict
      @mooict  3 роки тому +1

      This will help - www.liangshunet.com/en/202002/498218422.htm

    • @martin_skachkov6016
      @martin_skachkov6016 3 роки тому

      @@mooict Thank you!

  • @tienhuynh2435
    @tienhuynh2435 2 роки тому +1

    omg, thank you a lot

  • @godcanonen2634
    @godcanonen2634 2 роки тому

    Hey bro your tutorials are georgeous, can u help me pls? I want to make a trex can double jump and i dont know how

  • @anamulchowdhury8005
    @anamulchowdhury8005 4 роки тому +1

    I'm really interested to know how you learned C#?
    What advice do you want to give to who is beginners ?

    • @mooict
      @mooict  4 роки тому +2

      Hi, my advise would be to make as many projects as you can try different ones from games design to application development. I went through the process of making games and apps since university and I enjoyed making things that worked for me. I didn't do any commercial apps just made stuff that I wanted and see if I can do it. It's challenging but growth in any skill is always challenging.

  • @WilliamVangeance-t9t
    @WilliamVangeance-t9t 28 днів тому

    Hello I have a problem where the obstacle arent appearing and it shows error in the x.Left = this.ClientSize.Width

  • @boranylmaz686
    @boranylmaz686 Рік тому

    So if I use another gif or png instead of the gif or png you use, will I get an error?

  • @laver2571
    @laver2571 4 роки тому +1

    i got everything right but the only thing that wrong is my dino, when i run the game it appear to be a black box above near the score label and cant be moved and score still inscrease :(

  • @luanaiacobucci2483
    @luanaiacobucci2483 2 роки тому

    Really good tutorial! But your voice is a little too low!

  • @gulrqasmzad5959
    @gulrqasmzad5959 3 роки тому

    Can i write this code in jetbrains?or only visual studio

  • @abdullahajeebi
    @abdullahajeebi Рік тому

    There is a bit of a problem where the obstacle's hitbox is slightly oversized, I think you can fix this by making the image's transparent

  • @ivanpavaovucetic8276
    @ivanpavaovucetic8276 11 місяців тому +1

    Thank you so much for this but is there a reason why the dinosaur is under floor while playing the game, can you please tell me what i did wrong

    • @mooict
      @mooict  11 місяців тому

      You can check the trex.top value from the tutorial. For my one trex.Top = 367; in the timer and in the restart game function. You can also check the GitHub link for the project to view the full source code. Hope it helps.

    • @ivanpavaovucetic8276
      @ivanpavaovucetic8276 11 місяців тому +1

      @@mooict Yes, I have corrected, thank You

  • @BlackKyurem14
    @BlackKyurem14 4 роки тому

    Hi there. I encountered a problem while programming the game. I followed your tutorial very closely, but for some reason, the floor picture box doesn't shows up

    • @mooict
      @mooict  4 роки тому

      Did you add a picture box called floor to the form? check if that picturebox has any tags on it. Sometimes adding tags to the floor can cause it to move away from the form.

    • @BlackKyurem14
      @BlackKyurem14 4 роки тому +2

      @@mooict Thanks for your help. It seems like I accidentally added the obstacle tag to the floor. I fixed it now

  • @benwilliams8263
    @benwilliams8263 4 роки тому +1

    My obstacles and Trex are nowhere near each other but the if (trex.Bounds.IntersectsWith(x.Bounds)) is constantly true when I start the game. I don't know why

    • @mooict
      @mooict  4 роки тому

      It shouldn't be constantly true only when both picture boxes are overlapping with each other. Check the for each loop, you should be checking the tags and intersection between both objects to detect collision

    • @reversek4332
      @reversek4332 2 роки тому

      Me too

  • @pigeonblox4994
    @pigeonblox4994 4 роки тому +1

    Do you open the unity project as 2D or what?

    • @StabilerLoeffel
      @StabilerLoeffel 4 роки тому

      No its WPF but i dont recommend you to make a game in wpf as a beginner

    • @mooict
      @mooict  4 роки тому

      This is Windows Form Application in visual studio. It's a different format of app than unity games. It is in 2d but we are not using unity we are using the .net framework to manually make a game rather than using s games engine.

    • @pigeonblox4994
      @pigeonblox4994 4 роки тому

      @@mooict Oh ok thanks, I'll leave a sub, cos this tutorial is epic (:

    • @pigeonblox4994
      @pigeonblox4994 4 роки тому +1

      @@mooict Oh ok thanks, I'll leave a sub, cos this tutorial is epic (:

  • @shintawiekeolathsakoune3779
    @shintawiekeolathsakoune3779 4 роки тому

    Thanks

  • @vergaraverniel1416
    @vergaraverniel1416 2 роки тому

    bro, How come everytime i run the game, the trex is not showing? But ain't got no error?

    • @mooict
      @mooict  2 роки тому

      Check the location for the T rex in the code. It’s located with trex.Left and trex.Top

    • @vergaraverniel1416
      @vergaraverniel1416 2 роки тому +1

      @@mooict i fixed it, thank you so much

  • @subarunatsuki1902
    @subarunatsuki1902 2 роки тому

    How do you get these images and Gif's for your projects?

    • @mooict
      @mooict  2 роки тому

      Some I found online and some of them I animated myself 😊

  • @oli9944
    @oli9944 3 роки тому

    Hello! The Trex simply doesnt appear when I run the code. It just vanishes. The obstacles are there. The dino isnt. Im 15 min into the video

  • @ss-lol
    @ss-lol 4 роки тому +2

    How did you get that “obstaclespeed”

    • @mooict
      @mooict  4 роки тому +1

      Its defined in the begining when we start programming in the project.

    • @ss-lol
      @ss-lol 4 роки тому +2

      Moo ICT oh I see it. It works! Thank you for the amazing tutorials

  • @metalweb1895
    @metalweb1895 9 місяців тому

    it tried the code and test it but it showed me a blank screen is there a way to fix it?
    the floor is not solid

  • @abeelyn
    @abeelyn 2 роки тому

    Help, i have a problem! the first time the game works but if i die and reset the game the dino stops jumping (the cactus stills move) what can i do?

    • @mooict
      @mooict  2 роки тому +2

      Could you check the game reset function and see if the Dino is resetting to the right position

    • @abeelyn
      @abeelyn 2 роки тому

      @@mooict thank you! Now it works

  • @NoName-rq8ec
    @NoName-rq8ec 3 роки тому

    It works, but whenever I tried pressing space bar it closes itself instantly. Help.

  • @anamulchowdhury8005
    @anamulchowdhury8005 4 роки тому +1

    Hello sir , this is my first time that I am making a game. I don't know why but I having problem with my obstacle, when I run the game the trex work finely but those obstacle don't move, they stay in same place!
    Do you have any idea how to fix it or where the problem is ?

    • @mooict
      @mooict  4 роки тому +2

      Hi check if you've tagged the picture boxes for the obstacles in the properties window.

    • @anamulchowdhury8005
      @anamulchowdhury8005 4 роки тому +1

      @@mooict i just fixed the problem now and thank you so much for helping me to solve the problem.

  • @xSHiN61x
    @xSHiN61x 3 роки тому

    I always get the cs1656 error and cs0108 warning with these keydown & keyup events

  • @arez446
    @arez446 4 роки тому

    @Moo ICT can you do it with the flying birds?

  • @wouter9895
    @wouter9895 4 роки тому +1

    hey there. thank you so much for this cool tutorial. but for some reason the game isn't working even tho i have no erros. when I start the game nothing happens and when i press space also nothing happens. do you have any idea why this happens?

    • @mooict
      @mooict  4 роки тому +1

      Check the timer if it's enabled in the properties window.

    • @wouter9895
      @wouter9895 4 роки тому

      @@mooict The dino now moves. but for some reason he falls thru the floor. also thanks for the quick response.

    • @mooict
      @mooict  4 роки тому

      @@wouter9895 inside the timer event there's a part that checks for collision between the floor and the player see of it matches with your one and this tutorial code.

    • @wouter9895
      @wouter9895 4 роки тому

      @@mooict oke, now that works. but now my obstacles wont move xD. I'm sorry for all the questions.

    • @mooict
      @mooict  4 роки тому

      @@wouter9895 not a problem, see if you have added the tags to the obstacles in their properties window.

  • @KoenigOne
    @KoenigOne 2 роки тому

    im a beginner and i didnt understand anything, i appreciate the working but should've explained more

    • @KoenigOne
      @KoenigOne 2 роки тому +1

      after 24h, finally i can understand whats happening, i used the website for more information. You are a true legend

  • @muhammadhammad332
    @muhammadhammad332 2 роки тому

    Hello
    Score isn’t working it remains zero after jumping over hurdles
    Can you explain please

    • @mooict
      @mooict  2 роки тому

      Hi, check if the score integer is being updated on the label. inside of the timer even you can see a line like txtScore.Text = "Score" + score; this line is updating the label as the score is being updated.

  • @dkracingfan2503
    @dkracingfan2503 4 роки тому

    My dinosaur is in the wrong place when I run the code. It is in the right place in the design tho!

    • @mooict
      @mooict  4 роки тому

      Check the location of the trex picurebox in the reset function see if it matches the tutorial

  • @aleksandranedosekina8990
    @aleksandranedosekina8990 3 роки тому

    Hey! I have a problem. When I run the code an empty form without pictures appears, plz help me((((((((

    • @mooict
      @mooict  3 роки тому +2

      Does your code has this Form constructor. If not add it to the code see if that helps.
      public Form1()
      {
      InitializeComponent();
      }

    • @aleksandranedosekina8990
      @aleksandranedosekina8990 3 роки тому

      @@mooict so now everything is ok but my Trex image is not appears, when is bump into the obstacle image is appearing. Problem CS0117 "Resources" doesn't have description for "Running"

    • @mooict
      @mooict  3 роки тому

      @@aleksandranedosekina8990 see if you've imported a image called running in the project.

    • @aleksandranedosekina8990
      @aleksandranedosekina8990 3 роки тому

      @@mooict i need tag or call pictureBox with Trex "running"?

    • @mooict
      @mooict  3 роки тому

      @@aleksandranedosekina8990 there should be an image called running for the t rex. Import that to the project and the resource error will go away.

  • @casual-mtb-veiwer_782
    @casual-mtb-veiwer_782 2 роки тому +1

    I have almost finished making flappy bird using only the console as the display. Very inefficient

    • @mooict
      @mooict  2 роки тому +1

      That’s amazing. The fact it can be done in console and YOU are doing is amazing all to itself.

  • @Dream-rs7jh
    @Dream-rs7jh 4 роки тому

    can anyone help when i go to right trex.top it doesnt work

  • @shahzadali722
    @shahzadali722 9 місяців тому

    Game is Not restart by pressing R.
    Guide me How to restart the game

    • @mooict
      @mooict  9 місяців тому

      Game restart parts starts on 25:09. From there we are adding the game over function to the timer and then adding the other instructions inside of key up event. Hope this helps.

  • @Naman.aggarwal09
    @Naman.aggarwal09 4 роки тому

    dino rex was bottom in the black picture box what i do now

    • @mooict
      @mooict  4 роки тому

      Hi I'm not sure what you mean, is the t rex not stopping on the ground after the jump?

  • @mugenmasters8564
    @mugenmasters8564 4 роки тому

    how do i create a way to save players score and make a highscore ?

    • @czhockeyfan
      @czhockeyfan 3 роки тому

      You can easily save them into the file in game directory (using streamwrite and streamread)

    • @mugenmasters8564
      @mugenmasters8564 3 роки тому

      @@czhockeyfan leaderboard style

  • @Youtuber-sq9yz
    @Youtuber-sq9yz 4 роки тому

    I got half way through and followed it exactly and have 70 errors already. plz help

    • @mooict
      @mooict  4 роки тому

      What's the errors?

    • @Youtuber-sq9yz
      @Youtuber-sq9yz 4 роки тому

      well there are a lot haha. But its pretty much saying that pretty much everything is an invalid token so i don't really know whats happening.

    • @mooict
      @mooict  4 роки тому

      When I usually get errors like this I check if I missed any brackets. Sometimes missing the brackets cause cascading errors through out the code.

  • @joseflores-fv7fk
    @joseflores-fv7fk 3 роки тому

    tengo el personaje T Rex pero no me sale el piso negro en donde tiene que pisar el T Rex le di iniciar pero cuando inicio el juego solamente sale el T Rex con la pantalla en blanco y no el piso negro

  • @mohamadaminyarahmadi9794
    @mohamadaminyarahmadi9794 4 роки тому

    coud u talk louder thanks for ur tutorials

    • @mooict
      @mooict  4 роки тому

      Hi sorry about the audio quality on this I will fix this issue for future videos. For now you can use the volume booster browser extension if that helps.

  • @brydenwilmans3300
    @brydenwilmans3300 3 роки тому +1

    you sound depressed, you ok there fam?

    • @beachdab8725
      @beachdab8725 3 роки тому +1

      leave the poor guy alone . no boolie pls

  • @vanekgra7213
    @vanekgra7213 4 роки тому +1

    - Привет! У меня такая проблема - игра работает нормально, но игровые очки не считаются! сделали все так, как описано на сайте...

    • @vanekgra7213
      @vanekgra7213 4 роки тому +2

      Hooray, I figured it out myself! Thank you for publishing such an interesting project!

    • @mooict
      @mooict  4 роки тому

      Well done 👍 and I'm glad you enjoyed it

  • @juicynews0
    @juicynews0 3 роки тому

    Can you pls help me?

    • @mooict
      @mooict  3 роки тому

      Hi what's the issue?

    • @juicynews0
      @juicynews0 3 роки тому

      @@mooict Hey, can you explain me the MainGameTimerEvent part? (What the MainGameTimerEvent is and for what all the ifs and elses stand for)

    • @juicynews0
      @juicynews0 3 роки тому

      @@mooict Id really appreciate it. Tomorrow I have a presentation about this and I dont get the MainGameTimerEvent part.🙁

    • @mooict
      @mooict  3 роки тому

      @@juicynews0 Hi, the main game timer event is the TICK event for the timer. For this game the timer interval is set to 20 milliseconds so this event is called every interval or tick. We control the main game logic from inside of it for example the jump, landing on the ground, obstacles moving and replacing and finally updating the score. The timer will need to be enabled for all of this to work. All the best with your presentation tomorrow.

    • @juicynews0
      @juicynews0 3 роки тому

      @@mooict Thank you so much man. I have another question about the MainGameTimerEvent. Can you explain me, for what the first IF, second IF , the else and the last IF stand for? (What we check in the ifs and else)

  • @forever_6
    @forever_6 Рік тому

    would you mind giving me your mail address so that i can send you my code to help to check?
    i have followed each step carefully, and have checked that there should be no problem, but when i execute the app, it's not what it supposed to be, the trex is beneath the black bar, when i press space, it just jumps out. in addition, it's weird that the obstacles don't do anything
    thanks in advance if you can help me out

    • @mooict
      @mooict  Рік тому

      Hi, here is the GitHub Repo for this project, github.com/mooict/T-Rex-Endless-Runner-Game-in-Windows-Form you can download it all and open it in visual studio. Hope that helps.

    • @forever_6
      @forever_6 Рік тому

      @@mooict thanks, i did it, i execute your project, it's better that it can be played, but the trex still doesn't show up correctly in the initial position. i can just see its head, it's body is covered by the black bar. i didn't change anything, i don't know why it works like that

    • @mooict
      @mooict  Рік тому

      @@forever_6 see if you have the same line as this trex.Top = floor.Top - trex.Height; in your code.

  • @04-jayeshkumargupta8
    @04-jayeshkumargupta8 3 роки тому

    He sounds like georgenotfound

  • @MehmetikoTok
    @MehmetikoTok 6 місяців тому

    Howto convert exe

    • @mooict
      @mooict  6 місяців тому

      You can find your exe file in the debug folder inside of the visual studio project folder.

  • @freeff6406
    @freeff6406 4 роки тому

    Y is ur voice soooooooooo low?

  • @agentstona
    @agentstona 3 роки тому

    its too laggy .....when i play game

    • @mooict
      @mooict  3 роки тому

      Check the timer interval and set the interval to 20

  • @luisalichtmannecker3915
    @luisalichtmannecker3915 4 роки тому

    Bei mir kommen imme rnur 2 kakteen, kann mir jemand helfen?

  • @juanjoseduarteserna6245
    @juanjoseduarteserna6245 3 роки тому +1

    el dinosaurio se lo chupa la tierra

  • @Raas1905
    @Raas1905 3 роки тому +1

    you don't explain properly

  • @hugobertrand2299
    @hugobertrand2299 3 роки тому

    Love your tutorials! I followed this one but I got a few issues:
    1 ==> trex.Image = Propreties.Ressources.dead;
    2 ==> trex.Image = Propreties.Ressources.running;
    they both dont work and it says that the ressouces doesn't contain a defenition for the words running and dead.
    Also ==> txtscore += " Press R to restart the game!";
    it does not work and it says that it cannot implicitly convert type 'string' to 'System.Windows.Forms.Label'
    I tried to run the game without those lines and it partially worked. The obstacles and score worked, but every time I lunched it the trex went down and disappeared from the form.

    • @mooict
      @mooict  3 роки тому +1

      Hi, for the first two errors relating to the resources means your project doesn't have a image named running or dead imported to the project. If you downloaded and imported the images from the website that will solve that. The other error needs to state txtscore.Text += " Press Enter to restart". It's important to change the text property from the label not the label itself. If you try txtscore == "something" it will show an error because c# thinks you are trying to change the label itself to a string so you need add txtscore.Text to it and it should work. Hope this helps ☺️