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

Author Topic: attchaching on object to another as a child on mouseClick  (Read 1782 times)

0 Members and 1 Guest are viewing this topic.

andrei186

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
attchaching on object to another as a child on mouseClick
« on: September 27, 2019, 05:57:10 pm »
I  need to make a shooting simulator similar to this one made in Flash: http://igroflot.ru/shot/flash_game_50/

When mouse is pressed a bullet hole is placed on the target at the coursor coordinates. I guess these a local target coordinates and the bullet hole object becomes a child of the target object so that if the target moves or scales, the hole moves and scales with the target.

Also the points score is returned and its value depends on the hit zone of the target.
In Flash this is done by assembling the target of concentric circles each beeing a sepatate object with its points value and listening for onPress event (mouse click) which calls a function placing the bullet hole and returning the points.
In Flash when several objects, listening onPress event are placed one on top another, only the upper one reacts and stops event from propagating downwards.

I am trying to select a right tool to repeat this without Flash.
Can this approch be implemented in  C++ and SFML? I have SFML installed as well as Code Blocks C++ and Viasual Studio,  I looked through a number of tutorials, but still not sure if C++& SFML would be the right choice.

A founded opinion will be appreciated
« Last Edit: September 27, 2019, 09:08:28 pm by andrei186 »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11035
    • View Profile
    • development blog
    • Email
Re: attchaching on object to another as a child on mouseClick
« Reply #1 on: September 27, 2019, 07:57:41 pm »
You can certainly do this with C++ and SFML, but don't forget that SFML isn't a game engine, so you don't get features like object/entity management or event handling on entity-level, but you can easily implement this yourself. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

andrei186

  • Newbie
  • *
  • Posts: 26
    • View Profile
    • Email
Re: attchaching on object to another as a child on mouseClick
« Reply #2 on: September 30, 2019, 04:46:29 pm »
Thank you. As I never used game engine and my experience is limited by doing some simple games in Flash, I have no idea of what "object/entity management" means in this context.  I guess it allows creating visible objects, placing them on the screen and making them move?
I know event handling in Flash. Saying "don't get event handling on entity-level"  do you mean that in SFML there is no built-in facility to handle, for example, a mouse click on a particular object?   

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11035
    • View Profile
    • development blog
    • Email
Re: attchaching on object to another as a child on mouseClick
« Reply #3 on: October 02, 2019, 11:33:51 pm »
As I never used game engine and my experience is limited by doing some simple games in Flash, I have no idea of what "object/entity management" means in this context.  I guess it allows creating visible objects, placing them on the screen and making them move?
I don't know anything about Flash, so I can't really provide you some useful comparison.

My point was more, that in SFML terms an "object on the screen" is less of a thing that you can interact with and much more just a shape or image you can put on the screen. So interaction isn't really focused on the object, but it's much more focused on providing you a tool set to render shapes and images onto the screen.
Like you aren't defining a moving path or setting some animation points for an object, but instead you need to write the code that makes an object move (simple math & physics) and then you can apply that to an SFML shape or sprite that then gets rendered to the screen.

The same thing goes with event handling. You aren't reacting to events that happen to an object, but instead you have events on the window and if you want to figure out whether the mouse click on the window was on top of one of your objects, you'll have to apply your own math to figure this out.

I suggest looking through the official tutorials, so you get a sense of what SFML provides. :)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything