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

### Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

### Topics - Saw

Pages: [1]
1
##### C / 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.

2
##### C / How sfClock_getElapsedTime() works ?
« on: March 08, 2023, 08:21:44 am »
I don't understand how the function works. It feels like too little time has passed since the clock was updated, and therefore the counter value is always 0.

float time = sfTime_asSeconds( sfClock_restart(clock) ) ;
delta_time = sfClock_getElapsedTime(clock) ;
timer += sfTime_asMicroseconds(delta_time);

But timer always 0.

Also:

CSFML:
sfTime PreviousTime = sfTime_Zero ;
sfTime  CurrentTime = sfClock_getElapsedTime(clock) ;
sfTime  FrameTime = CurrentTime - PreviousTime ;
PreviousTime = CurrentTime ;
float DeltaTime = sfTime_asMicroseconds(FrameTime) ;

Error: [bcc32 Error] main.cpp(76): E2093 'operator-' not implemented in type 'sfTime' for arguments of the same type

SFML:
sf::Clock clock;
sf::Time previousTime{ sf::Time::Zero };
const sf::Time currentTime{ clock.getElapsedTime() };
const sf::Time frameTime{ currentTime - previousTime };
previousTime = currentTime;
const float dt{ frameTime.asSeconds() };

Compiles without errors.

What am I doing wrong?

Upd.

Works:
sfClock *clock = sfClock_create();
sfTime PreviousTime = sfTime_Zero ;
sfTime  CurrentTime = sfClock_getElapsedTime(clock) ;
float DeltaTime = sfTime_asMicroseconds(CurrentTime) -  sfTime_asMicroseconds(PreviousTime) ;
PreviousTime = CurrentTime ;

The problem with the timer occurs if 2 clock sources are declared.

Not works:
sfClock *clock = sfClock_create();
sfClock *clock2 = sfClock_create();
sfTime PreviousTime = sfTime_Zero ;
sfTime  CurrentTime = sfClock_getElapsedTime(clock) ;
float DeltaTime = sfTime_asMicroseconds(CurrentTime) -  sfTime_asMicroseconds(PreviousTime) ;
PreviousTime = CurrentTime ;

This is a quest. It's a pity there is no description for CSFML.

3
##### C / sfTime allways have zero value
« on: March 05, 2023, 04:55:57 pm »
I assign a value to a variable ways, but in the debugger the value is always 0.
In theory, everything should work. Maybe I'm doing something wrong?

sfTime time1 = sfSeconds(0.1f) ;
sfTime time2 = sfMilliseconds(100000);

CSFML 2.5.1
C++ Builder 11.3

Pages: [1]
anything