fake hacked ipad

Here is a little joke i’ve made for interlude.
The idea is to make your wife/dad/friend think his ipad is being hacked.
Here is the video:

(video record currently broken, i’ll post later).

I’ll put the code in next post, but there is a problem: you will have to work a little bit to see this running. You must create two screenshot images and import them in codea, with correct names. (I cannot load these images for some pb with retina images).
Here are the names:

    splashScreenEmpty -- link to your empty screen shot
    splashScreenFull -- link to your filled up screen shot

One image should be the favorite screen of your friend, with many apps: (splashScreenFull)

The other image should contain only one app, i need it for background: (splashScreenEmpty)

Then run the code. It will download 1 more image and restart. Then tap the pulsing icon, with sound at max volume to see the effect. For fooling your friend, you’ll have to manage having him tap the icon himself, but i’ll leave that to you…

Ho, and to close the app, click the home button and kill codea manually.


--# Screen
Screen = class()

function Screen:save(img,name)
    print("saving "..name)
    saveImage(name, img)
    restart()
end
function Screen:load(url,name)
    print("requesting "..name)
    http.request(url,function(data) self:save(data,name) end)
end

function Screen:loadImages()
    displayMode(STANDARD)
    print("Images must be loaded first")
    add0 = "https://dl.dropbox.com/s/0qbo6ldqmarj5vq/Photo%2022-09-2014%2023%2010%2049.png"
    name0 = "Documents:splashScreenEmpty"
    add1 = "https://dl.dropbox.com/s/k6i9sa7fyp75olg/Photo%2022-09-2014%2023%2009%2000.png"
    name1 = "Documents:splashScreenFull"
    add3 = "https://dl.dropbox.com/s/ufmcvxshppo2d3f/Photo%2023-09-2014%2021%2057%2023.jpg"
    name3 = "Documents:pirate"
--    self:load(add0,name0)
--    self:load(add1,name1)
    self:load(add3,name3)
end

function Screen:readImages()
    ready = true
    self.pirate = readImage("Documents:pirate")
    if not self.pirate then
        ready = false
        self:loadImages()
    end
    self.img0 = readImage("Documents:splashScreenEmpty") -- link to your empty screen shot
    self.img1 = readImage("Documents:splashScreenFull")-- link to your filled up screen shot
    if not ( self.img0 and self.img1 )then
        ready = false
        print("create your screenshots first")
    end
end

function Screen:init()
    self:readImages() 
    if ready then
        view = self.img0
        self.floor = physics.body(EDGE, vec2(0,0), vec2(WIDTH,0) )
        self.left = physics.body(EDGE, vec2(0,0), vec2(0,HEIGHT) )
        self.right = physics.body(EDGE, vec2(WIDTH,0), vec2(WIDTH,HEIGHT) )
        self.roof = physics.body(EDGE, vec2(0,HEIGHT), vec2(WIDTH,HEIGHT) )
    else
       
    end
end

function Screen:draw()
    physics.gravity( Gravity )
    background(40, 40, 50)
    spriteMode(CORNER)
    sprite(view,0,0,WIDTH,HEIGHT)
end

function Screen:touched(touch)
    -- Codea does not automatically call this method
end

--# Bloc
Bloc = class()

function Bloc:init(x,y,w,h,alpha)
    self.x = x
    self.y = y
    self.w = w
    self.h = h
    self.alpha = alpha
    self.angle = 0
    if self:initImg() then
        self:initBody()
    end
end

function Bloc:initBody()
    local w,h = self.w/2, self.h/2
    local x,y = self.x, self.y
    self.body = physics.body( POLYGON, vec2(x-w, y-h), vec2(x+w, y-h), vec2(x+w, y+h), vec2(x-w, y+h) )
    self.body.type = DYNAMIC
    self.body.sleepingAllowed = false
    self.body.restitution = 0.8
    self.body.active = false
end

local abs = math.abs
local function eq(a,b)
    if abs(a-b)<15 then return true else return false end
end

function Bloc:initImg()
    local x,y,w,h = self.x, self.y,self.w, self.h
    local img0 = screen.img0:copy( x-w/2, y-h/2, w, h )
    local img1 = screen.img1:copy( x-w/2, y-h/2, w, h )
    local n = 0
    for i = 1,img1.width do
        for j = 1,img1.height do
            local r0,g0,b0,a0 = img0:get(i,j)
            local r1,g1,b1,a1 = img1:get(i,j)
            if eq(r0,r1) and eq(g0,g1) and eq(b0,b1) and eq(a0,a1) then
                if self.alpha then img1:set(i,j,0,0,0,0) end
            else
                n = n + 1
            end
        end
    end
    self.img = img1
    local notEmpty = (n>30)
    return notEmpty
end

local cosRad = math.cos
local sinRad = math.sin
local rad = math.rad
local function cos(a) return cosRad(rad(a)) end
local function sin(a) return sinRad(rad(a)) end

function Bloc:update()
    if not self.body then return end
    local c = self.body.worldCenter
    local a = self.body.angle
    self.angle = a
    self.x = c.x 
    self.y = c.y
end
function Bloc:draw()
    if not self.body then return end
    self:update()
    fill(0,0)
    stroke(255)
    strokeWidth(1.5)
    rectMode(CENTER)
    spriteMode(CENTER)
    resetMatrix()
    translate(self.x, self.y)
    rotate(self.angle)
 --  rect(0,0, self.w, self.h)
    sprite(self.img,0,0,self.w,self.h)
end

function Bloc:touched(t)
    if abs(t.x-self.x)<self.w/2 and abs(t.y-self.y)<self.h/2 then
        return true
    end
end

--# Blocs
Blocs = class()

function Blocs:init()
    local b
    local dx,dy = 196, -141
    -- app name
    self.names = {}
    local x0,y0 = 120, HEIGHT-168+15
    for i = 0,4 do 
        for j = 0,3 do
            b = Bloc(x0+i*dx, y0+j*dy, 100, 30 )
            if b.body then table.insert(self.names, b ) end
        end
    end 
    -- app icon
    self.icons = {}
    local x0,y0 = 120, HEIGHT-98
    for i = 0,4 do 
        for j = 0,3 do
            b = Bloc(x0+i*dx, y0+j*dy, 80, 80, true)
            if b.body then table.insert(self.icons, b ) end
        end
    end 
    
    -- trigger
    self.button = self.icons[1]
    self.button.tween = tween(0.25,self.button ,{w=100,h=100},{loop=tween.loop.pingpong})

    -- final button
    self.pirate = Bloc(x0, y0-12, 30, 30, false)
    self.pirate.img = screen.pirate
--    self.pirate.body.active = false
    
    -- black screen
    self.black = {}
    local b = self.black
    b.x = 0
    b.y = HEIGHT
    b.w = WIDTH
    b.h = 0
    function b:draw()
        resetMatrix()
        noSmooth()
        noStroke()
        rectMode(CORNER)
        fill(0)
        rect(self.x,self.y,self.w,self.h)
    end
end

function Blocs:draw()
    self.pirate:draw()
    for _,b in pairs(self.names) do b:draw() end
    for _,b in pairs(self.icons) do b:draw() end
    self.black:draw()
end

function Blocs:touched(t)
    --for _,b in pairs(self.list) do b:touched(t) end
    if self.button:touched(t) then
        if t.state == BEGAN and not self.button.done then
            self:die()
            self.button.done = true
            tween.reset( self.button.tween )
            self.pirate.w = 120
            self.pirate.h = 96
            tween(0.5,self.pirate ,{w=200,h=160},{loop=tween.loop.pingpong})
        end
    end
end

function Blocs:die()
    sound("A Hero's Quest:Bottle Break 1")
    local t = -1
    for i=1,#self.icons do
        t = t + 3/(2+i)
        tween.delay(t,function()
            sound("Game Sounds One:Pop 1")
            local a = 5000
            local b
            b = self.icons[i].body
            if b then
                b.active = true
                b:applyForce(vec2(math.random(-a,a),math.random(-a,a)))
            end
            
            b = self.names[i].body
            if b then
                b.active = true
                b:applyForce(vec2(math.random(-a,a),math.random(-a,a)))
            end
        end)
    end
    
        t = t + 1
        tween.delay(t,function()
            sound("Game Sounds One:Male Cheer 3")
        end)
    
        t = t + 1
        tween.delay(t,function()
            music("Game Music One:Sci Fi Workshop")
        end)
        local dt=7
        tween.delay(t,function()
            tween(dt, self.black,{ y=0, h=HEIGHT})
        end)
        t = t + dt + 2
        tween.delay(t,function()
            music.stop()
            sound("Game Sounds One:Zapper 2")
        end)

end

--# Main
-- joke
supportedOrientations(LANDSCAPE_ANY)
displayMode(FULLSCREEN_NO_BUTTONS)

function setup()
    screen = Screen()
    if ready then blocs = Blocs() end
end


function draw()
    if not ready then return end
    screen:draw()
    blocs:draw()
end

function touched(t)
    if not ready then return end
    blocs:touched(t)
end


@Jmv38, sweet! 1 little thing to mention tho… if there’s a notification (like facebook, having the red number on it) it cuts the number off for a bit (not in the ‘hotbar’ tho)

also… to exit the app… just triple tap with 3 fingers and you get the codea buttons :wink:

but nice app, I like it :stuck_out_tongue:
(also… is it meant that the screen just turns black after a while?)

@stevon8ter wow you are fast!
Yeah, it is on purpose it gets black: because your ipad is DEAD! HA HA HA!
how do you like the sounds?
Do you think the trick will really work? (i mean scaring your friend?)

@Jmv38 it might work with some people, but it won’t work with all people, but I really like it :stuck_out_tongue: it’s just a matter on how you bring it to your friends (as you said)

en the music sounds… really ‘bad’ when you see your ipad going dead like that… :frowning:

(bad = good in this context :stuck_out_tongue: )