*Source code* If you don't want to write the code yourself, it's available here for 3$ (and free for Patreon supporters): www.patreon.com/OttoBotCode/shop/78691 Your support would be a massive help for me and my channel! 🤩
@@norbertabone9157 That's a shame. It works just fine on my end. Could you try again and see if it works now? Alternatively, try to go straight to www.patreon.com/OttoBotCode. You can find the Tetris code in the shop 😊
Very good for showing a completed project! Can't say many have ever actually shown a project as finished, or even so much as _declared_ their project as finished. So that gets bonus points! Kudos, bro.
Bro I can't stress this enough : if you keep making C++ , C# tutorials your channel is going to skyrocket ,and hold on hold on before you say that people are more into py and js now yeah yeah I’ve done it all ppl in the comments have done it all, BUT because C# and C++ tutorials are FREAKING rare . I figured that learning the universal concepts and principles of programming languages and their special features are best served with a pinch of tutorials before you go out there and create your own apps. It can be very frustrating just sitting there and creating stuff without seeing how to make them in the first place. You are freaking life savior with this I swear to God. PLEASE make more videos !!!n
Thanks, I hear you. There will be more videos, this is just the beginning! At the moment, it's hard for me to find time for my videos, but that will change in 2 months time 😉
@@OttoBotCode For real this is one of the best tutorial video's I've ever seen in my programming career love to see a new big channel at it's early stages of growing! I will do my best to share this content with everyone I know that loves this! I hope the best for you and wishes your channel a great growth in the near future :)
Otto, this tutorial helped me a lot. Thank you for a clear and simple explanation. Keep making such amazing and interesting videos. Well done and good luck
I'm a beginner at C# and unfortunately this is very hard for me to follow for some reason. Something about the explanations don't "click" with me. Maybe I'll try it again at a future time. Appreciate all the hard work you put in it though and the fact that you answer all your comments. Much respect.
For a beginner, this is too hard. It's more helpful for people who know properties, inheritance, basic collections, etc. If you know such things, following a tutorial like this one can help you get to the next level. I don't speed up the typing like I did for this video anymore, that's probably another reason why it's a bit hard to follow. Once you get more familiar with C# and you want to create a small project, definetely come back here (or perhaps check out my Snake tutorial) and give that a try. Thanks for your comment! 😊
This is one of the best programming videos I've seen. Everything very well explained but simple at same time. Btw loved the edit too. Keep up the amazing work! Thank youu!!
Master... thank you very much for the quality of your content. It is a great contribution to make the knowledge available to everyone. Someday i want to be like you.
Well, I'm still in the 'learning to code phase' but I just finished my first iteration of Tetris which I coded with JavaScript. Wow, at a certain point I thought I was going to lose my mind because I ran into so many issues, but somehow it's 95% finished now. So, seeing your vid thumbnail, I thought I'd come and learn something. My code is about 4 times the size of yours. I've got a thing or two to learn as yet. It's fascinating to see how you handled the dropping of non-full rows after clearing 'x' amount of rows. That whole process gave me massive headaches.
thank you for showing the complete guide from programming to developing and testing everything in real world. it helps me a lot to understand the various use of method and functions too ..keep it up.. one subscriber ..
Thanks for making this video. I believe it is the best way to learn how to transform theory into true code. You have been very clear and I would not be able to do many things.
I have problem here the block it doesn't move. When I press the keys for rotating is ok but when I press right, left and down button it doesn't move please help me 29:07
This is amazing. How did you learn to program, so simple yet so efficiently? It's like you are so perfect at this, when I program I just go with the flow, and although I would love my code to be as flexible and simple as yours, it never turns out like this. You are extremely talented, thanks for this amazing tutorial.
Thank you so much for the kind words! When I program, I try my best to write clean and efficient code that's as easy to understand as possible. I have a masters degree in computer science, which is where I have a lot of my knowledge from. My coding style comes from a lot of hard work and passion for the field! 😊
I get an error in IBlock at 11:15. Apparently I'm using an older version which doesn't support the notation "new(0,1)". Do you know of a way I can rewrite this so that it works?
You are right, I have omitted the type after "new" which you can only do in C# 9 or later. For older versions you have to always write the type explicitly like this: new Position(r,c) Hope that helps! 😃
@@OttoBotCodeI kept wanting to reach through the screen and rewrite your code to use the new C#11 collection initializers and then I realized this was 2 years old. 😂 Great video! Subscribed.
Hello I have an issue in where the next block and hold block won't show up properly, I can't seem to figure it out, im not getting any errors just the images won''t load.
The most common error is forgetting to mark the images as resources. Right click on them in the solution explorer, click Properties and set Build Action to Resource.
I hope i get an answer after all the time :D The .Reset(); method at 14:38 is red underlined because its not defined and either am blind or you didn't shown it. What to write in it if i create the method?
'MainWindow' does not contain a definition for 'Window_KeyDown' and no accessible extension method 'Window_KeyDown' accepting a first argument of type 'MainWindow' could be found (are you missing a using directive or an assembly reference?)😣
Heya, I have an error on the MainWindow.xaml.cs section. On the Draw method, "DrawGrid(gameState.GameGrid);", the gameGrid section has an error for not containing a definition for GameGrid and GameGrid argument type cannot be found. Same for the CurrentBlock part. Can you please help me?
This tutorial is great, but for some reason I couldn't get the game to run fully. While debugging, the game goes to GameOver state after a split second. After pressing "PlayAgine" it is the same. VisualStudio shows no errors.
Hi, maybe some could help me out. At #29:10 when he start up the program everythik goes well. When i trying to start it up it doesnt show any block and program crush down. Thanks for any help.
i would like to ask question @3:05 does declaring /*Rows=rows; /*is the same as */ this.Rows=rows; /*Columns=columns; /*is the same as */ this.Columns=colums; what does that imply?.. is that mean the class can only have one instance or object?
In this case *Rows = rows* and *Columns = columns* is the same as *this.Rows = rows* and *this.Columns = columns* *this* just refers to the current instance of the class. In the case above you don't have to add it explicitly but it is sometimes necessary. If the parameters in the constructor were also called *Rows* and *Columns* then we would have to do this: *this.Rows = Rows* and *this.Columns = Columns*. It does not imply that you can only create one instance of the class. We don't need it but you could create multiple instances of GameGrid. I hope this helps 😊
Very cool game, it was fun to make at times, other times it was a pain in the back because of the errors I got, but overall, I got'em fixed and the game itself is pretty well done. Thank you for the experience
One more thing: at 19:40 it says that KeyDown="Window_KeyDown"> is an error because it can be declared only on the left side of += or -= I'm using Visual Studio 2022
I have a problem with abstract position. It tells me "Functional inconsistency: property type "Position[][]" is less accessible than property "Block.Tiles"". What did I do wrong?
I would guess that your Position class is "internal" or "private". Make sure the Position class is "public". Inside Position.cs, the code should be: public class Position 😀
I have a question. What should i do if i want to tetris 3d? How should i set the positions and change 'Block' class? I am not sure honestly how many position state.
Thanks for buying the code. You should unzip the compressed file first and then open Tetris.sln with Visual Studio. Once opened, you can start the game by clicking the run button (green arrow) or pressing CTRL + F5. If that does not work, let me know what kind of error message you get! ☺
Hello! I am having some trouble with the game after play again is clicked. The DropBlock method is not being invoked but all the other buttons work. When I do the dropblock method, the game speed up. Any ideas? Thank you!
Good afternoon! I have a problem in the code. I am writing on Visual stusio 2017. Everything is clearly written in code, but the O-block is not displayed. It is displayed transparent on the playing field, although it is displayed in the HOLD and NEXT fields.
The hold and next fields display the Block-O.png image. On the playing field, an O-block is displayed using four instances of TileYellow.png. I suspect that Tile-Yellow.png is not loaded correctly in your project. Make sure that Tile-Yellow.png has build action set to "Resource" and double check that you have written the filename correctly in MainWindow.xaml.cs. Let me know if this resolves the issue! 😊
Can I make the same project using the .NET Framework? And if so, then what can be the changes made? Thank You for this video, going to make this for my college project!❤❤
I think I may be able to help. The "!" in coding means "not". So (!BlockFits) means (Not BlockFits). So that snippet of code basically means "If the block does not fit, rotate back". Btw i am assuming you have limited knowledge of coding. (Like me). Thinking of it like this when I started helped and i hope it helps you too.😊
First off fantastic video. Secondly I see there's code so that the same block cannot be called twice in a row. What would be the best way to make this happen call all 7 blocks before repeating the same block?
@@OttoBotCode Is it possible to add tetris song to this app? I know how to do it in Windows Forms app, but here the same code doesn't work :sob: I added the mp3 file to the Assets folder and changed the Build Action to Resource as for the images, but what do I do next? Thank you so much for your assistance. :hugging_face:
@@elenatrifonova5286 For the mp3 file. You have to set "Build Action" to "Content" and "Copy to Output Directory" to "Copy always". You can play the sound with the MediaPlayer class. MediaPlayer player = new MediaPlayer(); player.Open(new Uri("Assets/your_sound.mp3", UriKind.Relative)); player.Play();
@@OttoBotCode great thank you, ill try to convert it any particular advice on what i could do? also great video btw i like how each function ,method and class is explained very helpful
It's hard for me to guess what the issue is. The source code for the project is available here for 3$: www.patreon.com/OttoBotCode/shop. If that doesn't help you locate the mistake, then I can take a look at your project 😊
I'm up to GameStateBlock and I'm a little concerned as I have several underlined code words in this block (like GameState and BlockFits) and others that you do not. I've followed you perfectly down to the exact line number on every block....... I'm using VS 17.9.3 ease my mind please?? thanks
My guess would be that the warnings disappear if you disable the "nullable" feature under project settings. It is a newer feature which is now enabled by default when you create a project. Its purpose is to help you avoid null reference exceptions by imposing additional constraints on your code. I did not follow these constraints. Don't worry about those warnings, the code will work just fine! For this project, I recommend disabling nullable under project settings. That should get rid of those annoying warnings! Best of luck with the tutorial 😊
I am trying to learn from this video and i keep running into the same problem in the Block.cs class When i create the constructor i get an error saying this: 'Position[][]' does not contain a definition for 'Row' and no accessible extension method 'Row' accepting a first argument of type 'Position[][]' could be found (are you missing a using directive or an assembly reference?) Same error goes for Column. I have tried your your git project and i get same error.
hi OttoBotCode i need help with the protected abstrasct tiles and start offset the Error is: incosistent accesbilitiy property Type 'Position' is less accesible than Blockscs.Startoffset: the 2 error is: incosistent accesbilitiy property Type 'Position' is less accesible than Blockscs.Tiles
First, thanks for the tutorial. I have an Issue that is only one tetrominos spawns I can move him around and place but after that they spawn no one more
Im having an issue where no blocks will spawn for like 20 seconds and then when it finally does theres a invisible layer a few squares above the current blocks, any idea of what it could be?
I can't get the keys to work, I can't find anything I haven't followed perfectly as I re watch the video. The only thing that sticks out is I have a "Non-nullable field 'currentBlock' must contain a non-null value when exiting the constructor....." So I'm not sure if that has anything to do with it.
Does nothing happen when you press the arrow keys? Try setting a breakpoint in Window_KeyDown and then run the program in Debug mode. Then let me know if that breakpoint is hit when you press the arrow keys.
@@OttoBotCode tried that. And that is about the extent of my knowledge with debugging using visual studio features. And it did not trigger the breakpoint.
@@chadgessner4412 Okay so it seems like the event handler is not registered. I think the problem is in MainWindow.xaml. Do you have this property "KeyDown="Window_KeyDown" on the Window?
@@OttoBotCode I may have found something useful... My Window_KeyDown shows '0 references' above it, but yours shows 1. Maybe I missed a line of code somewhere?
I am glad that it helped you. Many games are easiest to implement using some kind of grid. Unfortunately, I am not familiar with dr.Mario, but best of luck with your project 😀
SetupGameCanvas populates a Canvas with Image controls, one for each cell in the GameGrid. If there is nothing in a given a cell (gameGrid[r, c] == 0), the source of the corresponding image is set to "Assets/TileEmpty.png". This image is just a dark gray border, with a transparent fill color. To give the cells a different color use one of these options: 1) Change the background color of the Canvas in the xaml code. 2) Change the TileEmpty.png image (this way will also allow you to change the color of the grid lines)
@@OttoBotCode Thank you very much , I understood . I have one more question that is the id variable in the Drawgrid method, it will always default to 0 right?
@@NguyenMinh-th2li The "IDs" are stored in an int array in the GameGrid class. The default value for int is 0. So yes, initially all IDs will be 0 by default.
1>C:\Users\johnn\source epos\tetris\tetris\MainWindow.xaml.cs(116,23,116,26): error CS1061: 'KeyboardEventArgs' does not contain a definition for 'Key' and no accessible extension method 'Key' accepting a first argument of type 'KeyboardEventArgs' could be found (are you missing a using directive or an assembly reference?)
Sorry for the (very) late reply. Is it complaining in the event handler for the KeyDown event? If you are interested, you can send your project to ottobotcodehelp@gmail.com. I'll take a look and figure out the problem for you 😊
@@OttoBotCode GameState does not contain a definition for MoveBlockLeft and accesible extension method MoveBlockLeft accepting a first arguement of type GameState could be found (are you missing a using directly or an assembly reference?)
@@frejandsubtolclc7935 Something is wrong with your MoveBlockLeft method. I would guess that you've made it private instead of public - that is why GameState cannot see it.
finished writing the code but when i try to run it it says "invalid URI: the format of the URI could not be determined" anyone else ran into the same problem?
changed the images' code from UriKind.Relative to UriKind.RelativeOrAbsolute then changed it back and I'm able to run the code without getting an error? lol, but now the images on the grid and grid lines are invisible :/
Thanks for buying the code. The issue probably has something to do with your Visual Studio setup. What errors do you get? If you prefer, you can also contact me at ottobotcodehelp@gmail.com 😊
You don't need to make it public, that's just how I was taught programming. Using "abstract" does make a lot of sense because we don't want the Block class to be instantiated directly (only the subclasses).
I also want to ask about how can you think about what function to create and how would you create it.. for example create a basic function that can be called later inside another function .. how do you think about it? Does this comes from experience and you just instinctively create all the functions in one go? is there a mathematics that can help us create the desired function? Does math function is really important in programming? for example a composite function is that necessary to learn for programming.. i honestly dont know what function to create but you just seamlessly code that without any troubles..
What you don't see in the video is the process of planning everything and structured the code to be as easy to understand as possible. There are design principles and standard patterns you can follow to some extent. That being said, there is no substitute for practice. With time you will develop a feel for what "good" code and "bad" code is. How important is math? That really depends on what you want to do. For most projects it's not so important in my opinion. It's more important to think logically and keep the code as simple as possible. BUT the really impressive programs like ray tracers, machine learning algorithms and game engines require a lot of math! 😉
Hey bro, Finished the tutorial but the O block keeps spawning as every other block and all but the 0 block are cyan. Any idea what I might have done? The BitMapImages look correct for colors. Not even sure where to look for the logic that keeps spawning the O block though.
Sorry for the late reply. If you are interested I can help you out. Send your entire project to me at ottobotcodehelp@gmail.com (zip or github link). I'll figure out what the problem is for you 😉
Hello! What a great video! I haven't made the project yet but have a quick question, I notice that you use individual tile pictures to make a whole block, can I use the entire png of the block instead of using this method? I wish to make my own fun spin on Tetris with a different style to the blocks, maybe something like animals! Thanks!
It is possible but you would have to change the code to display your blocks correctly. Also keep in mind that your blocks will be chopped up when the player clears a row.
It sounds like the assets are not loaded correctly. Double check that you have spelled the file names correctly and that they are all marked as "Resource" 😊
Did you figure it out? I'm having the same problem. Thanks in advance.😊 I am using Dotnet 6 and cannot get Visual Studio, do I'm using Notepad++ to write the code, and Command Prompt to compile.
Schweregrad Code Beschreibung Projekt Datei Zeile Unterdrückungszustand Fehler CS1061 "MainWindow" enthält keine Definition für "GameCanvas_Loaded", und es konnte keine zugängliche GameCanvas_Loaded-Erweiterungsmethode gefunden werden, die ein erstes Argument vom Typ "MainWindow" akzeptiert (möglicherweise fehlt eine using-Direktive oder ein Assemblyverweis). Tetris C:\Users\TN\source epos\Tetris\Tetris\MainWindow.xaml 40 Aktiv
Hey, where you learned programming like that? Any Books or only tutorials from yt, maybe some studies(I ask out of curiosity). About same game, this is really simple explain and coding, good work.
Hello! I have a bachelor's degree in "Software Development" and a master's degree in "Computer Science" 😊 Whenever I find something that interests me, I like to try it myself and create some small project 😉 Great that you like this one!
*Source code*
If you don't want to write the code yourself, it's available here for 3$ (and free for Patreon supporters):
www.patreon.com/OttoBotCode/shop/78691
Your support would be a massive help for me and my channel! 🤩
The link seems not to be working
@@norbertabone9157 That's a shame. It works just fine on my end. Could you try again and see if it works now? Alternatively, try to go straight to www.patreon.com/OttoBotCode. You can find the Tetris code in the shop 😊
Brother do you want sail any project of c#
Bcz i need in emergency
@@OttoBotCodeI see CS0122 Error. I don't know how to fix it. Thanks for advance.
Here's the code:
int dropDistance = gameState.BlockDropDistance();
I love how simple this way of creating Tetris is compared to other examples. Keep up the good work!
Thanks, I appreciate it. More content coming soon😀
@@OttoBotCode What is the name of the data structure u used?
I love how you took the time to talk about designing the application. Much appreciated after browsing other C# videos.
I am glad you liked it, thanks for watching!
Very good for showing a completed project! Can't say many have ever actually shown a project as finished, or even so much as _declared_ their project as finished. So that gets bonus points! Kudos, bro.
Bro I can't stress this enough : if you keep making C++ , C# tutorials your channel is going to skyrocket ,and hold on hold on before you say that people are more into py and js now yeah yeah I’ve done it all ppl in the comments have done it all, BUT because C# and C++ tutorials are FREAKING rare . I figured that learning the universal concepts and principles of programming languages and their special features are best served with a pinch of tutorials before you go out there and create your own apps. It can be very frustrating just sitting there and creating stuff without seeing how to make them in the first place. You are freaking life savior with this I swear to God. PLEASE make more videos !!!n
Thanks, I hear you. There will be more videos, this is just the beginning!
At the moment, it's hard for me to find time for my videos, but that will change in 2 months time 😉
@@OttoBotCode Man all thanks to you sure I can't wait to see more !
this video and channel are SOOO underrated you deserved my sub!
Thank you so much!
@@OttoBotCode For real this is one of the best tutorial video's I've ever seen in my programming career love to see a new big channel at it's early stages of growing! I will do my best to share this content with everyone I know that loves this!
I hope the best for you and wishes your channel a great growth in the near future :)
@@TeamROsky Awesome to hear. It is greatly appreciated, much more content coming soon!
@@OttoBotCode My teacher has send the other classes towards your video so they can do this as a task! Never expected that to happen but here you go :)
@@TeamROsky Wow super cool! Thanks again :)
I'm from Belarus, studying at university and starting to make games. Your tutorial was very helpful, the code is very beautiful. Thank you ♥♥♥
Thank you! I'm glad you like it 👍
Very clean! Don't know how i stumbled upon this video, but well done :)
Otto, this tutorial helped me a lot. Thank you for a clear and simple explanation. Keep making such amazing and interesting videos. Well done and good luck
Thank you, that's great to hear! I'm working on the next project (also in C#) 😉
why is this channel so underrated????
I'm a beginner at C# and unfortunately this is very hard for me to follow for some reason. Something about the explanations don't "click" with me. Maybe I'll try it again at a future time. Appreciate all the hard work you put in it though and the fact that you answer all your comments. Much respect.
For a beginner, this is too hard. It's more helpful for people who know properties, inheritance, basic collections, etc. If you know such things, following a tutorial like this one can help you get to the next level. I don't speed up the typing like I did for this video anymore, that's probably another reason why it's a bit hard to follow.
Once you get more familiar with C# and you want to create a small project, definetely come back here (or perhaps check out my Snake tutorial) and give that a try.
Thanks for your comment! 😊
the implementation is more math than code, hes good at explaining what each method does ur just not listening
@@BeenYT He said it himself that this is too hard for beginner. I guess "ur" just not reading...
@@BeenYTBro is not reading💀
Really appreciate it!!!!
This is one of the best programming videos I've seen. Everything very well explained but simple at same time. Btw loved the edit too. Keep up the amazing work! Thank youu!!
Thank you! Awesome to hear 😃
This would be my weekend challenge for this Saturday. Thanks for the great tutorial!
Thank you! 😃
Master... thank you very much for the quality of your content. It is a great contribution to make the knowledge available to everyone. Someday i want to be like you.
Glad you enjoyed it and thanks for the kind words!
Well, I'm still in the 'learning to code phase' but I just finished my first iteration of Tetris which I coded with JavaScript. Wow, at a certain point I thought I was going to lose my mind because I ran into so many issues, but somehow it's 95% finished now. So, seeing your vid thumbnail, I thought I'd come and learn something. My code is about 4 times the size of yours. I've got a thing or two to learn as yet. It's fascinating to see how you handled the dropping of non-full rows after clearing 'x' amount of rows. That whole process gave me massive headaches.
Good luck with finishing your project. I'm glad this video was helpful 😊
thank you for showing the complete guide from programming to developing and testing everything in real world.
it helps me a lot to understand the various use of method and functions too ..keep it up..
one subscriber ..
Thanks for making this video. I believe it is the best way to learn how to transform theory into true code. You have been very clear and I would not be able to do many things.
Thank you for watching. Glad it was helpful
I have problem here the block it doesn't move. When I press the keys for rotating is ok but when I press right, left and down button it doesn't move please help me 29:07
27:58 I'm getting 2 errors under the TilePositions and under the Id in [block.Id]. Both the error codes are CS1061
This is amazing. How did you learn to program, so simple yet so efficiently? It's like you are so perfect at this, when I program I just go with the flow, and although I would love my code to be as flexible and simple as yours, it never turns out like this.
You are extremely talented, thanks for this amazing tutorial.
Thank you so much for the kind words! When I program, I try my best to write clean and efficient code that's as easy to understand as possible. I have a masters degree in computer science, which is where I have a lot of my knowledge from. My coding style comes from a lot of hard work and passion for the field! 😊
Very clear and good explanation, good animations and entertaining, helped me a lot :) Well done:)
Thank you so much, really glad you like it!
Very good explanations, it helped me a lot in learning object oriented programming in C#. thanks a lot!!! :-)
Thanks for your comment 😊
I get an error in IBlock at 11:15. Apparently I'm using an older version which doesn't support the notation "new(0,1)". Do you know of a way I can rewrite this so that it works?
You are right, I have omitted the type after "new" which you can only do in C# 9 or later. For older versions you have to always write the type explicitly like this:
new Position(r,c)
Hope that helps! 😃
@@OttoBotCode This resolved my problem, thank you very much!
This is a super cool tutorial, thanks!
@@OttoBotCodeI kept wanting to reach through the screen and rewrite your code to use the new C#11 collection initializers and then I realized this was 2 years old. 😂
Great video! Subscribed.
Hey, I need help at 29:30 I can't get the row to clear is something wrong with it?
I'm surprised you have less than 700 subs! This is great content, keep up the great work
Thank you for the kind words. More content coming soon 😊
Hello I have an issue in where the next block and hold block won't show up properly, I can't seem to figure it out, im not getting any errors just the images won''t load.
The most common error is forgetting to mark the images as resources. Right click on them in the solution explorer, click Properties and set Build Action to Resource.
Great video!! the idea flow is simple and easy to understand
I hope i get an answer after all the time :D
The .Reset(); method at 14:38 is red underlined because its not defined and either am blind or you didn't shown it.
What to write in it if i create the method?
It's around 10:45
'MainWindow' does not contain a definition for 'Window_KeyDown' and no accessible extension method 'Window_KeyDown' accepting a first argument of type 'MainWindow' could be found (are you missing a using directive or an assembly reference?)😣
I also want to know this. Gem comment
Heya, I have an error on the MainWindow.xaml.cs section. On the Draw method, "DrawGrid(gameState.GameGrid);", the gameGrid section has an error for not containing a definition for GameGrid and GameGrid argument type cannot be found. Same for the CurrentBlock part.
Can you please help me?
Maybe you forgot to make those properties public inside the GameState class?
This tutorial is great, but for some reason I couldn't get the game to run fully. While debugging, the game goes to GameOver state after a split second. After pressing "PlayAgine" it is the same. VisualStudio shows no errors.
el Id del bloque I Me esta marcando error y lo tengo igual al del minuto 11:28
Hi, maybe some could help me out. At #29:10 when he start up the program everythik goes well. When i trying to start it up it doesnt show any block and program crush down. Thanks for any help.
Do you get any error message in the output window?
Untreated exception
System.IndexOutOfRangeException: Index was outside the bounds of the array.@@OttoBotCode
System.IndexOutOfRangeException: Index was outside the bounds of the array.
@@OttoBotCode
Thanks mate, this helped me a lot!
i would like to ask question @3:05
does declaring
/*Rows=rows; /*is the same as */ this.Rows=rows;
/*Columns=columns; /*is the same as */ this.Columns=colums;
what does that imply?..
is that mean the class can only have one instance or object?
In this case
*Rows = rows* and *Columns = columns*
is the same as
*this.Rows = rows* and *this.Columns = columns*
*this* just refers to the current instance of the class.
In the case above you don't have to add it explicitly but it is sometimes necessary.
If the parameters in the constructor were also called *Rows* and *Columns* then we would have to do this:
*this.Rows = Rows* and *this.Columns = Columns*.
It does not imply that you can only create one instance of the class. We don't need it but you could create multiple instances of GameGrid.
I hope this helps 😊
Very cool game, it was fun to make at times, other times it was a pain in the back because of the errors I got, but overall, I got'em fixed and the game itself is pretty well done.
Thank you for the experience
Glad to hear you worked out in the end. Thanks for your comment!
Hey, I need a little help: at 14:31 the computer gives me a warning on "currentBlock". Could you explain me why, please?
What does the warning say?
@@OttoBotCode it says that "currentBlock" can't contain a Null value in the output, because it isn't nullable
One more thing: at 19:40 it says that KeyDown="Window_KeyDown"> is an error because it can be declared only on the left side of += or -=
I'm using Visual Studio 2022
Hello, i get an error 14:55 . When i try to write public GameState(). Can you help me please
What does the error message say?
@@OttoBotCode Actually, i solved that problem. But now i get a debug problem. It says debug does not exist.
I have a problem with abstract position. It tells me "Functional inconsistency: property type "Position[][]" is less accessible than property "Block.Tiles"". What did I do wrong?
I would guess that your Position class is "internal" or "private" instead of "public". Go to Position.cs and make sure it says "public class Position"
@@OttoBotCode Thank you very much for your help
Great tutorial Otto, this is a feature-rich game.
Thanks!
Hello! Where can I found the images with blocks and backround image? It is on google?
There is a link in the description
at what moment does the Hold appear on the screen, that is, when this event occurs
Inconsistent accessibility: property type 'Position[][]' is less accessible than property 'Block.Tiles'?
I would guess that your Position class is "internal" or "private". Make sure the Position class is "public". Inside Position.cs, the code should be: public class Position 😀
@@OttoBotCode Thank you very much!
I have a question. What should i do if i want to tetris 3d? How should i set the positions and change 'Block' class? I am not sure honestly how many position state.
what throws off is the step sequencer. i ntally associate it with a soft/clip whether it's being used or not. also when you do
This is awesome. Thank you so much and greetings from Argentina
Thanks for your comment and greetings from Denmark 😉
Bro.. which server is used to stord a data? Cloud & database 🤷♂️
hi there, purchased the code and followed the tutorial, cant figure out how to run the game. please help
Thanks for buying the code. You should unzip the compressed file first and then open Tetris.sln with Visual Studio. Once opened, you can start the game by clicking the run button (green arrow) or pressing CTRL + F5. If that does not work, let me know what kind of error message you get! ☺
It's my first day of soft School, and I can tell I'm going to like my teacher!
Hello!
I am having some trouble with the game after play again is clicked. The DropBlock method is not being invoked but all the other buttons work. When I do the dropblock method, the game speed up.
Any ideas?
Thank you!
Good afternoon! I have a problem in the code. I am writing on Visual stusio 2017. Everything is clearly written in code, but the O-block is not displayed. It is displayed transparent on the playing field, although it is displayed in the HOLD and NEXT fields.
The hold and next fields display the Block-O.png image. On the playing field, an O-block is displayed using four instances of TileYellow.png. I suspect that Tile-Yellow.png is not loaded correctly in your project.
Make sure that Tile-Yellow.png has build action set to "Resource" and double check that you have written the filename correctly in MainWindow.xaml.cs.
Let me know if this resolves the issue! 😊
Can I make the same project using the .NET Framework? And if so, then what can be the changes made? Thank You for this video, going to make this for my college project!❤❤
Great video. It was easy to follow and understand.
can someone explain at 16:00 !BlockFits then ccw, i think BlockFits then ccw
I think I may be able to help. The "!" in coding means "not".
So (!BlockFits) means (Not BlockFits). So that snippet of code basically means "If the block does not fit, rotate back".
Btw i am assuming you have limited knowledge of coding. (Like me). Thinking of it like this when I started helped and i hope it helps you too.😊
@@genericname6753 i mean that is cw function, so it operates rotate cw. if block doesn't fit, why would we make block rotate ccw
Seriously well done and thank you for this.
First off fantastic video.
Secondly I see there's code so that the same block cannot be called twice in a row.
What would be the best way to make this happen call all 7 blocks before repeating the same block?
I've seen that has actually explained it to in a concise way!
I wrote the code as in the video, but for some reason cells and blocks are not drawn in my Canvas
ok, i I tried manually inserting the green cell image, but when i start app, my canvas is empty
@@akainktsn It's probably not an issue with your code then. Make sure that your assets have "Build Action" set to "Resource"
I can’t drag content / sample into my playlist on Mac? Anyone know how to fix
i have only one simple question how tiles and StartOffSet even appears here because i got Error
uh i didn't see public class prob solved
OMG! You are a life saver. Thanks you for clear description of every step of the way; amazing content! Good luck!!!!
You're welcome 😀
@@OttoBotCode Is it possible to add tetris song to this app? I know how to do it in Windows Forms app, but here the same code doesn't work :sob: I added the mp3 file to the Assets folder and changed the Build Action to Resource as for the images, but what do I do next? Thank you so much for your assistance. :hugging_face:
@@elenatrifonova5286 For the mp3 file. You have to set "Build Action" to "Content" and "Copy to Output Directory" to "Copy always".
You can play the sound with the MediaPlayer class.
MediaPlayer player = new MediaPlayer();
player.Open(new Uri("Assets/your_sound.mp3", UriKind.Relative));
player.Play();
@@OttoBotCode Super Mega LIKE to you, my friend! It can sing now :grin:
would parts of this code would you be able to use it in the windows forms c# or would you have to change some of it?
You don't have to change any of the actual Tetris logic. All you have to do is rewrite the UI (the code in MainWindow.xaml and MainWindow.xaml.cs).
@@OttoBotCode great thank you, ill try to convert it any particular advice on what i could do? also great video btw i like how each function ,method and class is explained very helpful
Hi, I have used the code exactly how you have but the blocks won't move down I was wondering if you knew why this would be?
It's hard for me to guess what the issue is.
The source code for the project is available here for 3$:
www.patreon.com/OttoBotCode/shop.
If that doesn't help you locate the mistake, then I can take a look at your project 😊
I'm up to GameStateBlock and I'm a little concerned as I have several underlined code words in this block (like GameState and BlockFits) and others that you do not. I've followed you perfectly down to the exact line number on every block....... I'm using VS 17.9.3 ease my mind please?? thanks
My guess would be that the warnings disappear if you disable the "nullable" feature under project settings.
It is a newer feature which is now enabled by default when you create a project. Its purpose is to help you avoid null reference exceptions by imposing additional constraints on your code. I did not follow these constraints.
Don't worry about those warnings, the code will work just fine! For this project, I recommend disabling nullable under project settings. That should get rid of those annoying warnings!
Best of luck with the tutorial 😊
I am trying to learn from this video and i keep running into the same problem in the Block.cs class
When i create the constructor i get an error saying this:
'Position[][]' does not contain a definition for 'Row' and no accessible extension method 'Row' accepting a first argument of type 'Position[][]' could be found (are you missing a using directive or an assembly reference?)
Same error goes for Column.
I have tried your your git project and i get same error.
Can you send the project with the error to ottobotcodehelp@gmail.com? Then I'll figure out what is wrong 😉
How did you select all the assets at 18:50
I click on the first one, hold down shift, and click on the bottom one 😀
So simple and clear! I like it
Also I noticed how your clead code improves mine, and it feels is amazing! Thank you
Great to hear! Thanks for your comment 👍
amazing video, do you consider this project as a beginner or intermediate project
Thanks! I'd say this is an intermediate project but on the easy side 😉
Brandony man pls i need to know how can I restore the snare and the hat in the channel rack, I accidentally deleted them.
are there any other function besides "Children"? cuz im using visual studio 2019
hi OttoBotCode i need help with the protected abstrasct tiles and start offset the Error is: incosistent accesbilitiy property Type 'Position' is less accesible than Blockscs.Startoffset: the 2 error is: incosistent accesbilitiy property Type 'Position' is less accesible than Blockscs.Tiles
It sounds like your Position class is either "internal" or "private". Go to Position.cs and make the class "public" 😊
First, thanks for the tutorial. I have an Issue that is only one tetrominos spawns I can move him around and place but after that they spawn no one more
Im having an issue where no blocks will spawn for like 20 seconds and then when it finally does theres a invisible layer a few squares above the current blocks, any idea of what it could be?
I can find out if you send me your code. You can send it to ottobotcodehelp@gmail.com, then I'll take a look 😊
I can't get the keys to work, I can't find anything I haven't followed perfectly as I re watch the video. The only thing that sticks out is I have a "Non-nullable field 'currentBlock' must contain a non-null value when exiting the constructor....." So I'm not sure if that has anything to do with it.
Does nothing happen when you press the arrow keys?
Try setting a breakpoint in Window_KeyDown and then run the program in Debug mode. Then let me know if that breakpoint is hit when you press the arrow keys.
@@OttoBotCode tried that. And that is about the extent of my knowledge with debugging using visual studio features. And it did not trigger the breakpoint.
@@chadgessner4412 Okay so it seems like the event handler is not registered. I think the problem is in MainWindow.xaml. Do you have this property
"KeyDown="Window_KeyDown" on the Window?
@@OttoBotCode I may have found something useful... My Window_KeyDown shows '0 references' above it, but yours shows 1. Maybe I missed a line of code somewhere?
@@OttoBotCode yes that was the problem. Thanks!
I’m trying to make dr.Mario and using the grid really helped. How would you go about making things fall in dr.Mario?
I am glad that it helped you. Many games are easiest to implement using some kind of grid. Unfortunately, I am not familiar with dr.Mario, but best of luck with your project 😀
@@OttoBotCode thank you!
i want to know about grid ,but i dont know how to set position becase all position is 0 all omg my head.
Hey:)
I can´t find the draw method at 28:09
Hi! Are you getting some sort of error? The draw method is one we write ourselves at 27:54
Hey , I want to ask you something, how to apply color to cells in grid, canvas? why is your loop giving an empty color grid ?
SetupGameCanvas populates a Canvas with Image controls, one for each cell in the GameGrid. If there is nothing in a given a cell (gameGrid[r, c] == 0), the source of the corresponding image is set to "Assets/TileEmpty.png". This image is just a dark gray border, with a transparent fill color.
To give the cells a different color use one of these options:
1) Change the background color of the Canvas in the xaml code.
2) Change the TileEmpty.png image (this way will also allow you to change the color of the grid lines)
@@OttoBotCode Thank you very much , I understood . I have one more question that is the id variable in the Drawgrid method, it will always default to 0 right?
@@NguyenMinh-th2li The "IDs" are stored in an int array in the GameGrid class. The default value for int is 0. So yes, initially all IDs will be 0 by default.
@@OttoBotCode Thank you, I got it. Your project is very good to learn 😃😃
Hello please i need a Tetris game template. How much should i pag to Support developer?
What exactly are you looking for?
1>C:\Users\johnn\source
epos\tetris\tetris\MainWindow.xaml.cs(116,23,116,26): error CS1061: 'KeyboardEventArgs' does not contain a definition for 'Key' and no accessible extension method 'Key' accepting a first argument of type 'KeyboardEventArgs' could be found (are you missing a using directive or an assembly reference?)
Sorry for the (very) late reply.
Is it complaining in the event handler for the KeyDown event?
If you are interested, you can send your project to ottobotcodehelp@gmail.com.
I'll take a look and figure out the problem for you 😊
Is there an external interface code for this game?
hi otto i have a problem with case key.left i cant use MoveblockLeft(); pls help ty
What error message do you get?
@@OttoBotCode GameState does not contain a definition for MoveBlockLeft and accesible extension method MoveBlockLeft accepting a first arguement of type GameState could be found (are you missing a using directly or an assembly reference?)
@@frejandsubtolclc7935 Something is wrong with your MoveBlockLeft method. I would guess that you've made it private instead of public - that is why GameState cannot see it.
@@OttoBotCode i dont have MoveBlockLeft method idk what to write or smth
finished writing the code but when i try to run it it says "invalid URI: the format of the URI could not be determined" anyone else ran into the same problem?
changed the images' code from UriKind.Relative to UriKind.RelativeOrAbsolute then changed it back and I'm able to run the code without getting an error? lol, but now the images on the grid and grid lines are invisible :/
nvm i fixed it, was missing the add Children line of code inside the SetUpGameCanvas method, now works fine 😎
Great 😊
I bought it, but why isn't it working? I've been doing it for days, but I keep getting errors
Thanks for buying the code. The issue probably has something to do with your Visual Studio setup. What errors do you get? If you prefer, you can also contact me at ottobotcodehelp@gmail.com 😊
CS1061: error KeyboardEventArgs does not contain a definition for "Key"
What type is the second parameter of your Window_KeyDown method? It should be KeyEventArgs.
Incredible video. I have a question, why did u use public abstract classes???
You don't need to make it public, that's just how I was taught programming. Using "abstract" does make a lot of sense because we don't want the Block class to be instantiated directly (only the subclasses).
hi! why is that the part of Hard Drop Feature, in the MainWindow folder when I put - case Key.Space it says error, what will I do?
Sorry for the late reply! Do you still have this error?
@@OttoBotCode yes I have... how can i fix it?
@@nnjaeemx7737 Can you send your project to ottobotcodehelp@gmail.com? It can also be a github link if you prefer. Then I'll take a look at it.
I also want to ask about how can you think about what function to create
and how would you create it..
for example create a basic function that can be called later inside another function ..
how do you think about it?
Does this comes from experience and you just instinctively create all the functions in one go?
is there a mathematics that can help us create the desired function?
Does math function is really important in programming? for example a composite function is that necessary to learn for programming..
i honestly dont know what function to create but you just seamlessly code that without any troubles..
What you don't see in the video is the process of planning everything and structured the code to be as easy to understand as possible.
There are design principles and standard patterns you can follow to some extent. That being said, there is no substitute for practice. With time you will develop a feel for what "good" code and "bad" code is.
How important is math? That really depends on what you want to do. For most projects it's not so important in my opinion. It's more important to think logically and keep the code as simple as possible.
BUT the really impressive programs like ray tracers, machine learning algorithms and game engines require a lot of math! 😉
Hey bro, Finished the tutorial but the O block keeps spawning as every other block and all but the 0 block are cyan. Any idea what I might have done? The BitMapImages look correct for colors. Not even sure where to look for the logic that keeps spawning the O block though.
Sorry for the late reply.
If you are interested I can help you out.
Send your entire project to me at ottobotcodehelp@gmail.com (zip or github link).
I'll figure out what the problem is for you 😉
Hello! What a great video!
I haven't made the project yet but have a quick question, I notice that you use individual tile pictures to make a whole block, can I use the entire png of the block instead of using this method? I wish to make my own fun spin on Tetris with a different style to the blocks, maybe something like animals!
Thanks!
It is possible but you would have to change the code to display your blocks correctly. Also keep in mind that your blocks will be chopped up when the player clears a row.
Hello may I ask why the blocks don't appear when I run the game?
It sounds like the assets are not loaded correctly. Double check that you have spelled the file names correctly and that they are all marked as "Resource" 😊
Yes it is loaded correctly and marked as Resource
Do you have social media that I can talk with? I need help
You can send your entire project to ottobotcodehelp@gmail.com. I'll take a look at it 😉
@@primo7178 Have you solved the problem? I'm experiencing the same difficulties now
DUDE, I got so frustrated 'cause of that problem, thanks a lot!
Sorry found my error: I had private void Window_KeyDown(object sender, KeyboardEventArgs e) instead of Window_KeyDown(object sender, KeyEventArgs e)
I use a mac so I can't WPF file. Any other ways
Hi! I tried writing your code and it seems that i have an invisible shape, can you help me with that? Idk what i did wrong...
Thank you!!
Do you know which shape it is? Is it one of the tiles that make up a block (TileGreen, TileBlue, etc.)? 😊
When I am coding the GameState I get an error (CS8618): Currentblock does not accept NULL values. Could you help me pls?
If you send your entire project (github link is fine) to ottobotcodehelp@gmail.com then I'll take a look when I have time! 😉
Did you figure it out? I'm having the same problem. Thanks in advance.😊
I am using Dotnet 6 and cannot get Visual Studio, do I'm using Notepad++ to write the code, and Command Prompt to compile.
Schweregrad Code Beschreibung Projekt Datei Zeile Unterdrückungszustand
Fehler CS1061 "MainWindow" enthält keine Definition für "GameCanvas_Loaded", und es konnte keine zugängliche GameCanvas_Loaded-Erweiterungsmethode gefunden werden, die ein erstes Argument vom Typ "MainWindow" akzeptiert (möglicherweise fehlt eine using-Direktive oder ein Assemblyverweis). Tetris C:\Users\TN\source
epos\Tetris\Tetris\MainWindow.xaml 40 Aktiv
This tutorial is amazing, i've been trying to expand the game by adding a database to make a register/login feature is there any way you can help??
Hey, where you learned programming like that? Any Books or only tutorials from yt, maybe some studies(I ask out of curiosity).
About same game, this is really simple explain and coding, good work.
Hello! I have a bachelor's degree in "Software Development" and a master's degree in "Computer Science" 😊 Whenever I find something that interests me, I like to try it myself and create some small project 😉 Great that you like this one!