123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|694|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> C/C++/C#/Other -> Converting simple code from basic to c...

Fri, 05 Oct 2007, 04:01
spinal
I having trouble converting this code to c.


I have the following, but the tail floats towards the top left, rather than following the mouse.
The code is for the DS, but the maths sould be understandable by most people.



If anyone can tell me why the tail floats towards top left, I need this fixed. It's bugging me a bit.

-=-=-
Check out my excellent homepage!
Fri, 05 Oct 2007, 05:06
mike_g
Just a random guess without looking at the code much, but you might need to convert from radians to degrees?
Fri, 05 Oct 2007, 14:18
spinal
I don't think thats it, the angles seem only slightly out, I would expect if that were the case, the agnles would seem almost random.

-=-=-
Check out my excellent homepage!
Fri, 05 Oct 2007, 14:23
Phoenix
Maybe it's not required (I haven't tried the code), but it seems like you forgot to translate this part of the code:

Fri, 05 Oct 2007, 15:09
spinal
nope, thats just for setting the start points, it doesn't make any difference once the mouse/stylus is squiggling about the screen.

It seems the angle is being calculated wrong.

-=-=-
Check out my excellent homepage!
Fri, 05 Oct 2007, 17:07
spinal
I managed to get it to work in the same way as the blitz version, it was most likely not calculating the angle correctly due to the closeness of each of the sets of points. I multiplied everything by 10 then divided it when plotting. I kept forgetting my nodes were u8, I changed it to u16 and it seems fine now.

Thanks for the help guys. Here is the code in case I loose it in the future ( I have a habit of doing that!).


|edit| I have increased the accuracy enough by multiplying by 100 also by using sprites, I can use a tiles background instead of a bitmap one. This might just make a nice game.

-=-=-
Check out my excellent homepage!