$COLOR32
CONST ImageDir$
= ".\Images\" CONST SoundDir$
= ".\Alphabet Sounds\" CONST TagDir$
= ".\Image Tags\" CONST WordSoundDir$
= ".\Word Sounds\"
'load our fonts
f1
= _LOADFONT("courbd.ttf", 48, "MONOSPACE")
'Load the alphabet sound library
temp$
= SoundDir$
+ CHR$(i
) + ".ogg" AlphaSound
(i
) = _SNDOPEN(temp$
, "VOL,SYNC,LEN,PAUSE")temp$ = WordSoundDir$ + "is how you spell.ogg"
IsHowYouSpell
= _SNDOPEN(temp$
, "VOL,SYNC,LEN,PAUSE")
_DELAY 1 'Give everything a moment to initialize and get started for us. ChangeSearchTags
PhotoCount
= UBOUND(PhotoList
) CASE 0: PhotoChosen
= 0: oldpic
= 0 'no matches CASE 1: PhotoChosen
= 1: oldpic
= 1 'Only one possible match CASE ELSE 'multiple photos match the search criteria PhotoChosen
= INT(RND * PhotoCount
) + 1 oldpic = PhotoChosen
playagain:
fullpath$ = PhotoList(PhotoChosen)
tempimage
= _LOADIMAGE(PhotoList
(PhotoChosen
), 32) 'get the new image
_FONT f1: CenterText
0, 0, 800, 50, "Spell It Aloud":
_FONT f
'program photo area is 500 x 450 pixels. So:
GetNewWH 500, 450, tempimage, nW, nH
_PUTIMAGE (300 - (nW
/ 2), 300 - (nH
/ 2) - 25)-STEP(nW
, nH
), tempimage
LoadPhotoTags word$
DisplayTags
575, 150, "Search Tags (" + _TRIM$(STR$(PhotoCount
)) + ")", LimitTag
DisplayTags 575, 300, "Photo Tags", PhotoTag
PlayLetters word$
DrawNoMatches
IF oldpic
= PhotoChosen
THEN ShowNext
= 0 IF ShowNext
= -2 THEN ShowNext
= 0:
GOTO playagain
MB = 0
IF Mx
>= 650 AND Mx
<= 750 THEN 'the mouse is in the correct X area for input temp$
= ChangeValue
(650, 171, STR$(LimitTag.Year
), -1) LimitTag.Year
= VAL(temp$
) ChangeSearchTags
temp$
= ChangeValue
(650, 191, STR$(LimitTag.Week
), -1) LimitTag.Week
= VAL(temp$
) ChangeSearchTags
temp$
= ChangeValue
(650, 211, LimitTag.
Sound, 0) ChangeSearchTags
temp$ = ChangeValue(650, 231, LimitTag.Theme, 0)
LimitTag.Theme = temp$
ChangeSearchTags
PhotoTag.Year
= VAL(ChangeValue
(650, 324, STR$(PhotoTag.Year
), -1)) ChangePhotoTags word$
PhotoTag.Week
= VAL(ChangeValue
(650, 341, STR$(PhotoTag.Week
), -1)) ChangePhotoTags word$
PhotoTag.
Sound = ChangeValue
(650, 361, PhotoTag.
Sound, 0) ChangePhotoTags word$
PhotoTag.Theme = ChangeValue(650, 381, PhotoTag.Theme, 0)
ChangePhotoTags word$
ShowNext = -2
ShowNext = -1
ControlVariable1 = -1 'Stop Command for playing the word
ControlVariable = 0
CASE 32 'space for next picture ShowNext = -1
DrawCommandBoxes
s = SaveState
BoxTitle 575, 450, 640, 470, 2, BlueGray, Gold, "LAST"
BoxTitle 641, 450, 705, 470, 2, BlueGray, Gold, "PLAY"
BoxTitle 706, 450, 770, 470, 2, BlueGray, Gold, "NEXT"
BoxTitle 575, 471, 640, 490, 2, BlueGray, Gold, "VOL"
BoxTitle 641, 471, 705, 490, 2, BlueGray, Gold, "STOP"
BoxTitle 706, 471, 770, 490, 2, BlueGray, Gold, "QUIT"
RestoreState s
Box x1, y1, x2 - x1 + 1, y2 - y1 + 1, thick, fg, bg
CenterText x1, y1 + thick, x2, y2 + thick, title$
S = SaveState
Box 50, 50, 500, 500, 5, Silver, Gold
CenterText 0, 0, 800, 50, "Spell It Aloud"
CIRCLE (300, 300), 200 - i
, BrickRed
CenterText 50, 50, 550, 550, "No Matches"
PhotoTag.Year = 0
PhotoTag.Week = 0
PhotoTag.Theme = ""
RestoreState S
DisplayTags
575, 150, "Search Tags (" + _TRIM$(STR$(PhotoCount
)) + ")", LimitTag
DisplayTags 575, 300, "Photo Tags", PhotoTag
ShowNext = -1
'Put the letters to the screen one by one
ControlVariable1 = 0
pw
= _PRINTWIDTH(word$
): StartX
= (600 - pw
) \
2 'center position
a
= ASC(word$
, i
) AND NOT 32 'play lowercase letters as uppercase sounds _LIMIT 10 'play nice with CPU during wait temp$ = WordSoundDir$ + word$ + ".ogg"
_LIMIT 10 'play nice with CPU during wait
temp
= _SNDOPEN(temp$
, "VOL,SYNC,LEN,PAUSE") _LIMIT 10 'play nice with CPU during wait
a
= ASC(word$
, i
) AND NOT 32 'play lowercase letters as uppercase sounds _LIMIT 10 'play nice with CPU during wait
SUB ChangePhotoTags
(word$
) 'Get a listing of the files
file$ = TagDir$ + word$ + ".txt"
SUB LoadPhotoTags
(word$
) file$ = TagDir$ + word$ + ".txt"
PhotoTag.Year = 0
PhotoTag.Week = 0
PhotoTag.Theme = ""
IF word$
<> "" THEN ChangePhotoTags word$
'Get a listing of the files
PhotoList$ = ImageDir$ + "*.bmp " + ImageDir$ + "*.jpg " + ImageDir$ + "*.png " + ImageDir$ + "*.gif "
SHELL _HIDE "DIR " + PhotoList$
+ "/b /s /a-d >PhotoList.txt"
'Load those names into a file.
PhotoCount = 0
file$ = TagDir$ + word$ + ".txt"
good = -1
IF LimitTag.Year
<> 0 AND LimitTag.Year
<> PhotoTag.Year
THEN good
= 0 IF LimitTag.Week
<> 0 AND LimitTag.Week
<> PhotoTag.Week
THEN good
= 0
IF LimitTag.Theme
<> "" AND LimitTag.Theme
<> PhotoTag.Theme
THEN good
= 0 PhotoCount = PhotoCount + 1
PhotoList(PhotoCount) = fullpath$
ShowNext = -1
FUNCTION ChangeValue$
(x
, y
, word$
, limit
) S = SaveState
Box x, y, 100, 20, 1, Black, Gold
CenterText x, y, x + 100, y + 20, temp$
CASE 48 TO 57 'We'll always accept numeric input CASE 65 TO 90, 97 TO 122 'A-Z (a-z) only when we're dealing with a string temp$
= word$
+ CHR$(179) ChangeValue$ = word$
RestoreState S
DisplayTags
575, 150, "Search Tags (" + _TRIM$(STR$(PhotoCount
)) + ")", LimitTag
DisplayTags 575, 300, "Photo Tags", PhotoTag
S = SaveState
w = 200: h = 106
Box x, y, w, h, 2, BlueGray, Gold
CenterText x, y + 2, x + 200, y + 20, Title
LINE (x
+ 1, y
+ 19)-STEP(w
- 2, 0), Gold
xs = x + 24: ys = y + 24 'x/y start after the box offset
bxs = xs + 50: bys = ys - 2 'x/y start for the display boxes
Box bxs, bys + i * 20, 100, 20, 1, Black, Gold
CenterValue bxs, bys, bxs + 100, bys + 20, DisplayTag.Year
CenterValue bxs, bys + 20, bxs + 100, bys + 40, DisplayTag.Week
CenterText bxs
, bys
+ 40, bxs
+ 100, bys
+ 60, DisplayTag.
Sound CenterText bxs, bys + 60, bxs + 100, bys + 80, DisplayTag.Theme
RestoreState S
LINE (x
+ i
, y
+ i
)-STEP(wide
- 2 * i
, high
- 2 * i
), Trim
, B
SUB CenterText
(x1
, y1
, x2
, y2
, text$
) xmax = x2 - x1: ymax = y2 - y1
xpos = (xmax - textlength) / 2
SUB CenterValue
(x1
, y1
, x2
, y2
, value
AS LONG) CenterText x1, y1, x2, y2, text$
DIM SS
AS SaveStateType
, Temp
AS SaveStateType
SaveMem
= _MEMNEW(LEN(SS
) * 255) 'Save up to 255 save states; More than 255 and we toss an error
'Data to Save
SS.InUse = -1
_MEMGET SaveMem
, SaveMem.OFFSET
+ o
, Temp
_MEMPUT SaveMem
, SaveMem.OFFSET
+ o
, SS
SaveState = i
_MEMPUT SaveMem
, SaveMem.OFFSET
+ NSS
* LEN(SS
), SS
NSS = NSS + 1
SaveState = NSS
_MEMGET SaveMem
, SaveMem.OFFSET
+ (WhichOne
- 1) * LEN(SS
), SS
SS.InUse = 0 'Let the routine know that we're no longer in use for this handle
_MEMPUT SaveMem
, SaveMem.OFFSET
+ (WhichOne
- 1) * LEN(SS
), SS
SUB GetNewWH
(destWidth
, destHeight
, handle
AS LONG, NewWidth
, NewHeight
) 'Sub return in variables NewWidth and NewHeight new image Width and image Height with the same ratio for optimal picture to set area width and height with [destWidth, destHeight] Pw = W / destWidth
Ph = H / destHeight
NewWidth = W / P
NewHeight = H / P