Sin/Cos Movement Error

For questions about using Classic.

Post » Fri Jun 24, 2011 11:13 am

Hi everyone, I tried to make a simple asteroids movement with friction and now my rocket is shaking weirdly :shock:

First: is this sinus behaviour normal? When the angle is larger than 180 sin should become a negative number but instead it seems to become zero?

[url:19w1roxi]http://www.file-upload.net/download-3532747/Sin-Error.cap.html[/url:19w1roxi]

Second: This is the problem-program, using arrow keys should move the 'rocket' but the movement angle seems 225 and the 'shaking' is weird :( .

I used private variables in the sprite and in the 'Text' for movement calculation.

[url:19w1roxi]http://www.file-upload.net/download-3532755/Movement-Error.cap.html[/url:19w1roxi]

Thank you. I'm still pretty noob with Construct :mrgreen:
B
4
S
1
G
1
Posts: 49
Reputation: 997

Post » Fri Jun 24, 2011 1:15 pm

The first is going into the negatives for me. It may be going into scientific notation, but its running so fast you might not see the e.
On the second I'm not sure, but setting the x/y speed in always may be interfering with your up key event.
Also having the up key event as a sub event in always wont change anything.
Image Image
B
161
S
48
G
90
Posts: 7,347
Reputation: 66,749

Post » Fri Jun 24, 2011 10:56 pm

To the First:
That's odd, I get a -0 most of the time when using sinus on an angle between 180 and 360 :(





However using it in events seems to work... just displaying as negative number results in a -0 or when animated it flickers between -0 and some strange wrong number (up to -9,837485 something). Sometimes with e's like 0,34e2745598, most of the time just -0.


To the Second:
KeyDown was not the problem. When accelerating over a longer period the shaking stops until you release the upkey. The friction works wrong :evil: , I suspect the angle command in the beginning.
B
4
S
1
G
1
Posts: 49
Reputation: 997

Post » Tue Jun 28, 2011 2:29 pm

Solved the Sinus Problem using "Format Decimal" in Text
(Displays x numbers after the comma)

For the movement I used a different approach, don't know why it didn't work
B
4
S
1
G
1
Posts: 49
Reputation: 997


Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 8 guests