how to change text colour
how to change text colour
How do I change the background color from black to another color and how do I change the text color. I'm new and need some help. Thanks for reading . I haven't explained myself very well I'm referring to the background color or the text.
Re: how to change text colour
Hi, please post a short code example showing where you are stuck, for people to help.
Re: how to change text colour
Code: Select all
StartDrawing(WindowOutput(0))
DrawText(10,10,"hello world")
ClearScreen(#Green)
x=x+1
DisplayTransparentSprite(sprite1,x,y)
DisplayTransparentSprite(sprite2,x2,y2)
result = SpriteCollision(sprite1,x,y,sprite2,x2,y2)
If result = 1
DrawText(600,400, "CRASH")
EndIf
If x >= 1366
x= -179
EndIf
StopDrawing()
FlipBuffers()
WindowEvent()
ExamineKeyboard()
If KeyboardPushed(#PB_Key_Return)
End
EndIf
If KeyboardPushed(#PB_Key_W)
y=y-10
EndIf
If KeyboardPushed(#PB_Key_S)
y=y+10
EndIf
Goto loopy
Re: how to change text colour
Have you ever read the help for DrawText()
DrawText(x, y, Text$ [, FrontColor [, BackColor]])
Re: how to change text colour
Ok thanks for that I'm still finding my feet.
I thought it would be something like settextcolor() was looking for the wrong help. I've come to PB from AGK2 classic. I must say I'm very impressed with PB so far. I'm on day 4 . Thanks again for the help.
I thought it would be something like settextcolor() was looking for the wrong help. I've come to PB from AGK2 classic. I must say I'm very impressed with PB so far. I'm on day 4 . Thanks again for the help.
Re: how to change text colour
@pfaber11: I have a few points about the code you posted that you might like to know.
- The DisplayTransparentSprite() commands should only be used outside of a StarDrawing()/StopDrawing() block.
- You are mixing drawing operations on the WindowOutput() and the ScreenOutput(). It isn't shown but you most likely have a WindowedScreen inside a Window. Just draw to the screen because you don't seem to be drawing on any portion of the window outside of the WindowedScreen() area. The pattern to do this is using ClearScreen(), StartDrawing(ScreenOutput())/StopDrawing(), then FlipBuffers(). If sprites are displayed they would be outside the drawing block as mentioned above but can be either before or after the drawing block or both before and after it.
- If there is a portion of the Window that is outside of the WindowedScreen area that you would like to draw to, consider using an ImageGadget() and draw to an image that is then assigned to it or use a CanvasGadget() and draw to it using StartDrawing(CancasOutput)). By ysing a gadget you won't have to keep redrawing the area within the gadget unless it changes.
- Since you are using a WindowedScreen you need to also check for window events in addition to the ones that are com8ng from the screen (ExamineKeyboard(), ExamineMouse(), etc). The code you showed does check once per each display loop. You should inates be checking for events in a loop until there are no more before continuing on with the displat loop. If this isn't done then it is very easy for three unhandled window events to quickly build up and cause lag in your program's responsiveness or even result in a crash. This is especially true if there is any user interaction with the program.
- One last minor point, the infinite Goto Label loop can easily and effectively be replaced by a Repeat: Until Forever loop.
Happy 4th day of PureBasic!
The PureBasic IDE can show you the parameters needed for a function in the status line by placing the cursor within the parenthesis after the funtion's name. You can also display the help file entry for a function by pressing F1 when the cursor is on the function's name in your code.
- The DisplayTransparentSprite() commands should only be used outside of a StarDrawing()/StopDrawing() block.
- You are mixing drawing operations on the WindowOutput() and the ScreenOutput(). It isn't shown but you most likely have a WindowedScreen inside a Window. Just draw to the screen because you don't seem to be drawing on any portion of the window outside of the WindowedScreen() area. The pattern to do this is using ClearScreen(), StartDrawing(ScreenOutput())/StopDrawing(), then FlipBuffers(). If sprites are displayed they would be outside the drawing block as mentioned above but can be either before or after the drawing block or both before and after it.
- If there is a portion of the Window that is outside of the WindowedScreen area that you would like to draw to, consider using an ImageGadget() and draw to an image that is then assigned to it or use a CanvasGadget() and draw to it using StartDrawing(CancasOutput)). By ysing a gadget you won't have to keep redrawing the area within the gadget unless it changes.
- Since you are using a WindowedScreen you need to also check for window events in addition to the ones that are com8ng from the screen (ExamineKeyboard(), ExamineMouse(), etc). The code you showed does check once per each display loop. You should inates be checking for events in a loop until there are no more before continuing on with the displat loop. If this isn't done then it is very easy for three unhandled window events to quickly build up and cause lag in your program's responsiveness or even result in a crash. This is especially true if there is any user interaction with the program.
- One last minor point, the infinite Goto Label loop can easily and effectively be replaced by a Repeat: Until Forever loop.
Happy 4th day of PureBasic!
The PureBasic IDE can show you the parameters needed for a function in the status line by placing the cursor within the parenthesis after the funtion's name. You can also display the help file entry for a function by pressing F1 when the cursor is on the function's name in your code.
Re: how to change text colour
pfaber11
Check out the detail from these TOPIC TITLES in the Search feature
Color Themes for PureBasic
Control border color
Change menu and popup menu colours
Color Themes for PureBasic
Procedure HDPI fix
Control border color
Check out the detail from these TOPIC TITLES in the Search feature
Color Themes for PureBasic
Control border color
Change menu and popup menu colours
Color Themes for PureBasic
Procedure HDPI fix
Control border color
If it's falling over......just remember the computer is never wrong!