SFML community forums

Help => Graphics => Topic started by: ElectricRevolt on February 25, 2019, 02:49:58 am

Title: Object class that inherits from Drawable and implements virtual draw
Post by: ElectricRevolt on February 25, 2019, 02:49:58 am
Hi, I am a total noob to C++ and SFML but I desparately want to learn.  I am familiar with OOP but definitely not that great at it.  I was hoping that someone could provide a basic example of a class that inherits from Drawable and uses the virtual draw function to display a simple sprite with a main.cpp driver to show it in action.  I have a hard time learning if I don't have a concrete example to go by.  I've been reading just about everything that I can find on how to do this but I am struggling to grasp the concepts.
Ultimately, I am required to build a class that stores sprite data, texture, and xy coordinates to draw moveable sprites to the target window for school.  I have to implement the private virtual draw function from my class that inherits from Drawable.
If someone could show me a basic simple functional example if its not too much to ask for, then I am sure that I can figure it out.
Title: Re: Object class that inherits from Drawable and implements virtual draw
Post by: G. on February 25, 2019, 09:07:01 am
Have you seen the sf::Drawable example in the documentation (https://www.sfml-dev.org/documentation/2.5.1/classsf_1_1Drawable.php#details)?
Title: Re: Object class that inherits from Drawable and implements virtual draw
Post by: eXpl0it3r on February 25, 2019, 10:55:39 am
There's also the TileMap example (https://www.sfml-dev.org/tutorials/2.5/graphics-vertex-array.php#example-tile-map).

Ultimately, I am required to build a class that stores sprite data, texture, and xy coordinates to draw moveable sprites to the target window for school.
Keep in mind that the goal of school work is that you actually do it yourself and not just copy & paste a solution or let other people solve things for you.
Secondly, your teacher/prof/assistant are being paid to help you, so you should make use of it, instead of asking people to invest their unpaid free time in helping you. ;)
Title: Re: Object class that inherits from Drawable and implements virtual draw
Post by: ElectricRevolt on February 26, 2019, 06:53:41 am
Thanks Dad, I figured it out.  I finally found some info where I was able to determine that the draw function was indeed a pure virtual function.  Once I discovered this I knew what to do.  Way easier than I envisioned.  I laugh at it now.