Font being covered by box
Author |
Message |
conbunthedestroyer
|
Posted: Thu Jun 08, 2017 7:58 pm Post subject: Font being covered by box |
|
|
What is it you are trying to achieve?
Make the font not be covered by the box when it's being drawn
What is the problem you are having?
The font is being covered by the box
Describe what you have tried to solve this problem
Tbh, not much, but I can't really think of anything to do other than put the font draw inside the loop, which is a problem in and of itself (for reasons, I don't want it to be inside the loop). Like, I understand that the box is being drawn over the text, but is there any way to stop that from happening? Can I make the box not be drawn on top without putting the Font.Draw inside the loop?
Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
Turing: |
var testFont : int := Font.New ("serif:30")
var mouseX, mouseY, b : int
setscreen ("graphics: max;max")
proc testDrawing
Font.Draw ("Shibbity boop", 130, 590, testFont, white)
end testDrawing
proc boxDrawing
Draw.FillBox (70, 530, 570, 680, white)
Draw.FillBox (75, 535, 565, 675, 18)
Draw.FillBox (670, 530, 1170, 680, white)
Draw.FillBox (675, 535, 1165, 675, 18)
Draw.FillBox (70, 330, 570, 480, white)
Draw.FillBox (75, 335, 565, 475, 18)
Draw.FillBox (670, 330, 1170, 480, white)
Draw.FillBox (675, 335, 1165, 475, 18)
loop
Mouse.Where (mouseX, mouseY, b )
if mouseX >= 75 and mouseX <= 565 and mouseY >= 535 and mouseY <= 675 then
Draw.FillBox (75, 535, 565, 675, blue)
else
Draw.FillBox (75, 535, 565, 675, 18)
end if
if mouseX >= 675 and mouseX <= 1165 and mouseY >= 535 and mouseY <= 675 then
Draw.FillBox (675, 535, 1165, 675, yellow)
else
Draw.FillBox (675, 535, 1165, 675, 18)
end if
if mouseX >= 75 and mouseX <= 565 and mouseY >= 335 and mouseY <= 475 then
Draw.FillBox (75, 335, 565, 475, red)
else
Draw.FillBox (75, 335, 565, 475, 18)
end if
if mouseX >= 675 and mouseX <= 1165 and mouseY >= 335 and mouseY <= 475 then
Draw.FillBox (675, 335, 1165, 475, green)
else
Draw.FillBox (675, 335, 1165, 475, 18)
end if
if whatdotcolour (680, 340) not= 18 and b = 1 then
end if
end loop
end boxDrawing
boxDrawing
testDrawing
|
Please specify what version of Turing you are using
Turing 4.1.1 |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Insectoid
|
Posted: Thu Jun 08, 2017 8:09 pm Post subject: RE:Font being covered by box |
|
|
Anything you draw will be drawn on top of the things drawn before it. This is unavoidable. If you want the text on top, you need to draw it last. Why don't you want it inside the loop? |
|
|
|
|
|
conbunthedestroyer
|
Posted: Thu Jun 08, 2017 8:16 pm Post subject: Re: Font being covered by box |
|
|
Well, I just tried putting it in the loop and it does a very bad flashing thing (once again, I get why this is happening, it's just constantly running through the loop and redrawing it). I just don't know how to fix it. Also, it just has to do with the nature of my program, I have a lot of questions for my quiz and a lot of answers, and I just want to be able to draw on top of the boxes with different answers every time. (Basically, I'm lazy and want to be able to reuse a lot of the same lines of code without any of the actual wor) |
|
|
|
|
|
Insectoid
|
Posted: Thu Jun 08, 2017 8:21 pm Post subject: RE:Font being covered by box |
|
|
Fortunately, I do know how to solve the flickering. Have a look at View.Update in both the Turing documentation and the Turing Walkthrough. That will help you out in that regard.
You will be able to re-use you code regardless of the text if you organize it properly. |
|
|
|
|
|
conbunthedestroyer
|
Posted: Thu Jun 08, 2017 8:31 pm Post subject: Re: Font being covered by box |
|
|
So I'm not sure if I either a) didn't do this right or b) my computer is silly and old but I did this to the code:
var testFont : int := Font.New ("serif:30")
var mouseX, mouseY, b : int
setscreen ("graphics: max;max")
proc boxDrawing
Draw.FillBox (70, 530, 570, 680, white)
Draw.FillBox (75, 535, 565, 675, 18)
Draw.FillBox (670, 530, 1170, 680, white)
Draw.FillBox (675, 535, 1165, 675, 18)
Draw.FillBox (70, 330, 570, 480, white)
Draw.FillBox (75, 335, 565, 475, 18)
Draw.FillBox (670, 330, 1170, 480, white)
Draw.FillBox (675, 335, 1165, 475, 18)
loop
Mouse.Where (mouseX, mouseY, b)
if mouseX >= 75 and mouseX <= 565 and mouseY >= 535 and mouseY <= 675 then
Draw.FillBox (75, 535, 565, 675, blue)
Font.Draw ("Shibbity boop", 130, 590, testFont, white)
%New change
View.Update
else
Draw.FillBox (75, 535, 565, 675, 18)
Font.Draw ("Shibbity boop", 130, 590, testFont, white)
%New change
View.Update
end if
%New change
View.Update
if whatdotcolour (680, 340) not= 18 and b = 1 then
end if
end loop
end boxDrawing
boxDrawing
and it really didn't do much. |
|
|
|
|
|
Insectoid
|
Posted: Fri Jun 09, 2017 4:21 am Post subject: RE:Font being covered by box |
|
|
You forgot something in your setscreen line. |
|
|
|
|
|
conbunthedestroyer
|
Posted: Fri Jun 09, 2017 6:54 pm Post subject: Re: Font being covered by box |
|
|
Ah! Thank you! I'm a dummy sometimes |
|
|
|
|
|
|
|