#My First Game In C++

26 messages · Page 1 of 1 (latest)

thin gust
modern juniper
#

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

native aurora
#

What an interesting code... 🧐 And commit messages 🧐🧐

#

The game looks cool though

noble quarry
#

You’re perfectly fine including source files; that’s how I do it as well

modern juniper
#

if you don't want to build and link multiple files you could just define things in header files

noble quarry
modern juniper
#

using a proper build system also makes larger projects easier to scale and manage

#

so no he's not perfectly fine including source files

barren arch
#

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

noble quarry
#

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.

barren arch
#

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.

stone fern
#

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!!!

copper siren
#

take cmake bro

pulsar glen
#

oh okay you replied later

#

for some reason it wasnt scrolling beyond that