Retrogamecoding(.org) > Other Languages

FreeBASIC

(1/2) > >>

Tomaaz:
It looks like FreeBASIC is still being used for making games. There is almost 20 games made in it in 2012 at FreeBASIC Games Directory (203 in total).

Many people complain about its slow development and lack of support for 64bit systems, but it's still a pretty good compiler IMHO. Any FreeBASIC programmers here?

Cybermonkey:
Since I am using Freepascal I do not use FreeBASIC anymore.

Bereb:
Just one script that I found in my archives ( sorry, it's not a game  :-[ ).
I have also  an EGSL version of it, just a little slower, but not very much. May I post this one here to compare ?

2D Equation (FreeBasic) : move the mouse over the screen

--- Code: ---'======================================
' Equation 2D
' FreeBASIC 0.23.0
' Septembre 2011 - B.Carette
' inspiré de 'Processing'
'======================================

Const LARG = 200
Const HAUT = 200
Const W = 16
Const H = 16
Const DX = W / LARG
Const DY = H / HAUT

Dim As String k
Dim As Integer mx, my
Dim As Single v, x, y, n
Dim As Integer i, j, p, coul

Dim Shared As Integer pix(LARG*HAUT+LARG, 2)
For i = 0 To LARG
For j = 0 To HAUT
p = i + j * LARG
pix(p, 0) = i
pix(p, 1) = j
Next
Next


ScreenRes LARG, HAUT, 32, 2, &h04
ScreenSet 1, 0

WindowTitle "Equation 2D"

Do
GetMouse(mx,my)
n = (mx + 1)  * 10 / LARG
x = -W / 2
For j = 0 To HAUT
y = -H / 2
For i = 0 To LARG
v = Sin(n * Cos(Sqr((x * x) + (y * y))) + 5 * ATan2(y, x))
coul = RGB((v + 1) * 127, (v + 1) * 127, (v + 1) * 127)
p = i + j * LARG
PSet (pix(p, 0), pix(p, 1)), coul
y += DY
Next
x += DX
Next
ScreenCopy
k = Inkey
Loop Until k = Chr(27) Or k = Chr(255, 107)

End

--- End code ---

Cybermonkey:
Yes, we want to see the EGSL script.  :)

Bereb:
2D Equation (EGSL) : move the mouse over the screen

--- Code: ---openwindow(200,200,32,"2D Equation")

-- constantes
local sqrt, atan2 = math.sqrt, math.atan2
local width, height = screenwidth(), screenheight()
local w, h = 16, 16
local dx, dy = w / width, h / height

-- variables
local px, py = {}, {}
local p, n, x, y, c
local mx, key

-- tables
for i = 0, width do
for j = 0, height do
p = i + j * width
px[p] = i
py[p] = j
end
end

repeat
key = getkey()
mx = mousex()
n = (mx + 1)  * 10 / width
x = -w / 2
for j = 0, width do
y = -h / 2
for i= 0, height do
c = (sin(n * cos(sqrt((x*x) + (y*y))) + 5 * atan2(x,y)) +1) * 128
p = i + j * width
-- tracer les points --
color(c,c,c)
dot(px[p], py[p])
-----------------------
y = y + dy
end
x = x + dx
end
redraw()
until key == 27

closewindow()

--- End code ---

N.B.: Personaly, I prefer EGSL because of the Lua syntax, the optional declaration of variables and because it is 'interpreted', so developing code is simpler. The results as regards  speed are better in FreeBasic (a compiled language), but graphic commands are easier and more complete in EGSL (e.g. there is no anti-aliasing in FB, among other things). However FB has some other features, which are missing in EGSL (e.g. creating dynamic libraries, .dll or .so files, etc.), but I have never used them and don't need them for my personal purposes.

Navigation

[0] Message Index

[#] Next page

Go to full version