Post by Wayne Rayner on Feb 17, 2019 11:50:48 GMT -5
Hey guys been a while found my old menu system code and put it on the latest version installed on my pc v2.6.4
Anyways not sure if this was an issue with my menu system code a while back or just something with the new version of basic4gl or not but my displaytext sub can only display one instance of text when I want to have a lot of instances of text.
Here is the code, dont worry about not having images or not for this as all I want is to display multiple instances of text with display text which allows to resize text and position it around the screen
Anyways hope you can help me
EDIT: Also don't tell me to un comment the line drawtext() inside the sub because doing just that makes the text flash and I want the text to not just flash
EDIT2: I have made a fix that works but wont work well if I want to have multiple sizes of text in my program.
The fix is simple remove the resizing of text in the DisplayText Sub
Code:
Anyways not sure if this was an issue with my menu system code a while back or just something with the new version of basic4gl or not but my displaytext sub can only display one instance of text when I want to have a lot of instances of text.
Here is the code, dont worry about not having images or not for this as all I want is to display multiple instances of text with display text which allows to resize text and position it around the screen
' Functions List
' Sub List (for simple subs)
Sub DisplayText (Text$,SizeX,SizeY,LocationX,LocationY)
ResizeText(SizeX,SizeY)
Locate LocationX, LocationY
Print Text$
'DrawText()
End Sub
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Set-Up
dim Version$ = "0.1"
ResizeText(60,40)
Resizespritearea(1280,720)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Constants (Static/Stays the same)
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Variables (Dynamic/Changes)
dim cursor(1), buttonActive
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Texture Variables
dim Tex(99), NewGameBtn, NewGameBtnOver
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Sound Variables
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Load Textures
Tex(0) = LoadTex("Graphics/button_normal.png")
Tex(1) = LoadTex("Graphics/button_hover.png")
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Load Sounds
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Intro
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Main Menu
NewGameBtn = NewSprite(Tex(0))
SprSetPos(640,174)
SprSetSize(128,64)
BindSprite(NewGameBtn)
NewGameBtnOver = NewSprite(Tex(1))
SprSetPos(640,174)
SprSetSize(128,64)
SprSetVisible(False)
BindSprite(NewGameBtnOver)
buttonActive = 0
while true
cls
TextMode(TEXT_BUFFERED)
BindSprite(NewGameBtn)
SprSetVisible(True)
BindSprite(NewGameBtnOver)
SprSetVisible(False)
cursor(0) = Mouse_X()*1280
cursor(1) = Mouse_Y()*720
' Here is where you will display stuff to the user
DisplayText("Text 1",60,40,20,1)
DisplayText("Play",60,40,28,20)'this text is meant to be over the button but since text is white I moved it
if cursor(0)>(SprLeft(NewGameBtn)) and cursor(0)<(SprRight(NewGameBtn)) and cursor(1)>(SprTop(NewGameBtn)) and cursor(1)<(SprBottom(NewGameBtn)) then
BindSprite(NewGameBtn)
SprSetVisible(False)
BindSprite(NewGameBtnOver)
SprSetVisible(True)
buttonactive = 1
Endif
If Mouse_Button(0) and ButtonActive = 1 then
DeleteSprite(NewGameBtn)
DeleteSprite(NewGameBtnOver)
goto NewGame:
EndIf
' Ideally this is where you want calculations especially if you have
' a end turn button.
DrawText()
Wend
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' New Game
NewGame:
cls
Printr "This is a new game screen :P"
DrawText()
Sleep(2000)
End
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Game
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Options
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
' Credits
''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Anyways hope you can help me
EDIT: Also don't tell me to un comment the line drawtext() inside the sub because doing just that makes the text flash and I want the text to not just flash
EDIT2: I have made a fix that works but wont work well if I want to have multiple sizes of text in my program.
The fix is simple remove the resizing of text in the DisplayText Sub
Code:
Sub DisplayText (Text$,LocationX,LocationY)
locate LocationX, LocationY
print Text$
End Sub