Posted By
|
Message
|
jamesh
Registered 28/02/2012 15:24:25
Points 381
|
28th May, 2013 at 28/05/2013 13:22:04 -
Hi
I've found the circular movement on MMF2
It doesn't seem to be very useful as you seem to have to define a centre for the circle in the level editor, and can't do so on the fly
How can I have an object moving in a circle, with a centre I can choose/change?
Certainly doesn't have to be with this movement - I have a hunch that some trigonometry might be involved?
n/a
|
OMC What a goofball
Registered 21/05/2007
Points 3516
|
28th May, 2013 at 28/05/2013 14:52:42 -
You have to add the Clickteam Movement Controller object to the frame to change the parameters of that movement. Take a look at it and see if it suits your needs.
|
jamesh
Registered 28/02/2012 15:24:25
Points 381
|
28th May, 2013 at 28/05/2013 15:26:49 -
Thanks! I'll give it a go
also, I'm trying this:
http://inventwithpython.com/blog/2012/07/18/using-trigonometry-to-animate-bounces-draw-clocks-and-point-cannons-at-a-target/
Trying to translate it from python. Somehow can't get it to work
Here's the relevant bit:
# draw blue ball
xPos = math.cos(step) * AMPLITUDE
yPos = -1 * math.sin(step) * AMPLITUDE
pygame.draw.circle(DISPLAYSURF, BRIGHTBLUE, (int(xPos) + WIN_CENTERX, int(yPos) + WIN_CENTERY), 20)
[...blah blah blah]
step += 0.02
step %= 2 * math.pi
So the way I figure it is this (I'm using an alterable value in place of the variable 'step' here):
Start of Frame:
set Alt Val A of [OBJECT] to 0.2
Every [so often]:
set x position of [OBJECT] to cos(Alt Val A of [OBJECT]) * [let's say 50]
set y position of [OBJECT] to -1 * sin (Alt Val A of [OBJECT]) * [let's say 50]
add 0.2 to Alt Val A of [OBJECT]
set Alt Val A of [OBJECT] to (Alt Val A [OBJECT] mod 2)*pi
This is actually bouncing up and down in a vaguely sine-wavey way (though very jerkily), but not moving in the irection at all.
What am I missing?
n/a
|
jamesh
Registered 28/02/2012 15:24:25
Points 381
|
28th May, 2013 at 28/05/2013 17:09:02 -
OK
I've narrowed down the problem a bit, by fixing some mistakes in my code
For now I'm just trying to draw a sine wave
add 0.02 to Alt Val A
set Alt Val A to (Alt Val A) mod (2*[pi])
This part is yielding the expected results
The part which DOESN'T work is
Sin(Alt Val A)*100
Rather than the expected rising-and-falling output, it's just producing a steadily rising number
The python equivalent (AFAICT) behaves correctly:
math.sin(VARIABLE)*100
n/a
|
UrbanMonk BRING BACK MITCH
Registered 07/07/2008
Points 49667
|
28th May, 2013 at 28/05/2013 19:54:21 -
I see multiple problems with your code.
First MMF 2 uses degrees not radians, so change 2*pi to 360.
Also remove the "add" action and just do:
set Alt Val A to (Alt Val A + 0.02) mod (360)
The "add" action isn't really useful anymore and is more or less there for compatibility with knp.
Now
sin(alt Val A)*100
should return a sine wave assuming you don't modify "alt Val A" at any other point in the application.
Edited by UrbanMonk
n/a
|
jamesh
Registered 28/02/2012 15:24:25
Points 381
|
28th May, 2013 at 28/05/2013 20:19:53 -
Originally Posted by -UrbanMonk-I see multiple problems with your code.
First MMF 2 uses degrees not radians, so change 2*pi to 360.
Also remove the "add" action and just do:
set Alt Val A to (Alt Val A + 0.02) mod (360)
The "add" action isn't really useful anymore and is more or less there for compatibility with knp.
Now
sin(alt Val A)*100
should return a sine wave assuming you don't modify "alt Val A" at any other point in the application.
Thanks - very useful information, esp the bit about degrees as opposed to radians.
the 0.02 definitely has to be changed and - we have a beautiful sine wave!
Thankyou very much.
n/a
|
jamesh
Registered 28/02/2012 15:24:25
Points 381
|
31st May, 2013 at 31/05/2013 02:33:51 -
if anyone's interested, this started out as a way of helping a ghost to move in my game, but has turned into this somewhere along the way: http://www.jameswhedges.com/digital/turtlemandalas.html
(warning large image files)
Edited by jamesh
n/a
|
|
|