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

Author Topic: sfCircleShape_move  (Read 2976 times)

0 Members and 1 Guest are viewing this topic.

Saw

  • Newbie
  • *
  • Posts: 11
    • View Profile
sfCircleShape_move
« on: March 11, 2023, 03:47:37 pm »
Draw a circle, trying to move it.
The sfCircleShape_move function must move the object by the given offset. But the movement goes along the coordinates specified in the parameters of this function, or a generally incomprehensible result
        sfCircleShape *circle = sfCircleShape_create();
        sfCircleShape_setRadius(circle, 20 - 3);
        sfCircleShape_setOutlineThickness(circle, 3);
        sfCircleShape_setOutlineColor(circle, sfBlack);
        sfCircleShape_setFillColor(circle, sfWhite);

        sfVector2f CirclePosOld = {800 / 2, 600 / 2};
        sfCircleShape_setPosition(circle, CirclePosOld) ;

        sfVector2f CirclePosNew = { 50, 50 } ;
        sfCircleShape_move(circle, CirclePosNew );

        float fPosOld_x = CirclePosOld.x ;
        float fPosNew_x = sfCircleShape_getPosition(circle).x ;

        float fPosOld_y = CirclePosOld.y ;
        float fPosNew_y = sfCircleShape_getPosition(circle).y ;

 

Result:


Works:
        sfVector2f CirclePosOld = {800 / 2, 600 / 2};
        sfCircleShape_setPosition(circle, CirclePosOld) ;
        sfVector2f CirclePosNew = {CirclePosOld.x + 50, CirclePosOld.y + 50 } ;
        sfCircleShape_setPosition(circle, CirclePosNew) ;
 


It feels like I'm the only one with the problems.
« Last Edit: March 11, 2023, 04:42:18 pm by Saw »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: sfCircleShape_move
« Reply #1 on: March 11, 2023, 04:20:02 pm »
Like your other problems, I'm betting on it being a weird issue with the Borland/Embarcadero compiler.

Code is quite predictive, but if the compiler just does random other things, then it because kind of impossible to program something. :D

Why are you writing in C anyways, when you have a C++ compiler at your hand?
Does it work if you just call SFML directly instead of using CSFML?
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

Saw

  • Newbie
  • *
  • Posts: 11
    • View Profile
Re: sfCircleShape_move
« Reply #2 on: March 11, 2023, 04:33:35 pm »
C++ Builder cannot work directly with MSVS C++ libraries, i.e. these libraries have a namespace. Therefore, only option C can be used. It's strange, of course, but other libraries seem to work without problems,
even the same SDL (I tried it for a long time, but I can try again for the sake of the experiment). But here, everything related to operations with variables does not work as it should (everything is fine in VisualStudio). I don't know what to think. It seems that when calling library functions, the link goes to memory areas where random data is located.

It will probably be easier to write on MSVS :(
« Last Edit: March 11, 2023, 05:51:34 pm by Saw »

 

anything