Critter

MisterX b.xavier at internet.lu
Sat Aug 21 23:22:12 EDT 2004


Cool. Here's the script I made last week that does
something similar! A bit smoother in movement thanks
to the speed differentiator. 

Then I tried yours by duplicating my oval. I just
pasted your script and even in development mode, I
had my graphic follow yours! ;) Im also working on
bouncing, gravity, friction and elasticity.

This could be the start of a cool video game!

on mousedown
  put 12 into xspeed
  put 12 into yspeed
  
  put the width of me into mW
  put the height of me into mH
  put mW div 2 into mW2
  put mH div 2 into mH2
  put the mouseh - left of me into xoff
  put the mousev - top of me into yoff
  put the width of this stack into stackwidth
    put the height of this stack into stackheight

  put the rect of this stack into limits
  lock messages
  
  repeat while the mouse is down
     
    put left of me + xoff into midx
    put top  of me + yoff into midy
    
    put the mouseh into nux
    put the mousev into nuy
     
    -- limit if out of 3dpane
     
    get the left of me
    add (nux - midx) / xspeed to it
    if it <= 1
    then get 1
    else if it + mw >= stackwidth
    then get stackwidth - mw
    set the left of me to it
    
    get the top of me
    add (nuy - midy) / yspeed to it
    if it <= 1
    then get 1
    else if it + mH >= stackheight
    then get stackheight - mH
    set the top of me to it 
     
  end repeat
end mousedown

> -----Original Message-----
> From: use-revolution-bounces at lists.runrev.com
> [mailto:use-revolution-bounces at lists.runrev.com]On Behalf Of Jim Lyons
> Sent: Sunday, August 22, 2004 04:18
> To: use-revolution at lists.runrev.com
> Subject: Critter
> 
> 
> Got time to play for a few minutes? Create a new stack and make an oval 
> graphic about 32 by 32 pixels. Set its arcAngle to about 330 degrees. 
> Set the _stack_ script to:
> 
> on mouseMove x,y
>    if x,y is within the rect of grc 1 then exit mouseMove
>    get the loc of grc 1
>    set the startAngle of grc 1 to \
>        -180*atan2( (y-item 2 of it),(x-item 1 of it) )/pi \
>        + (360 - the arcAngle of grc 1)/2
>    move grc 1 to x,y without waiting
> end mouseMove
> 
> Play with the move speed. Enjoy. Now get back to work. ;^)
> 
> Jim Lyons
> 
> _______________________________________________
> use-revolution mailing list
> use-revolution at lists.runrev.com
> http://lists.runrev.com/mailman/listinfo/use-revolution


More information about the use-livecode mailing list