Endless Runner Game Programming Tutorial with C# and WPF in Visual Studio

preview_player
Показать описание
In this project I will demonstrate how to make a simple endless runner game inside of visual studio using WPF and C#. This game will utilize different game programming methods such as sprite animation, hit test / collision and background scrolling.

We will use simple JPG and separate sprite images to build this game including running animation of the main character with only C#. WPF has made making games a lot easier with and we will see how to make a fun and simple game inside of visual studio using these methods. We can work more accurately with transparency now and this makes the games look so much better than windows form games.

You can make similar games on Unity and C# but I wanted to see if i can make something like this inside of WPF without any other framework or libraries and share my findings with you.

We will do some simple GUI set ups first and then dive right into the C# programming where we will add our main game timer, work with bitmaps and load out own custom animations and show it to the screen.

If you aren't familiar with WPF C# just yet don't worry this tutorial is aimed for beginners and we will go through each part of the programming together. In the above website address you will find the full written tutorial including the source code for this game and the images you can download and make your own.

Hope you find this game tutorial useful in your journey and keep learning from different projects.

Happy Programming. Moo Out.
Рекомендации по теме
Комментарии
Автор

Hey Moo ICT!

I would like to say thank you for putting up the tutorials and videos you have. I am a teacher teaching year one students to program in C#. We are currently covering event handlers and variables where I use this exact tutorial as a base for my assignments. I have never made a game before so this helped me out BIG TIME to get a nice start :)

Thanks again!

Diadras
Автор

Nice one 👌, Would love to see your Platform games in UNITY Development

sunilpal
Автор

The code for the background layer of this can be used to make a slot machine if you change the orientation of the rectanglea. Lots lf great fundamentals here.

anoniemoss
Автор

Hey, i had a problem when i tried to make a mini game on VS22 with WPF. It was always slow while debugging so I got here - well I learned something but my problem wasn't solved. So I downloaded your GitHub Version and same issue, very slow while debbugging. So I researched the net and well it's a problem of VS22, that the debugger is just slow. For everyone out there who has the same issue, just release and use the exe or without debbuging(2nd green arrow or Ctrl+5) or get VS19, when you work with similiar stuff.

benovka
Автор

Hi Moo ICT

I am an beginner in programming in C# and WPF, and your tutorials really help me out. Could you do a full tutorial of a 2D jump 'n' run sidescroller like Super Mario Bros in WPF?
That would be awesome, because I want to program a Mario fangame in WPF and i don't know how I can make the background follow the charakter, and I have some trouble with the controls of the player + animations

toastedMusic
Автор

One comment on your demos is you should break the flow down into smalle chunkc, and code/run them accordingly.

Ie. Implement the scrolling bckground, then implement the runing animation ...

MartinSparkes-BadDragon
Автор

I got it working, I deleted the images folder and added the images again, this time I extracted them from the zip file, my fault.
thanks

johnniegilkerson
Автор

hi, bro! how can i make such sprites like you did if i have 1 image with all animations(just like you, but with another character)? I mean, how to split up my imgs? would be too grateful for answer!

ВаняГрицай-цб
Автор

i wish you explained what you are doing a little better. why are we doing 3 commas in the URI path? other than that great tutorial

jordanedwards
Автор

for Example when i wanna to do hier a Load and save Buttons goes that in this game
?

osamaalnafouri
Автор

When i press space he doesnt jump help!!! Can it keeps stuttering how do i fix that too?

averagekilo
Автор

line 64
backgroundSprite.ImageSource = new BitmapImage(new
throws an error
System.NotSupportedException: 'The URI prefix is not recognized

johnniegilkerson
Автор

So im having some trouble with the program finding the images from the images folder(10:47). Im getting an exeption that i dont know how to deal with How do i fix this?

mt_sim
Автор

At around the 17 minute mark you create an 8 case switch statement for your animation. This is unnecessary. Instead you should just concatenate your uri string to i.

SteelNight
Автор

I love your content, it's great, but your website is painful. The source code page for this tutorial is completely covered in google ads. They cover 20% of the code.

TheFeralEngineer
Автор

nice video, can u make platform game like super mario...?

BalkanLeaksArchive
Автор

thanks for answering, but
backgroundSprite.ImageSource = new BitmapImage(new Uri("pack://application:, , , /images/background.gif"));
still throws System.IO.IOException: 'Cannot locate resource 'images/background.gif'.'
My images are under the solution Runner, I called it that.

johnniegilkerson
Автор

Understand yourself this size of text can be visible if i would be watching this video with teliscope

hey-efwv
Автор

Why my character is not running and how to fix the unreachable code detected?

it.jamesxyz
visit shbcf.ru