Every contractor i've worked with in my 15 years in construction has used Imperial, so I would say its still prevalent here in the states, although I agree that the metric system makes a whole lot more sense. I put this together on the AppGameKit mobile app, so pardon the lack of indents. I also finished most of it before I saw Phaelax's much more efficient method x_x Thanks for sharing guys and thanks PartTime for the starting point!
It runs without any media.
// Created: 2018-12-28
// show all errors
SetErrorMode(2)
// set display properties
// allow both portrait and landscape on mobile devices
SetOrientationAllowed( 1, 1, 0, 0 )
// 30fps instead of 60 to save battery
SetSyncRate( 30, 0 )
// use the maximum available screen space, no black borders
SetScissor(0,0,0,0)
// since version 2.0.22 we can use nicer default fonts
UseNewDefaultFonts(1)
//scrolls are used for the scroll wheel on bottom of screen
scrolls as integer [25]
oldscrolls as integer [25]
//fraction represent our lines on the ruler
type fractions
sprite as integer
value as string
active as integer
endtype
//the background color of the ruler
ruler = createsprite(0)
setspritesize(ruler, 5*16, 8)
setspriteposition(ruler,5, 15)
setspritecolor(ruler,241, 236, 80, 255)
//the white numbers below the ruler
numbers as integer [5]
for i = 1 to 5
CreateText(i, str(i))
SetTextPosition(i, 5+(i*16), 25)
SetTextAlignment(i, 1)
next i
fraction as fractions [4, 15]
// here we give a value for each line on the ruler and make the sprites
for i = 0 to 4
for f = 0 to 15
fraction[i, f].sprite = createsprite(0)
if f = 0
fraction[i, f].value = str(i)
SetSpriteSize(fraction[i, f].sprite, .5 , 8)
endif
if f = 1
fraction[i,f].value = str(i) + " 1/16"
SetSpriteSize(fraction[i, f].sprite, .5, 2)
endif
if f = 2
fraction[i,f].value = str(i) + " 1/8"
SetSpriteSize(fraction[i, f].sprite, .5, 3)
endif
if f = 3
fraction[i,f].value = str(i) + " 3/16"
setspritesize(fraction[i,f].sprite, .5, 2)
endif
if f = 4
fraction[i, f].value = str(i) + " 1/4"
SetSpriteSize(fraction[i,f].sprite, .5, 4)
endif
if f = 5
fraction[i,f].value = str(i) + " 5/16"
SetSpriteSize(fraction[i, f].sprite, .5, 2)
endif
if f = 6
fraction[i,f].value = str(i) + " 3/8"
SetSpriteSize(fraction[i,f].sprite, .5, 3)
endif
if f = 7
fraction[i,f].value = str(i) + " 7/16"
SetSpriteSize(fraction[i,f].sprite, .5, 2)
endif
if f = 8
fraction[i,f].value = str(i) + " 1/2"
SetSpriteSize(fraction[i,f].sprite, .5, 5)
endif
if f = 9
fraction[i,f].value = str(i) + " 9/16"
SetSpriteSize(fraction[i,f].sprite, .5, 2)
endif
if f = 10
fraction[i,f].value = str(i) +" 5/8"
SetSpriteSize(fraction[i,f].sprite, .5, 3)
endif
if f = 11
fraction[i,f].value = str(i) + " 11/16"
SetSpriteSize(fraction[i,f].sprite, .5, 2)
endif
if f = 12
fraction[i,f].value = str(i) + " 3/4"
SetSpriteSize(fraction[i,f].sprite, .5, 4)
endif
if f = 13
fraction[i,f].value = str(i) + " 13/16"
SetSpriteSize(fraction[i,f].sprite, .5, 2)
endif
if f = 14
fraction[i,f].value = str(i) + " 7/8"
SetSpriteSize(fraction[i,f].sprite, .5, 3)
endif
if f = 15
fraction[i,f].value = str(i) + " 15/16"
SetSpriteSize(fraction[i,f].sprite, .5, 2)
endif
setspritecolor(fraction[i,f].sprite, 15, 15, 15, 255)
SetSpritePosition(fraction[i, f].sprite, 5+(i*16)+f, 15)
next f
next i
//the 5 inch line on the tape (we dont use)
fiver = CreateSprite(0)
setspriteposition(fiver,5 + (16*5), 5)
SetSpriteSize(fiver, .5, 8)
SetSpriteColor(fiver, 0, 0, 0, 255)
stage = 1
//virtual button used to submit answer
AddVirtualButton(1, 50, 50, 20)
do
//select our spot on the ruler to find
if stage = 1
rndminch = random(0,4)
rndmfraction = random(0,15)
stage = 2
endif
//our selected line (the white line) is 0 and 1/16 by default
if stage = 2
selectedinch = 0
selectedfraction = 1
stage = 3
endif
//stage 3 handles moving the scroll wheel and submitting the answer, then returns to stage 1 for the next question
if stage = 3
//tells our program to go to the next inch after 15/16 or before 1/16
if selectedfraction < 0
selectedinch = selectedinch - 1
selectedfraction = 15
endif
if selectedfraction > 15
selectedinch = selectedinch +1
selectedfraction = 0
endif
//loops for beginning to end of ruler
if selectedinch < 0 then selectedinch = 4
if selectedinch > 4 then selectedinch = 0
//makes our selected line turn white
for i = 0 to 4
for f = 0 to 15
if selectedinch = i and selectedfraction = f
setspritecolor(fraction[i,f].sprite, 255, 255, 255, 255)
else
setspritecolor(fraction[i,f].sprite, 0, 0, 0, 255)
endif
next f
next i
//checks answer when button is pressed
if GetVirtualButtonPressed(1) = 1
if selectedinch = rndminch and selectedfraction = rndmfraction
score = score + 1
if score > highscore then highscore = score
endif
if selectedinch <> rndminch or selectedfraction<> rndmfraction
score = 0
endif
stage = 1
endif
endif
//creates our scroll wheel
if GetSpriteExists(scroll) =0
scroll = CreateSprite(0)
SetSpriteColor(scroll, 70, 70, 70, 255)
setspritesize(scroll, 52, 10)
SetSpritePositionByOffset(scroll, GetVirtualWidth()/2, 80)
for i = 1 to 25
scrolls[i] = createsprite(0)
setspritecolor(scrolls[i], 120,120,120,255)
SetSpriteSize(scrolls[i], 1, 9)
SetSpritePositionByOffset(scrolls[i], 24.5 + (2 * i), 80)
next i
endif
pointer = CreateDummySprite()
if GetPointerPressed() = 1
SetSpritePosition(pointer, getpointerx(), getpointery())
oldx = getpointerx()
oldy = getpointery()
for i = 1 to 25
oldscrolls[i] = getspritex(scrolls[i])
next i
endif
if GetPointerState() = 1
newx =getpointerx()
endif
for i = 1 to 25
if getspritex(scrolls[i]) < 25
oldscrolls[i] =oldscrolls[i] + 50
selectedfraction =selectedfraction - 1
endif
if getspritex(scrolls[i]) > 75
oldscrolls[i] = oldscrolls[i] - 50
selectedfraction= selectedfraction + 1
endif
next i
if oldx > 25 and oldx < 75 and oldy > 70 and oldy < 90
for i =1 to 25
SetSpritePosition(scrolls[i], oldscrolls[i] + ((newx - oldx)/2), GetSpriteY(scrolls[i]))
next i
endif
print("Highscore: " + str(highscore))
print("Score: " + str(score))
Print("FIND: " + fraction[rndminch, rndmfraction].value)
If GetRawKeyReleased(27) Then End
Sync()
loop
Let me know what you think!
One smart fellow, he felt smart. Two smart fellows, both felt smart. Three smart fellows all felt smart...