Re-validating an iterator

Pages: 12
make a 2D game using C++ and SFML, thats all I want.

M'ok, a good start with a book could be:

Beginning C++ Game Programming: Learn to program with C++ by building fun games, 2nd Edition https://www.amazon.com/Beginning-Game-Programming-program-building/dp/1838648577/

I have the book, I purchased it as an eBook during a Packt sale a while back, and it teaches the basics of SFML using C++ from the ground up. No WinAPI GUI. I haven't dinked around with more than the first couple of chapters.

The book has a github repo for the sources:
https://github.com/PacktPublishing/Beginning-Cpp-Game-Programming-Second-Edition

FYI, SFML is a library supported by vcpkg, and if you use Visual Studio any installed vcpkg packages can be integrated into the IDE so you don't have to worry about finding directories/files for the libraries.

https://vcpkg.io/en/getting-started

Even if you don't integrate vcpkg into the VS IDE vcpkg is also setup for using CMake as well, so you aren't tied down to just Windows for using the libraries.

Personally I enjoy mucking around the old C++/WinAPI code from those two game programming books I mentioned. That is the main reason I haven't really jumped into the SFML game programming book above beyond the first couple of chapters.
@seeplus

Well I just want to make sure my C++ knowledge is really solid before jumping into the SFML library in depth. 4 months ago i had no idea how to use iterators, lambdas, chrono, enum classes, template concepts, structured bindings, smart pointers, threads. My knowledge is still a little shaky with threads, template concepts and smart pointers but i haven't really focused too hard on those just yet either, but i will be after learning the chrono library, which i'm working on now. I have a lot of gaps in my knowledge that i'm trying to fill before moving on, but i totally agree, i will start small, maybe a basic cookie clicker clone or something like that. I have used SFML on and off here and there and im somewhat familiar with it but not enough to write it confidently, but i'll get there eventually.

I set a goal for myself that by the end of the year I want to have filled all the gaps in my knowledge, and learn enough to be able to do game development without much of an issue. I mean, I know im still going to run into problems, but knowing all the things im trying to learn will help at least limit my roadblocks ahead.

The way I see it, its similar to game design in itself, if you rush in and start writing a game with no design, its probably gonna end badly unless its something trivial. Same with learning C++, if I just try to write a game with my current knowledge, then I probably wont get very far. I cannot tell you in words how badly I want to start developing a game, it borders on excruciating, but I know ill get there, I just need to be patient and learn first. Like I said before, im still going to run into road blocks and make mistakes along the way, thats just part of the process, but being stuck because I don't know how to search a container or run certain aspects of my program concurrently is probably not gonna end well for me haha.

I mention ChatGPT a lot but I don't think I would be this far in my learning without it. I probably wouldn't reach my goal. Having the ability to get your code evaluated and corrected literally instantly any time I want and be given detailed explanations on what's wrong with it and why has been a godsend for me, which is why I pay $20 a month to use GPT 4, its worth its weight in gold so far.

@George P

Thanks for that suggestion, I'll check that one out as well. I actually own this book here:

https://www.packtpub.com/product/sfml-game-development-by-example/9781785287343

I remember asking on the SFML forums about 7 months back if its still good enough for modern SFML and they said it holds up pretty well, so ill be using that in tandem with the one you suggested.

Funny story, I remember a long time ago having a project I was trying to recruit people for on the SFML forum, and the writer of that SFML book I linked to emailed me cause he was interested in my project haha, he couldn't actually help though because he was contracted to start work on another book at the time but I thought that was so cool, here i was reading this guys book and he saw my post and emailed me about it.

But anyways yeah I tried WINApi when i first started programming and man, that was a nightmare. SFML or SDL FTW. I'll have to look into vcpkg for SFML, I just installed the new version of SFML that came out and linked it to a project in VS22, and if vcpkg prevents me from having to link everything every time I make a new project for SFML that's something i'm interested in cause that's such a pain in the ass to have to do that all the time.
Last edited on
When vcpkg is properly integrated into the VS IDE you won't have to manually enter the library's directory/file locations any more in your project's property pages. vcpkg takes care of that for you.

Plus, with a library installed with vcpkg the VS IDE will auto-complete any library headers you start to include. Let's say you want to #include <SFML/Graphics.hpp> . When you start typing the #include, < and SFML the auto-complete feature will let you "find" any header in the SFML library. Saves a lot of hassles with mistyped header names.

One minor detriment when compiling an SFML program that has an entry point of int main( ) on a Windows machine will pop up a console window and then display the SFML window.

AN-NOY-ING!!!!!!

So I went looking on the interwebs for a way to stop the console window from being displayed.

Meta-search:
https://duckduckgo.com/?q=winapi+sfml+how+to+stop+the+console+window+from+showing&t=ffab&ia=web

I found this stackoverflow entry:
https://stackoverflow.com/questions/21181748/is-there-any-way-that-we-let-the-window-appear-but-not-the-cmd-in-sfml

Instead of linking as a C++ console mode program your project links as WinAPI Windows subsystem.

But wait, that buggers the VS IDE when you try to compile your SFML code that uses main, it whinges it can't find WinMain.

Add this single non-standard line of code to your SFML code:
#pragma comment(lib, "sfml-main.lib")

https://stackoverflow.com/questions/12821391/c-visual-studio-linking-using-pragma-comment

This way you don't have to change your project's properties to link that library file. Using that LIB file suppresses the console window so all you see is your SFML window.

Fair warning, it does puts up a barrier for the VS IDE, you can NOT use the VS debugger, a debug build fails. So only use that #pragma code AFTER you have a finished project you won't be changing or debug testing.

vcpkg makes installing, updating and uninstalling an installed library easy. Just a couple of command prompt commands.
Here's a Lounge thread I created a while ago for why I like vcpkg:

https://legacy.cplusplus.com/forum/lounge/284973/

I use Git For Windows, so I have a console mode and a GUI clients for working with vcpkg and github.

https://gitforwindows.org/

I use the GUI to upload files/folders to a github repo and the console mode for cloning/pulling from a repo.
If you are thinking about using git and creating repositories I'd suggest you learn about the Markdown markup language so you can create READMEs and other formatted text files that reside in your repo.

https://www.markdownguide.org/
Thanks for all the info, ill set that up at some point here soon. For git, I usually just use the built in Git think in VS22, and I have GitHub desktop as well although i rarely use that but keep it around just in case. I have a little knowledge of markdown, I recently started using a program to keep my C++ notes in called Zettlr which uses a lot of markdown.

I just got that new C++ book so ill be reading through that as well.
Last edited on
Topic archived. No new replies allowed.
Pages: 12