Created
January 16, 2018 16:30
-
-
Save Eroica/0315df05f6e736f42e02e5ae18d7c665 to your computer and use it in GitHub Desktop.
Revisions
-
Eroica created this gist
Jan 16, 2018 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,203 @@ --[[ DebutShot.love Version 1.0, January 15th, 2018 Copyright (C) 2018 Eroica This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 3. This notice may not be removed or altered from any source distribution. ]] local flux = require "flux" math.randomseed(os.time()) local ROTATION = -2*math.pi local DRIBBBLE_COLORS = { {r = 0, g = 182, b = 227}, {r = 51, g = 51, b = 51}, {r = 58, g = 139, b = 187}, {r = 234, g = 76, b = 137}, } local function create_gizmo (drawable, l, t, angle, alpha) local color = DRIBBBLE_COLORS[math.random(1, #DRIBBBLE_COLORS)] return { drawable = drawable, r = color.r, g = color.g, b = color.b, angle = angle or math.random(0, 360)*math.pi/180, alpha = alpha or 0, l = l, t = t, sx = 1, sy = 1, } end local ANDROID local ANDROID_HEAD local DRIBBBLE_TEXT local BACKGROUND = { r = 0, g = 0, b = 0 } local gizmos = {} local function move_android_head () flux.to(ANDROID_HEAD, 1, {angle = 25*math.pi*2/360, t = ANDROID_HEAD.t - 10}):ease("quadout") :after(1, {t = ANDROID_HEAD.t + 10}):ease("quadout") :oncomplete(move_android_head) end function love.load (arg) love.window.setMode(800, 600, {borderless = true}) ANDROID = create_gizmo(love.graphics.newImage("android_1.png"), 400-64, 300 - 32, 0, 1) ANDROID_HEAD = create_gizmo(love.graphics.newImage("android_head.png"), 400 - 5, 300+20, 20*math.pi*2/360, 1) DRIBBBLE_TEXT = create_gizmo(love.graphics.newImage("dribbble_text.png"), 32*11 - 16, -32, 0, 1) DRIBBBLE_TEXT.r, DRIBBBLE_TEXT.g, DRIBBBLE_TEXT.b = 255, 255, 255 local ANDROID_colored = love.graphics.newImage("android_2.png") local ANDROID_HEAD_colored = love.graphics.newImage("android_head_2.png") local drawables = { love.graphics.newImage("circle.png"), love.graphics.newImage("star.png"), love.graphics.newImage("dribbble.png"), love.graphics.newImage("heart.png"), love.graphics.newImage("robot.png") } -- Add some holes to the checkboard pattern local skip_table = { [7*26 + 11] = true, [7*26 + 12] = true, [7*26 + 13] = true, [7*26 + 14] = true, [9*26 + 11] = true, [9*26 + 12] = true, [9*26 + 13] = true, [9*26 + 14] = true, [10*26 + 11] = true, [10*26 + 12] = true, [10*26 + 13] = true, [10*26 + 14] = true, [11*26 + 11] = true, [11*26 + 12] = true, [11*26 + 13] = true, [11*26 + 14] = true, [12*26 + 11] = true, [12*26 + 12] = true, [12*26 + 13] = true, [12*26 + 14] = true, } -- Prepare group of rows, columns, and rectangles local rows, columns, rects = {}, {}, {} for i=1, 20 do rows[#rows + 1] = {} end for i=1, 26 do columns[#columns + 1] = {} end for i=1, 12 do rects[#rects + 1] = {} end -- Create a checkboard pattern of drawables (gizmos) for i=0, 26*20 - 1 do if skip_table[i] == nil then local gizmo = create_gizmo(drawables[i % 5 + 1], (i%26)*32, 16 + math.floor(i/26)*32 - 16) gizmos[#gizmos + 1] = gizmo local current_row = math.floor(i/26 + 1) local current_column = math.floor(i%26 + 1) rows[current_row][#rows[current_row] + 1] = gizmo columns[current_column][#columns[current_column] + 1] = gizmo end end -- Let some appear for i=1, #gizmos do if math.random(1, 8) == 1 then flux.to(gizmos[i], 2, {alpha = 1}):delay(1) end end -- Let dribbble fall down, brighten background flux.to(DRIBBBLE_TEXT, 2, {t = 32*6 + 16}):ease("elasticout"):delay(3) flux.to(BACKGROUND, 1, {r = 255, g = 255, b = 255}):delay(5) flux.to(DRIBBBLE_TEXT, 1, {r = 234, g = 76, b = 137}):delay(5) -- Columns for i=1, #columns do for j=1, #columns[i] do column_appear = DRIBBBLE_COLORS[i % #DRIBBBLE_COLORS + 1] column_appear.alpha = 1 flux.to(columns[i][j], 2, column_appear):delay(5) end end -- Stripes local row_appear for i=1, #rows do for j=1, #rows[i] do flux.to(rows[i][j], 0, DRIBBBLE_COLORS[i % #DRIBBBLE_COLORS + 1]):delay(6 + i*j/200) end end -- Column groups local color local frame = 0 for i=1, #columns do for j=1, #columns[i] do flux.to(columns[i][j], 0, DRIBBBLE_COLORS[math.floor(i/4) % 4 + 1]):delay(8+i/10) :onupdate(function () frame = frame + 1 if frame == 255 then ANDROID.drawable = ANDROID_colored ANDROID_HEAD.drawable = ANDROID_HEAD_colored end end) end end -- Animate Android flux.to(ANDROID, .5, {t = ANDROID.t + 30, sy = 0.8}):ease("cubicout"):delay(3.15) :after(.5, {t = ANDROID.t, sy = 1}):ease("cubicout"):delay(.5) flux.to(ANDROID_HEAD, 1, {angle = 50*math.pi*2/360, l = ANDROID_HEAD.l + 10, t = ANDROID_HEAD.t - 5}):ease("cubicout"):delay(2) :after(.25, {angle = 20*math.pi*2/360, l = ANDROID_HEAD.l + 0, t = ANDROID_HEAD.t + 15}):delay(.15) :after(.5, {angle = 25*math.pi*2/360, l = ANDROID_HEAD.l + 4, t = ANDROID_HEAD.t - 6}):delay(.75) :after(1, {angle = 0, l = ANDROID_HEAD.l - 2, t = ANDROID_HEAD.t - 2}):delay(6) end function love.update (dt) ROTATION = math.min(ROTATION + dt, 2*math.pi) if ROTATION == 2*math.pi then ROTATION = -2*math.pi end flux.update(dt) end function love.draw () love.graphics.setBackgroundColor(BACKGROUND.r, BACKGROUND.g, BACKGROUND.b) local gizmo for i=1, #gizmos do gizmo = gizmos[i] love.graphics.setColor(gizmo.r, gizmo.g, gizmo.b, gizmo.alpha * 255) love.graphics.draw(gizmo.drawable, gizmo.l, gizmo.t, gizmo.angle + ROTATION, gizmo.sx, gizmo.sy, 16, 16) end love.graphics.setColor(DRIBBBLE_TEXT.r, DRIBBBLE_TEXT.g, DRIBBBLE_TEXT.b) love.graphics.draw(DRIBBBLE_TEXT.drawable, DRIBBBLE_TEXT.l, DRIBBBLE_TEXT.t) love.graphics.setColor(255, 255, 255, 255) love.graphics.draw(ANDROID.drawable, ANDROID.l, ANDROID.t, ANDROID.angle, ANDROID.sx, ANDROID.sy) love.graphics.draw(ANDROID_HEAD.drawable, ANDROID_HEAD.l, ANDROID_HEAD.t, ANDROID_HEAD.angle, 1, 1, 37, 33) end function love.keypressed (key, scancode, isrepeat) if key == "escape" then love.event.quit() end end