jahboater
Posts: 4425
Joined: Wed Feb 04, 2015 6:38 pm

Re: Coding Games Tutorial in MagPi Help

Sun Mar 03, 2019 11:01 am

dsyleixa123 wrote:
Sun Mar 03, 2019 8:54 am
compile (F8), build (F9), and run it (F5), no need for makefiles.
It may use makefiles underneath, I don't know.
The thing is, you have 500 source files and you change one .c or .cpp file. Make will ensure that only the one single file gets recompiled rather than all 500 of them (much faster). Of course if you changed a header (.h) file and they all include it, then they will all get recompiled. Make handles all that automagically.
If the worst does happen and they all need recompiling, then make's ability to schedule multiple compilations on all four CPU cores simultaniously speeds things up yet again.

dsyleixa123
Posts: 289
Joined: Mon Jun 11, 2018 11:22 am

Re: Coding Games Tutorial in MagPi Help

Sun Mar 03, 2019 11:19 am

I see, but for a beginner who just starts simple (game) programs some extra seconds for recompilings wouldn't matter so much. Instead, having to handle makefiles IMO is really a mess, I wouldn't do that. So I just #include header files, and press F9 + F5, keeping it simple, stupid.

Brian Beuken
Posts: 177
Joined: Fri Jan 29, 2016 12:51 pm

Re: Coding Games Tutorial in MagPi Help

Sun Mar 03, 2019 4:59 pm

Sorry but what you're asking for really isn't viable, a program capable of doing the basics of even a simple game, needs several classes/functions/systems to work. Graphics, input, files, etc..its a lot of different things to keep track of.

You "could" put it all in one file, but it would be an editing nightmare, and would also take quite a long time to compile, you might be surprised just how slow a compiler is, taking text files, working out all the values, small files take a few seconds, larger files take a lot longer.

So we keep them in small tight easy find, easy to read and edit files with names that explain what they do. Which in turn compile quickly and are stored if not changed so no more compiling needs to be done. This speeds up the edit/build/deploy process.

Make files take care of compiling and linking them into a final project.
Now, I agree with you, make files are confusing messes if you try to read or edit them, especially on big projects.. But...this is where IDE's like Code::Blocks come into their own. They create the make file, they keep it updated so you don't have to.

They do need a few clues, they need to know where the libs you want to use are, what they are called, and where the includes .h files are, but once they have that you can write a program with 100's files and only ever need to press F5 to make it build and run.

Tools....can be complex to learn, but once mastered make life so much easier.
Very old computer game programmer, now teaching very young computer game programmers, some very bad habits.
Wrote some book about coding Pi's and SBC's, it's out now...go get it!
http://www.scratchpadgames.net/

dsyleixa123
Posts: 289
Joined: Mon Jun 11, 2018 11:22 am

Re: Coding Games Tutorial in MagPi Help

Sun Mar 03, 2019 7:27 pm

Brian Beuken wrote:
Sun Mar 03, 2019 4:59 pm
Sorry but what you're asking for really isn't viable, a program capable of doing the basics of even a simple game, needs several classes/functions/systems to work. Graphics, input, files, etc..its a lot of different things to keep track of.

You "could" put it all in one file, but it would be an editing nightmare, and would also take quite a long time to compile, you might be surprised just how slow a compiler is, taking text files, working out all the values, small files take a few seconds, larger files take a lot longer.

So we keep them in small tight easy find, easy to read and edit files with names that explain what they do. Which in turn compile quickly and are stored if not changed so no more compiling needs to be done. This speeds up the edit/build/deploy process.

Make files take care of compiling and linking them into a final project.
Now, I agree with you, make files are confusing messes if you try to read or edit them, especially on big projects.. But...this is where IDE's like Code::Blocks come into their own. They create the make file, they keep it updated so you don't have to.

They do need a few clues, they need to know where the libs you want to use are, what they are called, and where the includes .h files are, but once they have that you can write a program with 100's files and only ever need to press F5 to make it build and run.

Tools....can be complex to learn, but once mastered make life so much easier.
as I stated:
1 main file to compile, and #including perhaps dozens of .h files for the classes, that is actually just 1 file to work with (i.e., the main program file feat. the main() function and a bunch of another functions more). That will work for Geany, too, no doubts, but just having to deal with a simple and handy IDE, what we already have agreed about and what I am gladly looking forward to 8-) .

Brian Beuken
Posts: 177
Joined: Fri Jan 29, 2016 12:51 pm

Re: Coding Games Tutorial in MagPi Help

Mon Mar 04, 2019 1:40 am

No

Sorry, but no.
That's not how C++ works. Its not really productive to enforce your working methods on a system designed around totally different working methods.

I think it would be more productive for you to have some simple lessons on using Code::Blocks rather than heading down a blind development lane.
Very old computer game programmer, now teaching very young computer game programmers, some very bad habits.
Wrote some book about coding Pi's and SBC's, it's out now...go get it!
http://www.scratchpadgames.net/

dsyleixa123
Posts: 289
Joined: Mon Jun 11, 2018 11:22 am

Re: Coding Games Tutorial in MagPi Help

Mon Mar 04, 2019 12:34 pm

Also the Arduino API is legal C++, and it works perfectly, simple and convenient, and commonly there is just 1 main program file used in the IDE providing setup and loop() (which is actually just a while() loop in main() ), apart from some #included arbitrary libs and classes (e.g. for amazing, simple Touch-TFT functions). IMO anything else is far too complicated for beginners and hobbyists, at least to me.
Alternatively, also Borland C++ for Windows is an awesome and powerful GUI IDE, generating all GUI Windows code automatically for all gadgets and events, and also for that just 1 C++ source code file is needed - the rest is generated automatically. Perhaps similar like qtcreator, but 1000x simpler to use (and opposite to qtcreator on the Pi, the Borland C++ Builder works for Windows out of the box :P )

Return to “C/C++”