Tenía pendiente este ejemplo de hace ya bastante por no conocer un poco el tema del cambio de fuentes.
No supondrá dificultad hacerlo con la clase Paint. Quizás algo mucho más complicado debe ser el scroll vertical.
Const VENTANAANCHO As Integer = 640
Const VENTANAALTO As Integer = 480
Private x As Integer
Private y As Integer
Private frase As String
Private fuente As Font
Private $hWindow As Window
Public Sub Main()
$hWindow = New Window As "Window"
With $hWindow
.Width = VENTANAANCHO
.Height = VENTANAALTO
.Title = "Mostrar Scroll Horizontal"
.Resizable = False
.Show
.FrameRate = 60
End With
fuente = Font.Load("/usr/share/fonts/truetype/freefont/FreeMono.ttf")
fuente.Size = 64
frase = " Esto es una demostración de scroll horizontal en SDL. "
x = 0
y = (VENTANAALTO - fuente.Height("A")) / 2
End
Public Sub Window_Draw()
$hWindow.Fill(Color.White)
Draw.Font = fuente
Draw.Font.Size = 64
Draw.ForeColor = Color.Blue
ScrollHorizontal
End
Public Sub ScrollHorizontal()
'Cambiando el valor de x aumenta o disminuye la velocidad de presentación en el eje x
'Puede producir efectos extraños en la presentación
x -= 2
If x < -fuente.Width(frase) Then x = 0
Draw.Text(frase, x, y)
Draw.Text(frase, x + fuente.Width(frase), y)
End
Public Sub Window_KeyPress()
Select Case Key.Code
Case Key.F1
$hWindow.FullScreen = Not $hWindow.FullScreen
Case Key.Esc
$hWindow.Close
End Select
End
Const VENTANAALTO As Integer = 480
Private x As Integer
Private y As Integer
Private frase As String
Private fuente As Font
Private $hWindow As Window
Public Sub Main()
$hWindow = New Window As "Window"
With $hWindow
.Width = VENTANAANCHO
.Height = VENTANAALTO
.Title = "Mostrar Scroll Horizontal"
.Resizable = False
.Show
.FrameRate = 60
End With
fuente = Font.Load("/usr/share/fonts/truetype/freefont/FreeMono.ttf")
fuente.Size = 64
frase = " Esto es una demostración de scroll horizontal en SDL. "
x = 0
y = (VENTANAALTO - fuente.Height("A")) / 2
End
Public Sub Window_Draw()
$hWindow.Fill(Color.White)
Draw.Font = fuente
Draw.Font.Size = 64
Draw.ForeColor = Color.Blue
ScrollHorizontal
End
Public Sub ScrollHorizontal()
'Cambiando el valor de x aumenta o disminuye la velocidad de presentación en el eje x
'Puede producir efectos extraños en la presentación
x -= 2
If x < -fuente.Width(frase) Then x = 0
Draw.Text(frase, x, y)
Draw.Text(frase, x + fuente.Width(frase), y)
End
Public Sub Window_KeyPress()
Select Case Key.Code
Case Key.F1
$hWindow.FullScreen = Not $hWindow.FullScreen
Case Key.Esc
$hWindow.Close
End Select
End
Saludos
EjemploMuestraTextoScroll.tar.gz | ||
Descripción: | Ejemplo que muestra como realizar un scroll horizontal con SDL1 | Descargar |
Nombre del archivo: | EjemploMuestraTextoScroll.tar.gz | |
Tamaño: | 12.99 KB | |
Descargado: | 13 veces |
EjemploMuestraTextoScroll.tar.gz | ||
Descripción: | Ejemplo que muestra como realizar un scroll horizontal con SDL1 | Descargar |
Nombre del archivo: | EjemploMuestraTextoScroll.tar.gz | |
Tamaño: | 12.99 KB | |
Descargado: | 13 veces |
EjemploMuestraTextoScroll.tar.gz | ||
Descripción: | Ejemplo que muestra como realizar un scroll horizontal con SDL1 | Descargar |
Nombre del archivo: | EjemploMuestraTextoScroll.tar.gz | |
Tamaño: | 12.99 KB | |
Descargado: | 13 veces |