Skip to content
Browse files

Added 25 and the fractal 26

  • Loading branch information...
1 parent c747621 commit bb8f98ce0880353bda4c4229b104a1589f8a5837 @altuzar committed Nov 10, 2010
Showing with 69 additions and 0 deletions.
  1. BIN 25/letsgo.m4v
  2. +53 −0 25/main.lua
  3. BIN 25/sierpinski.png
  4. BIN 26/lavaFlow.m4v
  5. +16 −0 26/main.lua
View
BIN 25/letsgo.m4v
Binary file not shown.
View
53 25/main.lua
@@ -0,0 +1,53 @@
+--[[ Sierpinski, the example by Appsamuck.
+ http://appsamuck.com/day25.html
+ A fractal, built from the ground up! It's like infinite... Well, not really.
+ ]]
+
+-- Goodbye Status Bar
+display.setStatusBar( display.HiddenStatusBar )
+
+-- Width, Height with shortcuts
+local w,h = display.contentWidth, display.contentHeight
+
+-- Some vars, taken directly from Appsamuck. Hope it works.
+local x = 140;
+local y = 140;
+local c = 0;
+local n = 0;
+
+-- Create the line var outside of the loop. Maybe is a little faster
+local line
+
+-- Here comes the fractal
+while c < 100000 do
+ line = display.newLine( x+10, 10+240-y, x+10+1, 10+240-y+1 )
+ -- This set color was problematic for me, because in the original
+ -- it's a float 0-1.0, and here an int 0-255
+ line:setColor( y/140 * 255, (140-x)/140 * 255, x/140 * 255, 255 )
+ line.width = 1
+
+ n = math.random(0,999)
+
+ if n < 333 then
+ x = .5 * (x+300)
+ y = .5 * y
+ elseif n > 666 then
+ x = .5 * (x + 140)
+ y = .5 * (y + 240)
+ else
+ x = x * .5
+ y = y * .5
+ end
+
+ c = c + 1
+end
+
+-- A nice grafitti at the bottom
+local label = display.newImage( "sierpinski.png" )
+label.x = w / 2
+label.y = h * .75
+
+-- Some music with a loop
+media.playSound( 'letsgo.m4v', true )
+
+
View
BIN 25/sierpinski.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
View
BIN 26/lavaFlow.m4v
Binary file not shown.
View
16 26/main.lua
@@ -0,0 +1,16 @@
+--[[ LavaFlow, the example by Appsamuck.
+ http://appsamuck.com/day26.html
+ I still don't have a code signature for iPhone, so couldn't try out this little code properly.
+ Sorry about that! But as soon as I have one, I'll check this code. Promise!
+ ]]
+
+-- Goodbye Status Bar
+display.setStatusBar( display.HiddenStatusBar )
+
+-- When the video is over, this is triggered.
+local onComplete = function(event)
+ print( "video session ended" )
+end
+
+-- Here comes the little video.
+media.playVideo( "lavaFlow.m4v", false, onComplete )

0 comments on commit bb8f98c

Please sign in to comment.
Something went wrong with that request. Please try again.