Login

Lost your password?
Don't have an account? Sign Up
https://www.educational.guru

25 comments

  1. Oskar

    Was actually just curious about how to program games in C, but your explanations (and your small mistakes lol) made your video really interesting and fun to watch. Keep going, I think you found a new subscriber 😉

  2. IloveC

    hey. can you make more tutorials,? just still use C. mario, pacman, pong, tetris, which have some basic concepts of game development. I started game dev in unity but it feels like I am missing something.Then I tried this tutorial ,which opens a lot about how a game really works. Hoping for more of your tutoirlas. (from the 2015 kids)

  3. Nerevar Indoril

    idTech 1, 2 and 3 engine were written in C and games that are using it are Doom 1/2, Quake 2/3. You can develop games in pure C but you will need good skills. You can just use structs and pointers to mimic Class in OOP. structs can hold data types, other structs(which is basically advanced data type) and pointers to functions. You can make your code really nice. For example:

    typedef struct Texture {
    void (*LoadTexture)(struct Texture*);
    void (*RenderTexture)(struct Texture*);
    void (*Destructor)(struct Texture*);
    const chat *path;
    SDL_Texture *texture;
    } Texture;

    As you can see, Texture “class” holds everything you need. Later on you just place function pointers.

    Texture background = { &LoadTexture, &RenderTexture, &DestroyTexture, “data/background.png” };

    And then you can use your “object”.

    background.LoadTexture(&background);
    background.RenderTexture(&background);
    background.Destructor(&background);

    Thats it, you don’t need classes.

  4. Braden Best

    What’s wrong with just using ‘Bullet bullets[]’? You’d remove a layer of complexity and still be able to use it as an array: bullets[n].x or (bullets + n)->x.

    Then you could add a flag into the structure like “int visible:1;” and default the whole array to 0, thus when you want to “add” a new bullet, you set its “visible” member to 1. When the bullet is removed, you set it to 0.

    As an array of structures, it would provide a single pointer to the beginning of a chunk of memory representing multiple contiguous bullet structures, and each one is re-usable without having to dynamically allocate new space for them, nor deal with an extra layer of indirection.

    Plus, it’s better to avoid dynamic memory allocation and take advantage of the stack rather than allocate everything on the heap.

    1. Jackstone Brooks88

      Braden Best No I think it’s easier to use a constant to fill up an array of the maximum amount of bullets this makes it easier for someone new starting out with C…but nonetheless I see what your saying he basically did a much easier way than…what you just said

    2. Neil Roy

      I also felt a simple linked list would work well, but that may have been too much for this simple tutorial. A nice index variable, something that pointed to the last available location in the array would have saved going through a loop each time. Just add to that spot then increment the index (or decrement it if a bullet is removed). Then the only loop needed would be at the end of the program and even that would only need to go up to the index and no farther.

  5. Nicolas Goubin

    Hey i’m starting in programming, chose to begin with C language which i find really interesting to me.
    As for my 1st library to work with i would like to master SDL one. But should i try to learn SDL then move to SDL2 or SDL2 from the beginning instead ?

Leave a Comment

Your email address will not be published. Required fields are marked *

*
*