ColorText - Text in Farbe wie in Call of Duty

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

 

Niclas

Betreff: ColorText - Text in Farbe wie in Call of Duty

BeitragDo, Feb 19, 2004 23:01
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi,
nach langer inaktivität im Forum, und noch längerer Pause im Code-Archiv *g* habe ich mal eine weitere, für die meisten wahrscheinlich unnütze, funktion. Smile

In Call of Duty werden die Nicks ja durch "^1" (=rot) Farbig gemacht. Diese Funktion kann diesen Farbcode darstellen.

Code: [AUSKLAPPEN]

;Function, die Text in Farbe darstellt.
;Benutzung wie in CoD:
;^ + Zahl der Farbe:
;      0 - Black / Schwarz
;      1 - Red / Rot
;      2 - Green / Grün
;      3 - Yellow /Gelb
;      4 - Blue / Blau
;      5 - Cyan / Türkis
;      6 - Pink / Purpurrot
;      7 - White / Weiß
;z.B. "^1" wenn der Text Rot erscheinen Soll
Function ColorText(x,y,txt$)
   Local tmp_x=x
   Local tmp_x2=x
   Local tmp_txt$
   
   For cnt = 1 to Len(txt$)
      curr_ltr$ = Mid$(txt$,cnt,1)
      
      If curr_ltr$ = "^" or cnt=Len(txt$) Then
         curr_cLtr$ = Mid$(txt$,cnt+1,1)
         curr_cNmbr = int(curr_cLtr$)
         
         If (curr_cNmbr > -1 And curr_cNmbr < 8) or cnt=Len(txt$) Then
         If cnt=Len(txt$) Then tmp_txt$=tmp_txt$+Right$(txt$,1)
         Text tmp_x,y,tmp_txt$
         tmp_x = tmp_x2
         tmp_txt$=""
         cnt=cnt+1   
            Select int(curr_cNmbr)
               Case 0
                  Color 0,0,0
               Case 1
                  Color 255,0,0
               Case 2
                  Color 0,255,0
               Case 3
                  Color 255,255,0
               Case 4
                  Color 0,0,255
               Case 5
                  Color 0,255,255
               Case 6
                  Color 255,0,255
               Case 7
                  Color 255,255,255
            End Select
         else
            tmp_txt$ = tmp_txt$+curr_ltr$
            tmp_x2 = tmp_x2+StringWidth(curr_ltr$)
         end if
      else
         tmp_txt$ = tmp_txt$+curr_ltr$
         tmp_x2 = tmp_x2+StringWidth(curr_ltr$)
      End if
   Next
End Function

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group