Aller au contenu


Submitter

File Information

  • Submitted: juil. 13 2009 16:49
  • Last Updated: juil. 13 2009 16:49
  • File Size: 2,69 Ko
  • Views: 8
  • Downloads: 1

Download Fireworks v0.2 pour DJSP

- - - - -



--  2 dimesional table for all stream variables
-- [1][x] = x value
-- [2][x] = y value
-- [3][x] = oldstreamx
-- [4][x] = oldstreamy
-- [5][x] = length
-- [6][x] = increment
-- [7][x] = newstream
-- [8][x] = initx,
-- [9][x] = inity,
-- [10][x] = velocityx,
-- [11][x] = velocityy,
-- [12][x] = color

--             1,2,3 ,4,5,6 ,7,8,9,10,11,12
stream = {{},{},{},{},{},{},{},{},{},{},{},{}}

readControls(1)
useFlipScreen(true)
disableDJSPControls()

color1 = rgb(255,255,255)
color2 = rgb(255,50,50)
black = rgb(0,0,0)

colorscheme = 3
streamangle = 0
x = 239
y = 135
i = 1
q = 8
gravityy = 5
gravityx = -5
runonce = true
maxstreamlength = 250
streamstartvalue = 5
speed = 13
streamcount = 40
renderedstreamcount = streamcount
analyzeAudio()
energy = getEnergy()*18
mag = getMagnitudes()
colorchange = 0
colorred = 0
colorgreen = 0
colorblue = 0
generatecolor = 1
cg = 6
drawmode = 9



--The main program loop.  Currently will run forever
---------------------------------------------------------------------------------
while true do

  -- initialise all values in the main table, it only runs once during the entire program using the runonce variable
  -------------------------------------------------------------------------------------------------------------------------------------------------------------------
  if (runonce) then
  while (i<streamcount) do  
  stream[1][i] = 0
  stream[2][i] = 0
  stream[3][i] = 0
  stream[4][i] = 0
  stream[5][i] = 0
  stream[6][i] = 0
  stream[7][i] = true
  stream[8][i] = x
  stream[9][i] = y
  stream[12][i] = rgb(255,255,255)
  streamangle = 0
  i=i+1
  
  end
  runonce = false
  end


  -- All control related code
  -------------------------------------
  readControls(1)

  -- Analog control related code.  Analog stick control the x,y position
  ---------------------------------------------------------------------------------------------------------
  xana = analogX()*80
  yana = analogY()*80
  
  if ((xana>15)or(xana<-15)) then
  x = x+(xana/6)
  end
  if ((yana>15)or(yana<-15)) then
  y = y+(yana/6)
  end
  
  if (x>478) then
  x=0
  end
  if (y>270) then
  y=0
  end
  if (x<0) then
  x = 478
  end
  if (y<0) then
  y = 270
  end


  -- Dpad button control related code.  Up, Down, Left, Right control x and y gravity
  ------------------------------------------------------------------------------------------------------------------------
  if (downPressed()) then
  gravityy = gravityy + 1
  end
  if (upPressed()) then
  gravityy = gravityy - 1
  end
  if (leftPressed()) then
  gravityx = gravityx - 1
  end
  if (rightPressed()) then
  gravityx = gravityx + 1
  end


  -- Other button control related code.  Square, Cirlce control variable q, and Triangle and Cross control Speed
  ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
  if (squarePressed()) then
  q = q + 1
  end
  if (circlePressed()) then
  q = q - 1
  end
  if (trianglePressed()) then
  speed = speed + 1
  end
  if (crossPressed()) then
  speed = speed - 1
  end


  -- Misc other button control related code.  Cross and Triangle at the same time to quit back to DJSP, Left Trigger chages colorscheme, although currently disabled
  ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  if crossPressed() and trianglePressed() then
  wait(500000)
  enableDJSPControls()
  return
  end
  if ltriggerPressed() then
  drawmode = drawmode+1
  if (drawmode>9) then
  drawmode = 1
  end
  end



  -- Start the audio analyzing.  Energy is times by itself a few times to 'exponentialise' it
  ----------------------------------------------------------------------------------------------------------------------------------------
  if audioPlaying() then
  analyzeAudio()
  energy = getEnergy()*3
  if enegy == 3 then
  energy = 0
  end
  energy = energy*energy*energy*energy
  mag = getMagnitudes()
  end

  
  
  

  -- Update the positions of all the streams.  The newstream loop is for streams that have expired.  It gives them a new angle and TTL. The angle in this version is based
  -- on the 'energy' from the audio playing.  The color is also set in the newstream code block.  The rest of this code block is for the updating of the positions of each stream.
  -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
  while (i < renderedstreamcount) do
  if (stream[7][i]) then
  streamangle = streamangle + energy
  if streamangle > 3600 then
  streamangle = 0
  end
  if streamangle < 0 then
  streamangle = 360
  end
  stream[1][i] = 0
  stream[2][i] = 0
  stream[5][i] = math.random(streamstartvalue,maxstreamlength)
  stream[7][i] = false
  stream[8][i] = x
  stream[9][i] = y
  stream[10][i] = ((math.sin(math.rad(streamangle)))*50)
  stream[11][i] = ((math.cos(math.rad(streamangle)))*50)


  -- This section is dedicated to the flow of the color.  Was more difficult than I had inistally thought
  -----------------------------------------------------------------------------------------------------------
  cg = mag[i]*5
  cg=cg*cg*cg
  if generatecolor == 1 then
  colorred = colorred + cg
  end
  if generatecolor == 2 then
  colorblue = colorblue - cg
  end
  if generatecolor == 3 then
  colorgreen = colorgreen + cg
  end
  if generatecolor == 4 then
  colorred = colorred -cg
  end
  if generatecolor == 5 then
  colorblue = colorblue + cg
  end
  if generatecolor == 6 then
  colorgreen = colorgreen - cg
  end
  if colorred>254 and generatecolor == 1 then
  generatecolor = 2
  end
  if colorblue<1 and generatecolor == 2 then
  generatecolor = 3
  end
  if colorgreen>254 and generatecolor == 3 then
  generatecolor = 4
  end
  if colorred<1 and generatecolor == 4 then
  generatecolor = 5
  end
  if colorblue>254 and generatecolor == 5 then
  generatecolor = 6
  end
  if colorgreen<1 and generatecolor == 6 then
  generatecolor = 1
  end
  if colorred>255 then
  colorred = 255
  end
  if colorgreen>255 then
  colorgreen = 255
  end
  if colorblue>255 then
  colorblue = 255
  end
  if colorred<0 then
  colorred = 0
  end
  if colorgreen<0 then
  colorgreen = 0
  end
  if colorblue<0 then
  colorblue = 0
  end
  stream[12][i] = rgb(colorred,colorgreen,colorblue)
  
  end
  
  stream[3][i] = stream[1][i]
  stream[4][i] = stream[2][i]
  
  stream[1][i] = stream[1][i] + stream[10][i]

  stream[2][i] = stream[2][i] + stream[11][i]

  stream[10][i] = stream[10][i] + gravityx
  stream[11][i] = stream[11][i] + gravityy

  stream[6][i] = stream[6][i] + speed
  if (stream[6][i]>stream[5][i] ) then
  stream[6][i] = streamstartvalue
  stream[7][i] = true
  end
  i = i + 1
  end
  i = 1


  -- Basically this is the start of rendering all of the above calculated streams to screen
  ----------------------------------------------------------------------------------------------------------------------------------------
  clearScreen()
  drawPixel(x, y, color1)
  while (i<renderedstreamcount) do
  if drawmode==1 then
  renderedstreamcount = streamcount
  drawLine(stream[8][i]+(stream[1][i]/q), stream[9][i]+(stream[2][i]/q), stream[8][i]+(stream[3][i]/q), stream[9][i]+(stream[4][i]/q), stream[12][i])
  elseif drawmode ==2 then
  renderedstreamcount = streamcount
  if stream[4][i]>stream[2][i] then
  drawRectangle(stream[8][i]+(stream[1][i]/q), stream[9][i]+(stream[2][i]/q), stream[8][i]+(stream[3][i]/q), stream[9][i]+(stream[4][i]/q), stream[12][i],stream[12][i])
  else
  drawRectangle(stream[8][i]+(stream[1][i]/q), stream[9][i]+(stream[4][i]/q), stream[8][i]+(stream[3][i]/q), stream[9][i]+(stream[2][i]/q), stream[12][i],stream[12][i])
  end
  elseif drawmode ==3 then
  drawRectangle(stream[8][i]+(stream[1][i]/q), stream[9][i]+(stream[4][i]/q), stream[8][i]+(stream[3][i]/q), stream[9][i]+(stream[2][i]/q), stream[12][i])
  elseif drawmode ==4 then
  renderedstreamcount = streamcount/2
  if stream[4][i]>stream[2][i] then
  drawRectangle(stream[8][i]-(stream[1][i]/q)-100, stream[9][i]-(stream[2][i]/q), stream[8][i]-(stream[3][i]/q)-100, stream[9][i]-(stream[4][i]/q), stream[12][i],stream[12][i])
  drawRectangle(stream[8][i]+(stream[1][i]/q)+100, stream[9][i]+(stream[2][i]/q), stream[8][i]+(stream[3][i]/q)+100, stream[9][i]+(stream[4][i]/q), stream[12][i],stream[12][i])
  else
  drawRectangle(stream[8][i]-(stream[1][i]/q)-100, stream[9][i]-(stream[4][i]/q), stream[8][i]-(stream[3][i]/q)-100, stream[9][i]-(stream[2][i]/q), stream[12][i],stream[12][i])
  drawRectangle(stream[8][i]+(stream[1][i]/q)+100, stream[9][i]+(stream[4][i]/q), stream[8][i]+(stream[3][i]/q)+100, stream[9][i]+(stream[2][i]/q), stream[12][i],stream[12][i])
  end
  elseif drawmode ==5 then
  renderedstreamcount = streamcount/4
  drawRectangle(stream[8][i]+(stream[1][i]/q)-100, stream[9][i]+(stream[2][i]/q), stream[8][i]+(stream[3][i]/q)-100, stream[9][i]+(stream[4][i]/q), stream[12][i])
  drawRectangle(stream[8][i]-(stream[1][i]/q)+100, stream[9][i]-(stream[2][i]/q), stream[8][i]-(stream[3][i]/q)+100, stream[9][i]-(stream[4][i]/q), stream[12][i])
  drawRectangle(stream[8][i]+(stream[1][i]/q), stream[9][i]+(stream[2][i]/q)-100, stream[8][i]+(stream[3][i]/q), stream[9][i]+(stream[4][i]/q)-100, stream[12][i])
  drawRectangle(stream[8][i]-(stream[1][i]/q), stream[9][i]-(stream[2][i]/q)+100, stream[8][i]-(stream[3][i]/q), stream[9][i]-(stream[4][i]/q)+100, stream[12][i])
  elseif drawmode ==6 then
  renderedstreamcount = streamcount/4
  drawLine(stream[8][i]+(stream[1][i]/q), stream[9][i]+(stream[2][i]/q), stream[8][i]+(stream[3][i]/q), stream[9][i]+(stream[4][i]/q), stream[12][i])
  drawLine(stream[8][i]-(stream[1][i]/q), stream[9][i]-(stream[2][i]/q), stream[8][i]-(stream[3][i]/q), stream[9][i]-(stream[4][i]/q), stream[12][i])
  drawLine(stream[8][i]+(stream[1][i]/q)-100, stream[9][i]+(stream[2][i]/q), stream[8][i]+(stream[3][i]/q)-100, stream[9][i]+(stream[4][i]/q), stream[12][i])
  drawLine(stream[8][i]-(stream[1][i]/q)+100, stream[9][i]-(stream[2][i]/q), stream[8][i]-(stream[3][i]/q)+100, stream[9][i]-(stream[4][i]/q), stream[12][i])
  drawLine(stream[8][i]+(stream[1][i]/q), stream[9][i]+(stream[2][i]/q)-100, stream[8][i]+(stream[3][i]/q), stream[9][i]+(stream[4][i]/q)-100, stream[12][i])
  drawLine(stream[8][i]-(stream[1][i]/q), stream[9][i]-(stream[2][i]/q)+100, stream[8][i]-(stream[3][i]/q), stream[9][i]-(stream[4][i]/q)+100, stream[12][i])
  elseif drawmode ==7 then
  renderedstreamcount = streamcount/2
  drawLine(stream[8][i]+(stream[1][i]/q), stream[9][i]+(stream[2][i]/q), stream[8][i]+(stream[3][i]/q), stream[9][i]+(stream[4][i]/q), stream[12][i])
  drawLine(stream[8][i]-(stream[1][i]/q), stream[9][i]-(stream[2][i]/q), stream[8][i]-(stream[3][i]/q), stream[9][i]-(stream[4][i]/q), stream[12][i])
  elseif drawmode ==8 then
  renderedstreamcount = streamcount/3
  drawLine(stream[8][i]+(stream[1][i]/q), stream[9][i]+(stream[2][i]/q), stream[8][i]+(stream[3][i]/q), stream[9][i]+(stream[4][i]/q), stream[12][i])
  drawLine(stream[8][i]-(stream[1][i]/q), stream[9][i]-(stream[2][i]/q), stream[8][i]-(stream[3][i]/q), stream[9][i]-(stream[4][i]/q), stream[12][i])
  drawRectangle(stream[8][i]+(stream[1][i]/q), stream[9][i]+(stream[2][i]/q), stream[8][i]+(stream[3][i]/q), stream[9][i]+(stream[4][i]/q), stream[12][i])
  drawRectangle(stream[8][i]-(stream[1][i]/q), stream[9][i]-(stream[2][i]/q), stream[8][i]-(stream[3][i]/q), stream[9][i]-(stream[4][i]/q), stream[12][i])
  elseif drawmode ==9 then
  renderedstreamcount = streamcount/6
  drawRectangle(stream[8][i]-(stream[1][i]/q), stream[9][i]+(stream[2][i]/q), stream[8][i]+(stream[3][i]/q), stream[9][i]-(stream[4][i]/q), stream[12][i],stream[12][i])
  drawRectangle(stream[8][i]+(stream[1][i]/(q*2))-50, stream[9][i]-(stream[2][i]/(q*2))+50, stream[8][i]-(stream[3][i]/(q*2))+50, stream[9][i]+(stream[4][i]/(q*2))-50, stream[12][i],stream[12][i])
  end
  i = i + 1
  end
  i = 1

  --if (colorscheme==1) then
  -- drawText("color: Blue",4,240, rgb(50,50,255),black)
  --elseif (colorscheme==2) then
  -- drawText("color: Green",4,240, rgb(50,255,50),black)
  --elseif (colorscheme==3) then
  -- drawText("color: Red",4,240, rgb(255,50,50),black)
  --else
  -- drawText("color: Greyscale",4,240, rgb(120,120,120),black)
  --end


  drawText("dr4g0n.net",4,4, rgb(30,30,30), black)
  --drawText("Red:"..colorred,4,190, color2, black)
  --drawText("Green:"..colorgreen,4,200, color2, black)
  --drawText("Blue:"..colorblue,4,210, color2, black)
  --drawText("q: "..q,4,220, color1,black)
  --drawText("speed: "..speed,4,230, color1,black)
  --drawText("gravityx: "..gravityx,4,250, color1,black)
  --drawText("gravityy: "..gravityy,4,260, color1,black)
  
  waitForVSync()
  flipScreen()
  wait(4000)
  
end






Other files you may be interested in ..





  • 4 891 Total Files
  • 401 Total Categories
  • 13 Total Authors
  • 294 778 Total Downloads
  • Xbox Backup Creator Latest File
  • Razkar Latest Submitter