Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: A game engine i have been working on + Formatable Text  (Read 6143 times)

0 Members and 1 Guest are viewing this topic.

kleinschrader

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
A game engine i have been working on + Formatable Text
« on: May 18, 2018, 07:19:18 pm »
Hi all,

i have been working on a small Project for some time now.
Its an Engine i plan to use in the Future for some games of mine.

https://github.com/kleinschrader/SFML-GameEngine-Test

It includes a somewhat inacceible Font and Texture loader im gonna rework.
An accecible Multithreading Renderer
and finaly a derivative of sf::Text that can have int's, float's and char arrays passed to it and have them Printet in the string and automaticly updated, similar to printf. (Its kind of an hack due to the way sfml works)

Geheim

  • Full Member
  • ***
  • Posts: 201
    • View Profile
    • Email
Re: A game engine i have been working on + Formatable Text
« Reply #1 on: May 18, 2018, 08:49:06 pm »
Hey,
I just took a quick look over your project...
You are using quite a lot of raw pointers, which most of them are never deleted (= memory leak).

One example would be your
sf::Font *FontArray;
this->FontArray = new sf::Font[Fonts::MAXSIZE];
// never deleted...

Many of them are not required in your project and if you really need pointers, use smart pointers.
Nowadays (since C++14) you don't even have to use the new keyword yourself.

There is also some inconsistency in your coding style, as if multiple people work on it, like:
float yScale                         // camelCase
sf::RectangleShape *Left_side        // Snake_case
sf::String OrgString                 // PascalCase
Or
#include "Textf.h"      // in Textf.cpp
#include <Textf.h>      // in main.cpp

I know that looks like not a big deal, but for some people it is, just don't make it a bad habbit  ::)

Anyways, keep it up!
Failing to succeed does not mean failing to progress!

kleinschrader

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: A game engine i have been working on + Formatable Text
« Reply #2 on: May 18, 2018, 09:03:49 pm »
Heyo,

i dont think that is a memory leak.
I allocated space for the fonts so i can access them later.
Of course i dont have a deconstructor but im to lazy to do them.

And yea. I know my code style is all over the place, ill have to clean up and comment more.

Thanks for the feedback. Ill better myself, i promise :)

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: A game engine i have been working on + Formatable Text
« Reply #3 on: May 18, 2018, 09:08:05 pm »
If you don't delete your allocated memory, then yes, you do have a memory leak.

Are there some pictures to go with your project? :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

kleinschrader

  • Newbie
  • *
  • Posts: 3
    • View Profile
    • Email
Re: A game engine i have been working on + Formatable Text
« Reply #4 on: May 18, 2018, 09:34:52 pm »
Hi,
i do not really need to Delete them, do i?

I mean the only time i do not use them is if the Programm is closing.

I have a simple picture, yes. To be honest it dosent show much, but im Proud of the fText.


Phanoo

  • Full Member
  • ***
  • Posts: 136
    • View Profile
Re: A game engine i have been working on + Formatable Text
« Reply #5 on: May 29, 2018, 04:11:03 pm »
It depends, if it's a global object that is allocated only once at game startup then you don't need to delete it, although it's considered good practice to delete everything manually so everything is cleaned up properly in the right order
« Last Edit: May 29, 2018, 04:13:32 pm by Phanoo »