Hi there, I've been working for a while in my first game. I'm using C++, Raylib and Nodepp, I hope you like it. If you have any feedback for me, it would be greatly appreciated! Here is the Github link:
#My First Game In C++
26 messages · Page 1 of 1 (latest)
you're not meant to include c++ source files
you're supposed to build them and then link them together
you should include header files (.h or .hpp) which will have the declarations for classes, functions, etc. and then define those in the source files
for example
// example.hpp
int add(int a, int b);
int sub(int a, int b);
// example.cpp
#include "example.hpp"
int add(int a, int b) {
return a + b;
}
int sub(int a, int b) {
return a - b;
}
// main.cpp
#include <iostream>
#include "example.hpp" // we include the header file
int main() {
std::cout << add(3, 4) << '\n';
std::cout << sub(5, 6) << '\n';
return 0;
}
you should also consider using a build system like cmake
You’re perfectly fine including source files; that’s how I do it as well
bro what
thats not what source files are for though
if you don't want to build and link multiple files you could just define things in header files
They’re for whatever I want them to be
sure, if you're doing small solo projects and don't care, but if you're looking for best practices, which is what i imagine edbc is looking for, that's just not it
using a proper build system also makes larger projects easier to scale and manage
so no he's not perfectly fine including source files
i totally agree with zwei. It's the best to know the correct way of doing things and then sure you can do whatever you wanna do. But if someone comes up to you and says "check this out this is my first cpp game project" then you better guide him properly.
no offense
If edbc wants/needs to get a job in the industry or they feel like they are having trouble organizing their project, then yeah they'll have to get into build systems and all that stuff. But it seems like they're doing just fine without one but I'd want to hear what they have to say.
I was not talking about build systems but i got your point. I was just talking about source and header files you mentioned.
Im also working as a game dev and we don't have much time to tidy things up all the time in projects. And also im sure we're familiar with the leaked gta source codes. They are terrible at some point but it also works just fine (mostly).
What I actually wanted to say is let edbc know the differences and purposes of things and then say it's totally ok what he is doing at this point because it is, mate.
Looks AMAZING. no joke! this is cool,
Maybe change the color of the ball enemy, its very close to the background, so you could also change that.
the FPS seems a little low for the game of your scale, try to optomize any loops in your game, reducing how many actions / amount of different loops / nested loops will help performance.
Keep up the good work soldier!!!
"update" 💀
take cmake bro
why is it bad to include source files? I don't do it but what difference does it make?
oh okay you replied later
for some reason it wasnt scrolling beyond that