License from €75 Log in
DE EN FR ES IT CZ

LUA: Turning the wheels of a windmill

This thread is a few years old. Some details may refer to an earlier version of Visionaire Studio. Current tutorials

  1. · 14 years ago
    How would it be possible with LUA to "turn" something... lets say the wheel of a windmill. smile
  2. Working on a game?

    The free version covers up to 25 scenes per project. For more scenes and to sell your game, you need a license.

    See licenses Try it for free
  3. · 14 years ago
    currently we have no support for rotation as far as I know...
    if we could add some of the Löve 2D framework libraries/functions then would be possible I suppose as they have a couple functions for rotation & all their code/lib files are open source.

    I have no idea how to include & use them though.

    but anyway you can usually animate something turning in a few frames.
    you really only have to animate the first spoke of things like windmills - the point between one blade until it's just before position of the last & then loop. usually only need maybe 3-5 frames. Well providing the thing rotating isn't covered in debris, graffiti or vegetation etc. You could also get away with creating the animation in layers too so that the images for the animation aren't as big.
  4. · 14 years ago
    There was a compass script "einzelkaempfer" did a while ago. There is a turning, rotating compass needle. How could he arrange that?
  5. · 14 years ago
    hmm...

    it doesn't rotate, it uses a lot of frames of which (I haven't gone over the script, but I'm assuming) it selects the frame to display based on a calculation of where the mouse cursor is on the screen.

    -- Interface
    comp_interface = getObject("Interfaces[Kompass]")
    
    -- Lokale Interface-Koordinaten des Kompassnadel-Drehpunktes
    rot_point = {55;85}
    
    -- Anzahl Sprites
    num_sprites = 64
    
    -- Geschwindigkeit (1=sofort; je größer, je langsamer)
    rot_speed = 5
    
    
    
    
    ---------------------------------------
    
    -- Aktuelle Position des Kompasses
    pos_compass = {0;0}
    
    -- Aktueller Winkel
    curr_angle = 0
    

    --Dreht die Kompassnadel in Richtung des Mauszeigers
    function spinNeedle()
       local pos_cursor = getCursorPos()
    
       local target_angle = math.atan2(pos_compass[2] - pos_cursor.y, pos_compass[1] - pos_cursor.x) / math.pi * 180
       local rot_angle = target_angle - curr_angle
       if rot_angle <= -180 then
          rot_angle = 360 + rot_angle
       elseif rot_angle > 180 then
          rot_angle = 360  - rot_angle
       end
       curr_angle = curr_angle + rot_angle / rot_speed
    
       if curr_angle < 0 then
          curr_angle = 360 + curr_angle
       elseif curr_angle >= 360 then
          curr_angle = curr_angle - 360
       end
       local call_frame = math.floor(curr_angle / 360 * num_sprites + 0.5) + 1
       if call_frame == 65 then call_frame = 1 end
    
       comp_anim:setValue(VAnimationFirstFrame, call_frame)
       comp_anim:setValue(VAnimationLastFrame, call_frame)
    end
    
    
    -- Speichert die Position des Kompass-Drehpunktes in einer globalen Variable
    function setRotationPoint()
       local int_pos = comp_interface:getPoint(VInterfacePosition)
       pos_compass = {int_pos.x + rot_point[1];int_pos.y + rot_point[2]}
    end
    


    P.S: we need something like this: http://love2d.org/wiki/love.graphics.rotate
    mind you there's loads of useful sounding stuff listed for the framework! check out all the stuff just for graphics: http://love2d.org/wiki/love.graphics
    • Image in post
  6. · 14 years ago
    Isnt it possible to implement an external library via lua?
  7. · 14 years ago
    better off asking Alex about that wink

This thread is closed because nobody has replied for more than a year. Feel free to ask your question in a new thread.

New thread

Really delete this post?