Tidied it up a bit and added Questions for A and B
// Project: blockbusters
// Created: 2019-03-03
// show all errors
SetErrorMode(2)
#constant screenwidth=1024
#constant screenheight=768
#constant fullscreen=0
#constant screenrate=0
// set window properties
SetWindowTitle( "blockbusters" )
SetWindowSize( screenwidth, screenheight, fullscreen )
SetWindowAllowResize( 1 ) // allow the user to resize the window
// set display properties
SetVirtualResolution( screenwidth, screenheight ) // doesn't have to match the window
SetOrientationAllowed( 1, 1, 1, 1 ) // allow both portrait and landscape on mobile devices
SetSyncRate( screenrate, 0 ) // 30fps instead of 60 to save battery
SetScissor( 0,0,0,0 ) // use the maximum available screen space, no black borders
UseNewDefaultFonts( 1 ) // since version 2.0.22 we can use nicer default fonts
global mouse, question,activeletterid, framestep#, toggleletter
global time,timeid
global gap#=1.06
global letters as integer[26]
global sides as integer[]
global letterpeices as integer[]
global activeletterpeices as integer[]
global tops as integer[]
global size=80
framestep#=timer()
time=20
timeid=CreateText(str(time))
SetTextSize(timeid,32)
toggleletter=1
for a=0 to 25
letters[a]=CreateText(chr(a+65))
SetTextSize(letters[a],32)
SetTextColor(letters[a],0,0,0,255)
next
spr=createside(size)
SetSpriteVisible(spr,0)
for a=0 to 10
sides.insert(CloneSprite(spr))
SetSpriteVisible(sides[a],1)
next
spr1=createobject(size,300,size/2,MakeColor(255,255,255),MakeColor(255,255,255))
SetSpriteVisible(spr1,0)
for a=0 to 9
tops.insert(CloneSprite(spr1))
SetSpriteVisible(tops[a],1)
next
spr2=createobject(size,300,size/2,MakeColor(255,255,0),MakeColor(255,255,0))
SetSpriteVisible(spr2,0)
for a=0 to 26
letterpeices.insert(CloneSprite(spr2))
SetSpriteShape(letterpeices[a],3)
SetSpriteVisible(letterpeices[a],1)
next
spr2=createobject(size,300,size/2,MakeColor(255,255,0),MakeColor(150,150,0))
SetSpriteVisible(spr2,0)
for a=0 to 26
activeletterpeices.insert(CloneSprite(spr2))
SetSpriteShape(activeletterpeices[a],3)
SetSpriteVisible(activeletterpeices[a],0)
next
// setup question
question = CreateText("")
SetTextSize(question,32)
letter$ = GetTextString(letters[activeletterid])
grabaquestion(letter$)
createmouse()
do
SetSpritePosition(mouse,getpointerx(),getpointery())
drawsides()
drawtopsandbottoms()
drawletters()
collision()
showtimer()
flashactiveletter()
print(activeletterid)
Render2DFront()
Print( ScreenFPS() )
Sync()
loop
function showtimer()
blue=130
for a=0 to 10
DrawEllipse(700,100,50-a,50-a,MakeColor(0,0,blue),MakeColor(0,0,blue),1)
inc blue, 10
next
for a=10 to 20
DrawEllipse(700,100,50-a,50-a,MakeColor(0,0,blue),MakeColor(0,0,blue),1)
dec blue, 10
next
SetTextPosition(timeid,690,80)
endfunction
function flashactiveletter()
if (timer()-framestep#>1)
framestep#=timer()
dec time
toggleletter=-toggleletter
if toggleletter=1
SetSpriteVisible(activeletterpeices[activeletterid],1)
SetSpriteVisible(letterpeices[activeletterid],0)
else
SetSpriteVisible(activeletterpeices[activeletterid],0)
SetSpriteVisible(letterpeices[activeletterid],1)
endif
endif
if time>=0
SetTextString(timeid,str(time))
else
activeletterid=random(0,1)
time=20
letter$ = GetTextString(letters[activeletterid])
grabaquestion(letter$)
endif
SetTextPosition(question,20,screenheight-50)
endfunction
function createmouse()
swap()
render()
mouse=createsprite(GetImage(0,0,1,1))
endfunction
function collision()
for a=0 to 26
if (GetSpriteCollision(mouse,letterpeices[a])=1)
if GetRawMouseLeftPressed()
activeletterid=a
letter$ = GetTextString(letters[a])
grabaquestion(letter$)
endif
endif
next
endfunction
function grabaquestion(letter$)
if GetFileExists("Questions " + letter$ + ".dat")
fr=OpenToRead("Questions " + letter$ + ".dat")
line=random(0,25)
l=0
while not FileEOF(fr)
line$=ReadLine(fr)
if l=line then quest$=GetStringToken(line$,"?",1)
inc l
endwhile
CloseFile(fr)
else
quest$="Question set not available yet"
endif
SetTextString(question,quest$)
endfunction
function drawletters()
//draw letter peices
b=0
c=0
for y=0 to 3
for x=0 to 2
if mod(x,1)=1
// SetSpritePosition(peices[b],100+(x*GetSpriteWidth(peices[b])),140+size+ (y*GetSpriteHeight(peices[b])))
else
SetSpritePosition(letterpeices[b],145+size/2 + (x*GetSpriteWidth(letterpeices[b])*gap#-1),149+size+(y*GetSpriteHeight(letterpeices[b])*gap#))
SetSpritePosition(activeletterpeices[b],145+size/2 + (x*GetSpriteWidth(letterpeices[b])*gap#-1),149+size+(y*GetSpriteHeight(letterpeices[b])*gap#))
inc b
endif
SetTextPosition(letters[c],200+size/2 + (x*GetSpriteWidth(letterpeices[b])*gap#),167+size+(y*GetSpriteHeight(letterpeices[b])*gap#))
inc c
next
next
for y=0 to 3
for x=0 to 1
if mod(x,1)=1
// SetSpritePosition(peices[b],100+(x*GetSpriteWidth(peices[b])),140+size+ (y*GetSpriteHeight(peices[b])))
else
SetSpritePosition(letterpeices[b],148+size+size/2 + (x*GetSpriteWidth(letterpeices[b])*gap#+.2),147+size/2+(y*GetSpriteHeight(letterpeices[b])*gap#))
SetSpritePosition(activeletterpeices[b],148+size+size/2 + (x*GetSpriteWidth(letterpeices[b])*gap#+.2),147+size/2+(y*GetSpriteHeight(letterpeices[b])*gap#))
inc b
endif
SetTextPosition(letters[c],200+size+size/2 + (x*GetSpriteWidth(letterpeices[b])*gap#),167+size/2+(y*GetSpriteHeight(letterpeices[b])*gap#))
inc c
next
next
endfunction
function drawtopsandbottoms()
// draw tops and bottoms
b=0
for x=0 to 2
for y=0 to 1
if y=0
SetSpritePosition(tops[b],102+size + (x*GetSpriteWidth(tops[b])*gap#) ,102+size/2*gap#+.5)
inc b
SetSpritePosition(tops[b],102+size*gap# + (x*GetSpriteWidth(tops[b])*gap#),522+size/2*gap#+.5)
inc b
else
if x<2
SetSpritePosition(tops[b],102+size+size*gap# + (x*GetSpriteWidth(tops[b])*gap#),104)
inc b
SetSpritePosition(tops[b],105+size+size*gap# + (x*GetSpriteWidth(tops[b])*gap#),524)
inc b
endif
endif
next
next
endfunction
function createobject(size,startx,starty,color,outlinecolor)
c=color
swap()
ClearScreen()
// DrawBox(0,0,200,200,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
for b=0 to size/2
for a#=0 to size/2 step .01
if b>2 and b<10
color=outlinecolor
else
colcr=c
endif
DrawLine(startx+a#+b,starty+a#,(startx+size/2)+a#+b,(starty-size/2)+a#,color,color)
next
next
render()
spr = CreateSprite(GetImage(startx,0,size*2,size))
endfunction spr
function drawsides()
// drawsides
for y=1 to 5
SetSpritePosition(sides[y],100,100+y*GetSpriteHeight(sides[y])*gap#)
next
for y=6 to 10
SetSpritePosition(sides[y],570,100+(y-5)*GetSpriteHeight(sides[y])*gap#)
SetSpriteFlip(sides[y],1,0)
next
endfunction
function createside(size)
startx=0
starty=0
white=MakeColor(255,255,255)
blue = MakeColor(0,0,200)
swap()
ClearScreen()
// DrawBox(0,0,200,200,MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),MakeColor(0,0,0),1)
for a=0 to size/2
DrawLine(startx+a,starty+a,startx+size+a,starty+a,white,white)
next
for a=0 to size/2+2
DrawLine((startx+a)+2,(starty+a)+1,(startx+size+a)-1,(starty+a)+1,blue,blue)
next
b=0
for a=size/2 to 0 step -1
DrawLine(startx+a,starty+size/2+b,startx+size+a,starty+size/2+b,white,white)
inc b
next
b=0
for a=size/2 to 0 step -1
DrawLine((startx+a)+2,(starty+size/2+b)+1,(startx+size+a)-1,(starty+size/2+b)+1,blue,blue)
inc b
next
render()
spr = CreateSprite(GetImage(0,0,size*2,size))
endfunction spr
Do more soon
Tier 1 Developer