Advertisement
Guest User

Untitled

a guest
Oct 20th, 2014
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 0.86 KB | None | 0 0
  1. -- Writing code like this is very convenient, let's make it work!
  2. function cutScene()
  3.     john:say( "What a sunny day" );
  4.     mary:say( "Wanna go fishing?" );
  5.     john:setAnim( "hesitation" );
  6.     wait( 2 );
  7.     john:say( "Ok" );
  8. end
  9.  
  10. function love.draw()
  11.     john:draw();
  12.     mary:draw();
  13.     dialogBox:draw();
  14. end
  15.  
  16. function love.load()
  17.     script = coroutine.create( cutScene );
  18. end
  19.  
  20. function love.update()
  21.     john:update();
  22.     mary:update();
  23.     dialogBox:update();
  24.     coroutine.resume( script );
  25. end
  26.  
  27. function wait( duration )
  28.    local start = timer.now();
  29.    while true do
  30.        if timer.now() > start + duration then
  31.             break;
  32.         else
  33.         coroutine.yield();
  34.     end
  35.    end
  36. end
  37.  
  38. function say( text )
  39.     dialogBox:startDisplaying( text );
  40.     while not dialogBox:finishedDisplaying() do
  41.     coroutine.yield();
  42.     end
  43. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement