I totally agree about the need to see the results of your work from time to time to maintain interest. Seeing the characters and tile maps implemented even though they are simple really keeps the drive going. This series has been great, thanks for your contribution.
My first steps in SDL I tried to do with LazyFoo tutorial. When I was watching all youtube tutorials I had feeling dat everybody learns from him how to programm with SDL. Is it true in your case ??? Sorry for my english. Its not my native language.
+Joker DDZ yeah, lazy foo was one of the first tutorials I read when I was learning it. The main issue I found with SDL tutorials was the lack of context, so that’s what I’m going for here :)
Exactly ! I had the same problem. I knew how to render some textures, make key input but how to link everything and make game. Dat was main problem and I think u gonna solve this problem. Do what u do . Great job :)
Why didnt I watch your videos when I was making a project for a job interview.....But hands down, best tutorial on SDL and C++ I have seen on RU-vid. Period.
For those who their map isnt rendering. For me, the problem was assigning the values of x y w h to source and destination. I changed it to: rectSource = { 0, 0, 32 ,32 }; rectDestination = { 0, 0, 32 ,32 }; (I changed the variables names) And it worked just fine.
Man these tutorials are great, they are easy to understand. I have to make a game in C for Uni Project with server and client, but i had never used any graphics libraries and these tutorials are the best.
Instead of zeroing the whole array like that you could you something like this: int lvl1[20][25] = { 0 }; or you could use memset() function: memset(lvl1, 0, sizeof(lvl1)); or finally by using dynamic allocation with the help of vectors: vector lvl1(20, vector(25, 0)); Great tutorials regardless. Thank you for these!
@@gari1633 Yeah I actually saw that later! I thought he was gonna use something like a map parser to fetch the tile values instead of manually entering them. Regardless, I decided to leave the comment since it could be helpful for those who don't know these ways!
Also, on a side note I was wondering where did he disappear? I mean, the last video uploaded was 3 yrs ago!! Any idea/news? I really liked his way of explaining things.
im having a problem getting the tiles to render on the map. i have made the water, dirt, and grass tiles and set up the code exactly like you did but for some reason i can not seem to get the tiles to load onto the map. my whole screen is white instead. any idea what i need to look for to fix this?
I reviewed my code multiple times, and it is exactly like yours, yet nothing new happens when I debug. the background is all white. Dunno if I can continue the playlist without completing this lesson first.. Edit: fixed it for me. Make sure you have the "
Hey, I was near quitting the series at video 2. Im working on windows in VS and was confused from using os in your video and had some errors loading SDL_Image. In the end it worked and now im really a fan of your stuff. Its logical, in small steps and really motivating. Thanks for this.
Useful tutorials there where some problems I saw but you seemed to have fixed them in multiple iterations. Its really helped carry me along in learning how to work with the libsdl2 library.
I get a message saying "free(): invalid pointer)" after closing the window, but otherwise the program works perfectly. This seems to point towards memory leak issues. Any tips? Do I need to deallocate the 2D array in the destructor function?
Thank you for your videos ^^ Say, i'm pretty new to C++, but i was wondering, we are using several times some "new", but never some "delete", doesn't it create memory leaks ?
" If you have only one .exe file that uses the allocated memory, the memory will be automatically deallocated when the program terminates, so you may not need to explicitly use delete. "
I'm currently 3 days into learning C++ and this series is awesome, even I can follow along. I have run into a snag here though. I followed each instruction (i watched the video twice to make sure) and when I run the program I still get a white background. I tested each png by replacing player.png and they all work. I made sure to include map->draw(); in the render function in Game.cpp so it's not that either. Basically there is no map and I have no idea why. Help please
Well ik this was made 5 years ago but I've read all the comments and none of them have helped so far and my code as far as i can tell is the same so this is my last ditch effort for a solution. I have used "std::cout" to test each part of my code and make sure all the for loops are running correctly and to verify that my array is being set to 0 and that it is 20 by 25. Yet when i run it the back round is still white. I have made sure that the textures are the right size (i did this by putting their names into the player draw statement and it draws them correctly) So i honestly don't know whats wrong. Any suggestions would be greatly appreciated.
Why are you dynamically allocating (heap allocated) all your game objects like player, and map? I don't see a reason to make them pointers, just create them on the stack
Let's Make Games Yesterday I was watching them from 12AM to 7AM hahaha .. and kinda got stuck on ECS because of the new keywords .. Is instead of using ECS good to use Binary tree??
I've got a problem: When I started with testing the code, It only had loaded the first row. I changed it bit, and now it isn't loading anymore. Can someone help?
can someone explain how games make use of different rooms? for exemple supermetroid? Is the whole world one big tilemap or is every room a single tilemap that gets loaded when you go through a door? If room 1 is a tilemap and room 2 is a tilemap then you would need to map all door transitions in your code? Like door A in room 1 brings you to door A in room 2 en door B in room 1 brings you to door A in room 3? And if it were one big fat tilemap you would only have to change the camera position to a different section of the total map? What is more efficient?
Fry GG I will be in the next tilemap video, I need to do a video on creating the tile set image, then another on loading the various textures from the same atlas by moving the srcRect around the image. I am keeping the implementation simple then as we continue, making the system more robust as we will be loading maps from an external level file
Thanks again for another lesson. I was wondering about if you have any kind of copyright on this code? After I finish this tutorial series I want to make a different kind of game, a playing card game. But I think it would help to base my game on the structure of this game engine.
6 лет назад
Is it possible to get the whole source code? Thank you
It's starting to come together now, my art is bad tho, I'm using the blur tool to cover for the fact that I just don't feel like doing pixelart right now.
I was nearly going insane because i couldnt get this part to work, and them i saw it, i placed a "dest.y" instead of "dest.h", so i was not defining the height of the destination rectangle, no error was given, i even placed some couts in the switch that would tell me what and where something was being placed just to be sure that was working. My worst enemy is my typos and my eyesight, great tutorial.
My water is not rendering, even though I have no errors... If I put my player texture in as "water" it renders that but not the separate water texture I made
Kinda late, but check if your water texture has the same image resolution as your player, if it doesn't then that's the problem 'cause in the gameObject class you have srcRect.h and srcRect.w set to fit your player but not to fit your water, just change the resolution passing it as a parameter and it'll be fine :)
This didn't work quite perfectly for me: SDL_Renderer* Game::renderer = nullptr; ...had Code::Blocks giving me the following: error: 'nullptr' was not declared in this scope After some Stack Overflow'ing, I changed "nullptr" to "0" and got it working just fine. Is 0 an okay substitute?
'nullptr' is a keyword used for pointer initialization in c++11. You probably don't have compiler flag set to c++11. As for your question. Yes, 0 is a good substitiute. By using 0 you are reffering to part of memory with address 0 which is correct. You can use name NULL as well which under the hood is defined like this: #define NULL 0
Well, I was thinking more along the lines of an editor built within the engine. Also, an in game editor has much more potential than just for maps. Say, for an entity that is supposed to walk from one place to another repeatedly, instead of hardcoding that data, you could create within the editor 'path points' for it to follow. Ultimately, this is your series, albeit, as a fan, this is a feature I would love to see you teach. Edit: I now realize you could easily just implement that very feature without the need for an in game editor
The only reason I suggested it is because that software costs, and creating an in game editor would keep your series on a track to cost nothing. Unless, that is, you know of a free software that can edit .csv
+GunnDawg we will be making it full screen in a future episode, and automatically drawing the correct size and scale when we start dealing with moving the character past the screen. Those values were picked as they don’t cover the whole screen as I’m recording (console output) and they divide nicely by 32.
Why does he need to do the double for loop when he loads the map? Like, the input array is 20x25 and the member array is also 20x25. So, can't he just replace the array directly? Map::LoadMap(int arr[20][25]) { map = arr; } Basically, just replacing the pointer to the start of the array.
I think its because if u do what u said, u can change your source array when u change your map. At the current state, it doesnt really matter though, but i think its for future stuff, or just something like good practise
@@majklavzar9057 I finally figured out the source of this. It's caused by defining the function Draw just like that, instead of TextureManager::Draw in TextureManager.cpp. No idea if you guys figured it out or not, but hopefully this helps someone else who ran into this problem.
I know I'm commenting on this a bit late, but I had one question regarding the "global" renderer variable you created to be used between classes: For example - To allow other classes to use this renderer variable, you included "Game.h" in the TextureManager class, and included "TextureManager.h" in the Game class. Since they are including each other, will this cause performance issues? Is there a neater way of doing this, since you only require the renderer variable from the Game class?
If you wanted to code all of this in one cpp file how would you do it since the you need gameobject before game in order to create player in void init in the game class and you need game class created in order to pass game::renderer in the void render function in gameobject?
idknuttin you can make the player etc global. And use forward declarations for any classes that you haven’t defined yet. Curious as to why you would want it in one massive file?
Aaaahhhh I'm having a lot of fun but I find myself just typing out what you have and not really understanding it all. I couldn't delete all this code and retype it is what I'm saying...sooooo I'm not learning.... :(
After each lesson, start modifying what he's done in your own copy. When you force yourself to change and add things, you'll start understanding it better. Then return to the original for the next lesson.
The previous answer was great. You need to practice a lot to be able to do it on your own.First of all, understand the structure he uses for its game and how all things work together. You really need to start with small projects, for example, snake, tetris and from there on you can build bigger projects.That's what I do and that's what everybody does.
To fill the screen, 25*32 (the resolution of his tiles) is 800 (the width of his window), 20*32 is 640, that's also why he changed the 600 height he had at the begining to 640.