[B+]Locate, Print, Write und Input im Grafik-Fenster

Übersicht BlitzBasic Codearchiv

Neue Antwort erstellen

Rallimen

Sieger des 30-EUR-Wettbewerbs

Betreff: [B+]Locate, Print, Write und Input im Grafik-Fenster

BeitragMo, Okt 03, 2005 21:35
Antworten mit Zitat
Benutzer-Profile anzeigen
Hallo,
da es einige gibt die nur mit B+ arbeiten und es gestört hat das Print usw nicht im Grafik Fenster möglich ist, habe ich die mal neu geschrieben!
Jetzt geht auch Locate wieder!
Ist natürlich mehr für Beginner gedacht! BlitzBasic: [AUSKLAPPEN]
; [ nur Blitz Plus ]
; 03.10.2005 by Rallimen
; Print, Locate, Write und Input -Routinen
;
; wie bei BB2D und BB3D (..es geht doch!)
; + 10er Block (Extra)
; Funktioniert nur bei gesetzten Graphics Modus!
; also nicht in der Dos Konsole!
;
; Einfach direkt nach dem Graphics Befehl rein kopieren!!
; besser aber mit include
;
Global PrintWriteX%
Global PrintWriteY%
Global Textheight%
Global BackImg% = CreateImage (GraphicsWidth () ,GraphicsHeight () )

Function Locate (x%,y%)
PrintWriteX = X
PrintWriteY = y
End Function

Function Print (A$ = \"\")
print_Change_sys ()
Text PrintWriteX,PrintWriteY,A$
Flip 0
If Textheight < FontHeight () Then Textheight = FontHeight ()
PrintWriteY = PrintWriteY + Textheight
Textheight = 0
PrintWriteX = 0
End Function

Function Write (A$)
print_Change_sys ()
Text PrintWriteX,PrintWriteY,A$
Flip 0
PrintWriteX = PrintWriteX + StringWidth (A$)
If Textheight < FontHeight () Then Textheight = FontHeight ()
End Function

Function print_Change_sys ()
Flip 0
CopyRect 0 ,0,GraphicsWidth () ,GraphicsHeight () ,0,0,BackBuffer () ,ImageBuffer (BackImg)
Flip 0
If PrintWriteY + FontHeight () > GraphicsHeight () Then
Cls
DrawBlock BackImg,0,GraphicsHeight () - PrintWriteY - FontHeight ()
PrintWriteY = GraphicsHeight () - FontHeight ()
Else
DrawBlock BackImg,0,0
End If
End Function

Function Input$ (A$ = \"\")
A$ = A$ + \" \"
print_Change_sys ()
If PrintWriteY + FontHeight () => GraphicsHeight () Then
CopyRect 0 ,0,GraphicsWidth () ,GraphicsHeight () ,0,0,BackBuffer () ,ImageBuffer (BackImg)
End If
Repeat
DrawBlock BackImg,0,0
zz = GetKeyNew ()
If zz > 31 And zz < 256 Then antwort$ = antwort$ + Chr (zz)
If zz = 8 Then
If Len (antwort$) > 0 Then
antwort$ = Left (antwort$, (Len (antwort$) - 1) )
End If
End If
If CursorStatus Then
Text PrintWriteX,PrintWriteY,a$ + antwort$ + Chr(95) ;Cursor
Else
Text PrintWriteX,PrintWriteY,a$ + antwort$
End If
If CursorZeit < MilliSecs () Then
CursorStatus = CursorStatus Xor 1
CursorZeit = MilliSecs () + 300;Cursor Blinkspeed
End If
If zz = 13 Then
DrawBlock BackImg,0,0
Text PrintWriteX,PrintWriteY,a$ + antwort$
If Textheight < FontHeight () Then Textheight = FontHeight ()
PrintWriteY = PrintWriteY + Textheight
Textheight = 0
PrintWriteX = 0
Flip 0
Return antwort$
End If
Flip 0
Forever
End Function

Function GetKeyNew ()
Local xx
If KeyHit (181)
xx = 47
ElseIf KeyHit (82) Then
XX = 48 ;0
ElseIf KeyHit (83) Then
XX = 44 ;,
ElseIf KeyHit (79) Then
XX = 49 ;1
ElseIf KeyHit (80) Then
XX = 50 ;2
ElseIf KeyHit (81) Then
XX = 51 ;3
ElseIf KeyHit (75) Then
XX = 52 ;4
ElseIf KeyHit (76) Then
XX = 53 ;5
ElseIf KeyHit (77) Then
XX = 54 ;6
ElseIf KeyHit (71) Then
XX = 55 ;7
ElseIf KeyHit (72) Then
XX = 56 ;8
ElseIf KeyHit (73) Then
XX = 57 ;9
End If
If xx = 0 Then XX = GetKey ()
FlushKeys ()
Return xx
End Function

Ist natürlich nichts für schnelle Sachen!
Versucht es bitte nicht mit BB2D oder BB3D, es geht nicht!
Wenn der Fehler "Invalid Blitz2D Buffer handle"
dann fehlt der Graphics Befehl
[BB2D | BB3D | BB+]

Neue Antwort erstellen


Übersicht BlitzBasic Codearchiv

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group