I’m always really impressed at how small people can make their programs!
I want to post my code and see if anyone can tell me if there’s a way to make it as impressively compact as others I’ve seen here.
It’s a very simple adventure game that my daughter designed. I could just cut and paste it but it has a lot of custom art, and I don’t know how to share those things.
I gather this is what codea community will be for but it doesn’t seem totally ready yet.
It includes a Main class showing how to use the Loader class and a Data tab showing how to feed it the names and URLs of images to get.
(note: this class was specially designed to work with the URLs you get from ‘Copy Link’ on a shared Dropbox image. If you use a different site like imgur, I have a different class for that )
Dropbox is weird like that. You did your code right.
What Dropbox does when you access an image’s link is that it returns an HTML page with a preview, share links, and a download button.
You can get Dropbox to work right by opening the Dropbox page for you image, and copying the download link, not the page link, by long pressing the download button and selecting “copy.”
I believe you can also make it work by using the normal Dropbox link, but changing the website to dl.dropboxusercontent.com instead of dropbox.com
-- Request an image
function setup()
logoImage = nil
-- Request some data
http.request( 'https://dl.dropboxusercontent.com/s/r6wg8mn555l54n8/maxresdefault.jpg',
didGetImage )
end
-- Our callback function
function didGetImage( theImage, status, head )
logoImage = theImage
saveImage("Documents:Victory",logoImage)
end
function draw()
background(20,20,40)
if logoImage ~= nil then
sprite(logoImage, WIDTH/2,HEIGHT/2)
end
end
But it doesn’t for me. The image shows on the screen fine, but when I go to look in my documents folder it isn’t there. Have you checked your documents folder after running this?
Below is my entire actual main tab. I’m including everything, even the commented-out stuff, in case any of it happens to contain what I’m missing.
What am I doing wrong???
-- Main
-- A Day of Choices
--basic settings
supportedOrientations(LANDSCAPE_ANY)
displayMode(FULLSCREEN)
icon = readImage("Documents:Choices Icon")
saveImage("Project:Icon", icon)
-- Our callback function
function didGetImage( theImage, status, head )
logoImage = theImage
saveImage("Documents:Victory",logoImage)
end
--[[function draw()
background(20,20,40)
if logoImage ~= nil then
sprite(logoImage, WIDTH/2,HEIGHT/2)
end
end ]]
function setup()
logoImage = nil
-- Request some data
http.request( 'https://dl.dropboxusercontent.com/s/r6wg8mn555l54n8/maxresdefault.jpg',
didGetImage )
mainObject = MainObject()
-- used as needed to position things on screen
parameter.number("positionX",0,WIDTH)
parameter.number("positionY",0,HEIGHT)
parameter.number("widthX",0,WIDTH)
parameter.number("heightY",0,HEIGHT)
end
function draw()
mainObject:draw()
-- modify and uncomment the following to use it for positioning
-- sprite("Documents:choices cup big", positionX, positionY)
if logoImage ~= nil then
sprite(logoImage, WIDTH/2,HEIGHT/2)
end
end
function touched(touch)
mainObject:touched(touch)
end
I tried the code above, and it saved an image named Victory in the Documents folder. The size of the image was 1280x720. I had to comment out some code to get it to run, but it ran OK after that.
Well, I figured out why it wasn’t saving for me. Not enough space. My storage has been dangerously low the past few days, I have to get around to backing up and deleting a bunch of apps and photos again.