On first run, the program will download the needed media files from off my website (I don't do Dropbox). It shouldn't take long at all. After that the screen saver will run.
While playing, touch the sides of the screen to cycle through the midi song files. Left side goes backwards, right side goes forward to next song. Touch any other area of screen exits the program.
All media files were found in public domain. Hope you enjoy this and have a (belated) Merry Christmas.
- Dav
Code: Select all
'snowman.txt v1.0
'A Snowman Screensaver (ipad/iphone)
'Coded by Dav DEC/2016 - for Christmas.
'Visit my site at: http://www.qbasicnews.com/dav
'Shows a winter scene animation while playing
'17 Christmas songs in the background. Something
'nice to look at & listen to on Christmas.
'Put on your table/desk to create holiday mood.
'ALL MEDIA FILES WERE FOUND IN PUBLIC DOMAIN.
'==============================================
'PLAYING CONTROLS...skipping songs...quitting
'Touch the left side of screen to go backward
'through the song list (play previous song).
'Touch right side of screen to move forward to
'the next song.
'Touch the middle of screen to end program.
'==============================================
'NOTE: ON FIRST RUN THIS PROGRAM WILL ATTEMPT
'TO DOWNLOAD NEEDED MEDIA FILES FROM MY WEBSITE.
'THIS WILL ONLY NEED TO BE DONE ONCE.
'==============================================
'flag to control background music. 1=on,0=off
music=1 'music will play during animation
option base 1
set toolbar off
set orientation left
get screen size sw,sh
option screenlock off
'make the list of 17 .mid files
songmax= 17
dim song$(songmax)
for t=1 to songmax
a$=str$(t)!if len(a$)=1 then a$="0"&a$
song$(t)=a$&".mid"
next t
'see if media files present first
gosub checkinstall
graphics
graphics clear 0,0,0
draw text " Loading..." at sw/2-75,sh/2
'load sprite animation
sprites delete
option sprite pos central
sprite "1" load "snowman-data/snowman.png",5,3
sprite "1" resize sw,sh
sprite "1" at sw/2,sh/2 scale 1
sprite "1" show
sprite "1" delay .12
sprite "1" loop
'start a song if music flag is on
if music=1 then
song=rnd(songmax)+1 'choose a random song
notes load "snowman-data/"&song$(song)
notes play
end if
'================
'the main loop...
'================
do
if music=1 then gosub checkmusic
slowdown
'get screen touch...
if touch_x(0)<> -1 then
x=touch_x(0) ! sx=sw/5
'left side of screen touched...
'go backwards in song list
if x>1 and x<sx then
notes stop
song = song -1
if song<1 then song = songmax
notes load "snowman-data/"&song$(song)
notes play
'wait until finger up..
do!until not touch_x(0)<> -1
end if
'right side of screen touched...
'go forward in song list
if x>(sw-sx) and x<sw then
notes stop
song = song +1
if song>17 then song = 1
notes load "snowman-data/"&song$(song)
notes play
do!until not touch_x(0)<> -1
end if
'touch middle of screen quits...
if x>sx and x<sw-sx then
break
end if
end if
until forever
set toolbar on
sprite "1" delete
text
end
'=================================
' G O S U B S / F U N C T I O N S
'=================================
'=========
checkmusic:
'=========
'if song over, load the next one
if notes_time() => notes_length() then
song=song+1 ! if song>songmax then song=1
notes load "snowman-data/"&song$(song)
notes play
end if
return
'===========
checkinstall:
'===========
i=0 ! i$="snowman-data/"
'check to see if data files exist first.
if not file_exists(i$) then i=1
if not file_exists(i$&"snowman.png") then i=1
for t=1 to songmax
a$=str$(t)!if len(a$)=1 then a$="0"&a$
a$=a$&".mid"!if not file_exists(i$&a$) then i=1
next t
if i= 1 then gosub install
return
'======
install:
'======
'set orientation top
url$="www.qbasicnews.com/dav/snowman-data/"
print
print
print
print "SNOWMAN SCREEN SAVER INSTALL v1.0"
print
print "Before using this screen saver you must ";
print "download the needed media files. A folder ";
print "will be created called 'snowman-data' and ";
print "will take under 1MB of space. ";
print "It will download from: http://"&url$
print
print "You will only have to do this download once ";
print "unless you delete the 'snowman-data' folder."
print
print "MAKE SURE TO STAY CONNECTED TO THE ";
print "INTERNET DURING THE ENTIRE PROCESS."
print
button "download" text "Proceed" at 25,10
button "no" text "Not now, maybe later" at 150,10
do
if button_pressed("no") then end
until button_pressed("download")
button "download" delete
button "no" delete
text clear
if system_ext_ip$() ="" then
print "Error!"
print
print "You do not appear to be online. ";
print "Please connect to the internet first and ";
print "try running program again."
print
print "STOPPED..."
end
end if
print "Creating 'snowman-data' folder...";
dir "snowman-data/" create
print "OK!"
redownload:
print "Downloading snowman.gif (565983 bytes)"
print "This may take a minute ..."
http url$&"snowman.gif" getdim m
file "snowman.gif" writedim m
if file_size("snowman.gif") <> 565983 then
print "File not properly downloaded, retrying..."
file "snowman.gif" delete
goto redownload
end if
print "Generating snowman animation..."
sprites delete
sprite 1 load "snowman.gif"
sprite 1 save "snowman-data/snowman.png"
file "snowman.gif" delete
'download midi files...
for t=1 to songmax
a$=str$(t)!if len(a$)=1 then a$="0"&a$
a$=a$&".mid" ! f$="snowman-data/"&a$
print "Downloading ";
print url$;
print a$;
print "...";
http url$&a$ getdim m
file "snowman-data/"&a$ writedim m
next t
text clear
return