Pigeons flying Demo

http://www.youtube.com/watch?feature=player_embedded&v=M4sAqqIt1qs

-- Pigeons flying

-- Use this function to perform your initial setup
--
-- The next block only to load the images into the Documents folder.
-- After the first start can be deletet or off with --[[ ..code .. ]]

function didGetImage1( theImage, status, head )
    saveImage("Documents:T1",theImage)
end
function didGetImage2( theImage, status, head )
   saveImage("Documents:T2",theImage)
end
function didGetImage3( theImage, status, head )
    saveImage("Documents:T3",theImage)
end
function didGetImage5( theImage, status, head )
    saveImage("Documents:T5",theImage)
end
function didGetImage6( theImage, status, head )
    saveImage("Documents:T6",theImage)
end
function didGetImage7( theImage, status, head )
    saveImage("Documents:T7",theImage)
end

    b1='https://dl.dropboxusercontent.com/u/19857700/T1.png'
    b2='https://dl.dropboxusercontent.com/u/19857700/T2.png'
    b3='https://dl.dropboxusercontent.com/u/19857700/T3.png'
    b5='https://dl.dropboxusercontent.com/u/19857700/T5.png'
    b6='https://dl.dropboxusercontent.com/u/19857700/T6.png'
    b7='https://dl.dropboxusercontent.com/u/19857700/T7.png'
    http.request(b1, didGetImage1 )
    http.request(b2, didGetImage2 )
    http.request(b3, didGetImage3 )
    http.request(b5, didGetImage5 )
    http.request(b6, didGetImage6 )
    http.request(b7, didGetImage7 )  
 -- End of block only to load the images into the Documents folder.
 -- After the first start can be deletet or off with --[[ ..code .. ]]

function setup()

  displayMode(FULLSCREEN)
     img1 = ("Documents:T5") --Street
     img2 = ("Documents:T7")  --VW
     img3 = ("Planet Cute:Tree Tall")  
     img4 = ("Documents:T6") --Ampel
    gox = 100
    speed = 10
    red=color(255,0,0)
    yellow=color(255,255,0)
    green=color(0,255,0)
    xt=0
    frameDelay = 10
    animation = Animation({"Documents:T1",
                          "Documents:T2",
                          "Documents:T3"}, 10)
    
    tweenObject = {x = -50, y = 350, rotation = 0}
    tween(10,tweenObject, {x = WIDTH + 700, y = 650, rotation = 15},
    {easing = tween.easing.quintInOut,loop = tween.loop.forever})
end

-- This function gets called once every frame
function draw()  
    gox = gox + speed
    if gox > 1200 then gox = -31 end 
    if gox > 400 and gox < 480 and s == true then speed = 0
    else speed = 10; end
    -- Do your drawing here
    --sprite(img1,WIDTH/2,HEIGHT/2,WIDTH*2,HEIGHT) --for iPad1
    sprite(img1,WIDTH/2,HEIGHT/2,WIDTH,HEIGHT) --for iPad4 Retina
    sprite(img2,gox,100,320,140)
    sprite(img3,1000,0,200,800)
    sprite(img4,495,200,116,375)
    xt=xt+5
    if xt > 1002 then xt = 0 end
    
    pushMatrix()
    translate(tweenObject.x,tweenObject.y)
    rotate(tweenObject.rotation)
    sprite("Documents:T3",-100,100)
    sprite("Documents:T3",-300,20)
    sprite("Documents:T3")
    popMatrix()   
    
    animation:draw(xt,600) 
  
 if (os.date("%S")) > ("00") and (os.date("%S")) < ("11") then fill(red) ellipse(500,340,40,40);
     noFill() ellipse(500,300,40,40);noFill() ellipse(500,260,40,40); s=true end
if (os.date("%S")) > ("10") and (os.date("%S")) < ("12")then fill(red) ellipse(500,340,40,40);
     fill(yellow) ellipse(500,300,40,40);noFill() ellipse(500,260,40,40);  s=true end
if (os.date("%S")) > ("11") and (os.date("%S")) < ("26")then noFill() ellipse(500,340,40,40);
     noFill() ellipse(500,300,40,40); fill(green) ellipse(500,260,40,40) ; s=false end   
if (os.date("%S")) > ("25") and (os.date("%S")) < ("27") then noFill() ellipse(500,340,40,40);
     fill(yellow) ellipse(500,300,40,40); noFill() ellipse(500,260,40,40); s=false end
if (os.date("%S")) > ("26") and (os.date("%S")) < ("41") then fill(red) ellipse(500,340,40,40);
     noFill() ellipse(500,300,40,40); noFill() ellipse(500,260,40,40) ; s=true end  
if (os.date("%S")) > ("40") and (os.date("%S")) < ("42") then fill(red) ellipse(500,340,40,40);
     fill(yellow) ellipse(500,300,40,40); noFill() ellipse(500,260,40,40) s=true end    
if (os.date("%S")) > ("41") and (os.date("%S")) < ("58") then noFill() ellipse(500,340,40,40);
     noFill() ellipse(500,300,40,40);fill(green) ellipse(500,260,40,40)  ; s=false end      
if (os.date("%S")) > ("57") and (os.date("%S")) < ("61") then noFill() ellipse(500,340,40,40);
     fill(yellow) ellipse(500,300,40,40);noFill() ellipse(500,260,40,40)  s=false end   
if (os.date("%S")) < ("01") then fill(red) ellipse(500,340,40,40);
     noFill() ellipse(500,300,40,40); noFill() ellipse(500,260,40,40)   s=true end
end

-- Animation class
Animation = class()
 
function Animation:init(frames, delay)
    self.frames = frames -- table of sprite names
    self.currentFrame = 1 -- the current frame
    self.frameDelay = delay -- how many iterations of main draw loop before changing frame
    self.count = 1 -- keeps track of iterations passed 
end
 
function Animation:draw(x, y)
    -- Increment the counter
    self.count = self.count + 1
    -- Check if frame should be updated
    if self.count > self.frameDelay then
        -- Reset count and increment current frame
        self.count = 1
        self.currentFrame = self.currentFrame + 1
        -- Check if we've reached the last frame
        if self.currentFrame > table.maxn(self.frames) then
            -- Back to first frame
            self.currentFrame = 1
        end
    end
    -- Draw correct frame
    sprite(self.frames[self.currentFrame], x, y) 
    sprite(self.frames[self.currentFrame], x-150, y+50) 
end
 

@matox Interesting.

I swear I’ve seen this before…

It uses part of the traffic light simulator @JakAttak

I think I’ve seen the birds before too… @matox, is this just a combination of two peoples work?

Yes, it is an evolution of Traffic Light. It was I am concerned about the automatic storage of images in the Documents folder.