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

Author Topic: Muliple Questions  (Read 2357 times)

0 Members and 1 Guest are viewing this topic.

Narok

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
Muliple Questions
« on: August 08, 2012, 10:19:56 pm »
1) Is there a way to make it so you can only collide with non-alpha parts of the picture? This has been bugging me for awhile because it would be so much easier to have this rather than having to make a ton of different shapes.
 
2) Also, does anyone know how to make a SFML editor, or know where a tut is for one?

3) Also does anyone know how to clear a shape on function command? Or make multiple shapes by using a for loop? I want to make a enemyClass where it has a die function and when the user clicks on the enemy it disapeers. Also I want a enemyObject tied to each enemy shape, is there a way to produce a mass of those?

4) How do you make it so when your mouse intersects a object and is  clicked the object disapears from ^ class.


My idea of what a for loop to make multiple enemies would look like:

sf::RectangleShape enemy;
enemy.setSize(sf::Vector2f(25,25));
enemy.setPosition (100, 200);


int j;

for (j=1; j>=10; j++)
{
    sf::RectangleShape enemy(j);
    enemy(j).setSize(sf::Vector2f(25, 25));
    enemy(j).setPosition (100+(25+(j)), 200);

    enemyClass enemyObject(j);
}

Answering any one of these would be extremly helpful

Thanks
« Last Edit: August 08, 2012, 10:42:40 pm by Narok »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: Muliple Questions
« Reply #1 on: August 08, 2012, 10:42:33 pm »
1) Is there a way to make it so you can only collide with non-alpha parts of the picture? This has been bugging me for awhile because it would be so much easier to have this rather than having to make a ton of different shapes.
Yes you can create a pixel perfect collision, by converting it to a sf::Image and checking the alpha channel, unfortunatly this procedure won't performe very well at all, then again it highly depends on your game and for most of the games a simpler collision detection is sufficient.
 
2) Also, does anyone know how to make a SFML editor, or know where a tut is for one?
An editor for what? Graphics? Verticies? Meshs? TileMaps? Text? Code?

3) Also does anyone know how to clear a shape on function command? Or make multiple shapes by using a for loop? I want to make a enemyClass where it has a die function and when the user clicks on the enemy it disapeers. Also I want a enemyObject tied to each enemy shape, is there a way to produce a mass of those?
A shape won't get displayed if you don't draw it, simple as that. ;)
And it you want to create multiple shapes use a std::vector, if you don't know what that is, then you're lacking major knowledge in C++ and you'd be better of reading a good C++ book from front to back. ;)
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Narok

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
Re: eXpl0it3r
« Reply #2 on: August 08, 2012, 10:47:12 pm »
1) So are you saying pixel perfeect is very buggy?

2) An editor for all of those, or most.

3) I don't actually know too much C++ lol, I'm cutting corners for some, and the rest I'm learning by doing.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re: eXpl0it3r
« Reply #3 on: August 08, 2012, 11:05:41 pm »
1) So are you saying pixel perfeect is very buggy?
No, but for a bigger number of objects to collid with it's pretty slow (i.e. 1fps or so... ;D). Of course if you're doing it right and probably not directly with sf::Image but with your own structure you could get it to quite a good level, but it won't be easy and you're better of using other methods.

2) An editor for all of those, or most.
All of those what?
Graphics: Photoshop, Gimp, Fireworks, Photofiltre, Paint.NET, CorelDraw, ...
Verticies/Meshs: Blender, Max 3D, Cinema 4D, ...
TileMaps: TiledMapEditor, ...
Text: Notepad, Notepad++, Gedit, vim, nano, ...
Code: Notepad++, vim, Visual Studio, Code::Blocks, QtCreator, KDeveloper, ...

Basically just use google...

3) I don't actually know too much C++ lol, I'm cutting corners for some, and the rest I'm learning by doing.
Then you should defently read a book. C++ isn't a lol language, it's one of the best but also one of the hardest languages and it takes years to get a really good orientation with it and the learning process will probably never really stop.
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Narok

  • Newbie
  • *
  • Posts: 9
    • View Profile
    • Email
Re:Re: eXpl0it3r
« Reply #4 on: August 08, 2012, 11:19:37 pm »
1) Thanks

2) No haha. I meant is there a tut on how to make your own editor with SFML or C++ for SFML. Like on the right side there would be a list of objects to chose, and when you clicked one it would ask for the size, color, and if you wanted to texture it, then you could determine the position by dragging it around in real time instead of having to guess and check like we have to do now.

3) Will do, thanks.

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11034
    • View Profile
    • development blog
    • Email
Re:Re: eXpl0it3r
« Reply #5 on: August 08, 2012, 11:37:18 pm »
No haha. I meant is there a tut on how to make your own editor with SFML or C++ for SFML. Like on the right side there would be a list of objects to chose, and when you clicked one it would ask for the size, color, and if you wanted to texture it, then you could determine the position by dragging it around in real time instead of having to guess and check like we have to do now.
No, there's no such tutorial afaik.
Note that SFML is not a GUI library, thus depending on what you want to do SFML maybe isn't the right library for it...
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

 

anything