How does cls work with View.ClipSet
Author |
Message |
BigBear
|
Posted: Mon Mar 16, 2009 7:40 am Post subject: How does cls work with View.ClipSet |
|
|
I am trying to make a Font.Draw text field for input use like get.
So inside the procedure I have to cls the word if backspace is it, but I also want to be able to give the user instructions. If you put the directions on the screen before calling the procedure and then using View.ClipSet it works but the word doesn't cls if you hit Backspace.
The cls does help because if you remove the letters get blocky and sorta bold. I also tried drawing the same font white and drawing a fill box.
Any Ideas |
|
|
|
|
|
Sponsor Sponsor
|
|
|
Insectoid
|
Posted: Mon Mar 16, 2009 8:38 am Post subject: RE:How does cls work with View.ClipSet |
|
|
I did this once. To eliminate the 'dots' that get left over from drawing over the letters, I drew over them 5 times with a for loop, though there are still a few dots left over. Draw.FillBox should work fine. Here is my rather lengthy text field used in my Blackjack game.
Turing: |
%gets the bet graphically, using Font.Draw because it looks cooler.
var betString : string %the entire bet, as a string.
var betInput : string (1) %the 1 character bet input, as a string
var counter : int %holds the current posittion of the 'curser'
loop %This loop checks if the bet is above 0 and below the player's cash limit
loop %This loop checks if the bet contains only numbers
betString := "" %nothing is input yet
counter := 0 %curser is at '0'
loop
Font.Draw ("Enter your bet: $", 101, 16, textfont, yellow)
Font.Draw ("Enter your bet: $", 100, 15, textfont, brightred)
View.Update
getch (betInput ) %gets a character to add to the bet
fork playSound (click )
exit when betInput = (KEY_ENTER )
%This 'if' allows the backspace key to be used
if betInput = (KEY_DELETE ) or betInput = (KEY_BACKSPACE ) then
if counter > 0 then
%Draws a character on top of itself to erase character from screen.
%Turing doesn't seem to draw every pixel, so it is 'erased' 8 times to fully erase character.
for x : 1 .. 8
Font.Draw (betString (*), 221 + counter, 16, textfont, green)
Font.Draw (betString (*), 220 + counter, 15, textfont, green)
end for
%move the curser back a space
counter - = 12
betString := betString (1 .. * - 1) %remove previous character from bet
end if
else
%move curser forward
counter + = 12
betString + = betInput %add input to bet
Font.Draw (betInput, 221 + counter, 16, textfont, yellow) %draw the character
Font.Draw (betInput, 220 + counter, 15, textfont, brightred)
end if
end loop
exit when strrealok (betString ) %check if bet only contains numbers
%fork playSound (invalid) %This line causes Turing to crash in Crossover
Font.Draw ("Invalid Bet", 101, 3, textfont, yellow)
Font.Draw ("Invalid Bet", 100, 2, textfont, brightred)
View.Update
fork playSound (invalid )
delay (1000)
cls
drawTable
View.Update
end loop
bet := strreal (betString ) %convert bet to a real variable
exit when bet > 0 and bet <= playerMoney %check if bet is a valid number
Font.Draw ("Invalid Bet", 101, 3, textfont, yellow)
Font.Draw ("Invalid Bet", 100, 2, textfont, brightred)
View.Update
fork playSound (invalid )
delay (1000)
cls
drawTable
View.Update
end loop
|
|
|
|
|
|
|
|
|