Gambas France BETA


Pas de compte ? Incription

Démos oldskool

1
AuteurMessages
Jack#1 Posté le 9/2/2025 à 20:55:01
Hello

après un long moment d'absence me voilà de retour :-)
j'ai retravaillé mes démos afin de les rendre compatibles avec la SDL2.
Je viens de mettre à jour celle nommée "Cube". C'est dans la partie Graphisme.
Je mettrai les autres au fur et à mesure. Pour les impatients, elles sont déjà dans la bibliothèque de Gambas.
Pour un code démocratique nationalisons Gambas.
gambix#2 Posté le 10/2/2025 à 10:30:44
Faire simple !Je vais pouvoir te montrer comment utiliser jit et sdl.

Ya plein de truc délire a faire en old-school
Moins de texte dans une signature c'est agrandir son espace.
gambix#3 Posté le 10/2/2025 à 13:28:01
Faire simple !Du coup voici le délire



1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
' Gambas module file

PRIVATE $hWindow AS Window
PRIVATE $hBuffer AS Image
PRIVATE $pBuffer AS POINTER

PUBLIC SUB Main()

$hWindow = NEW Window AS "Window"

WITH $hWindow
.Resize(640, 480)
.Resizable = FALSE
.Show
'.FrameRate = 60
END WITH


$hBuffer = NEW Image(640, 480)
$pBuffer = $hBuffer.Data

END

PUBLIC SUB Window_Draw()

DIM H AS INTEGER

H = Font.DefaultHeight * 4

Draw.Clear
Draw.Font.Size = H
'Draw.Text("Gambas", 0, 0)

DrawImage()

Draw.Image($hBuffer, 0, 0)

Draw.Text(CStr($hWindow.FrameRate), 0, 0)


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

FAST UNSAFE PRIVATE SUB DrawImage()


DIM r, g, b, a AS BYTE
DIM i AS LONG


FOR i = 0 TO ($hBuffer.Width * $hBuffer.Height - 1) * 4 STEP 4
r = Rnd(0, 255) 'la fonction rnd coute cher en temps
g = Rnd(0, 255)
b = Rnd(0, 255)
a = 255
Byte@($pBuffer + i) = b
Byte@($pBuffer + i + 1) = r
Byte@($pBuffer + i + 2) = g
Byte@($pBuffer + i + 3) = a
NEXT

$hBuffer[0, 0] = 0 'pour forcer le drapeau de modification

END
Moins de texte dans une signature c'est agrandir son espace.
Jack#4 Posté le 10/2/2025 à 16:29:04
Bluffant effectivement. Ca augmente la vitesse de traitement de combien d'après toi ?

Cependant l'initialisation du framerate annihile le FAST UNSAFE. Il suffit de décommenter la ligne du framerate pour voir cela.

' Gambas module file

Private $hWindow As Window
Private $hBuffer As Image
Private $pBuffer As Pointer
Private x2 As Integer[]
Private y As Integer[]
Private xp As Integer[]
Private yp As Integer[]

Public Sub Main()
Dim ii As Integer
$hWindow = New Window As "Window"

With $hWindow
.Resize(640, 480)
.Resizable = False
.Show
'.FrameRate = 30
End With
x2 = New Integer[51]
y = New Integer[51]
xp = New Integer[51]
yp = New Integer[51]
Randomize
For ii = 1 To 50
xp[ii] = Int(Rnd * 20) - 10
yp[ii] = Int(Rnd * 20) - 10
x2[ii] = $hWindow.width / 2
y[ii] = $hWindow.height / 2
Next

$hBuffer = New Image(640, 480)
$pBuffer = $hBuffer.Data

End

Public Sub Window_Draw()

Dim H, ii As Integer

H = Font.DefaultHeight * 4
Draw.Clear
Draw.Font.Size = H
DrawImage()
Draw.Image($hBuffer, 0, 0)
Draw.Text(CStr($hWindow.FrameRate), 0, 0)


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

Fast Unsafe Private Sub DrawImage()


Dim ii As Integer

Randomize
Draw.Background = &h3F3FFF&
For ii = 1 To 20
Draw.Rect(x2[ii], y[ii], 8 + ii, 8 + ii, 28888)
x2[ii] = x2[ii] + xp[ii]
y[ii] = y[ii] + yp[ii]
If x2[ii] < 0 Or x2[ii] > $hWindow.width Or y[ii] < 0 Or y[ii] > $hWindow.height Then
x2[ii] = $hWindow.width / 2
y[ii] = $hWindow.height / 2
Endif
Next

'$hBuffer[0, 0] = 0
End
Pour un code démocratique nationalisons Gambas.
gambix#5 Posté le 10/2/2025 à 17:55:11
Faire simple !quand tu donne une valeur a framerate ça met un taquet qui maintien le frame rate a un niveau constant et limite la charge du processeur.

Pour ce qui est de la vitesse d'execution, c'est assez pour faire mumuse. Par exemple j'ai fais des jeu en raycasting ... donc sans utilisation de la carte graphique et en pure balayage d'écran a l'ancienne.
Moins de texte dans une signature c'est agrandir son espace.
Jack#6 Posté le 10/2/2025 à 18:09:28
Oui, c'est bien pour des gros calcul.
Pour un code démocratique nationalisons Gambas.
Jack#7 Posté le 11/2/2025 à 09:20:44
Je viens de voir que mettre le framerate à 0 ça le désactive
Pour un code démocratique nationalisons Gambas.
1