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

Author Topic: Object class that inherits from Drawable and implements virtual draw  (Read 1051 times)

0 Members and 1 Guest are viewing this topic.

ElectricRevolt

  • Newbie
  • *
  • Posts: 3
    • View Profile
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.

G.

  • Hero Member
  • *****
  • Posts: 1590
    • View Profile

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 10800
    • View Profile
    • development blog
    • Email
Re: Object class that inherits from Drawable and implements virtual draw
« Reply #2 on: February 25, 2019, 10:55:39 am »
There's also the TileMap example.

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. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

ElectricRevolt

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Object class that inherits from Drawable and implements virtual draw
« Reply #3 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.

 

anything