Author Topic: New SDL Library  (Read 3600 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
New SDL Library
« on: September 03, 2015, 06:42:47 AM »
Hello,

New Sdl-Library o3.o9.2o15
Do a test!

Demo Example 1

Code: [Select]
include "sdl.inc"
window 800,600,1

sub drawLightning(sys x1, y1, x2, y2, displace)
dim as integer curdetail=5
if displace < curDetail 
   color 200,200,255,255
   drawline x1,y1,x2,y2
else
    single mid_x = (x2+x1)/2
    single mid_y = (y2+y1)/2
    mid_x += (-rndF()*displace)
    mid_y += (-rndF()*displace)
    drawLightning(x1,y1,mid_x,mid_y,displace/2)
    drawLightning(x2,y2,mid_x,mid_y,displace/2)
end if
end sub

while key(27)=0
clsA 0,0,0,40
color 0,0,0,255
drawline 0,0,799,599
color 200,200,200,255
color 255,255,255,255
fillcircle 25,300,25
fillcircle 775,300,25
drawlightning(50,300,750,300,400)
redraw
wait 100
wend
winExit


Demo Example 2
Code: [Select]
include "sdl.inc"
window 640,480,1
single m1,m2,m4,m3,m5

while key(27)=0
for y=0 to 480
    m3 = m3+1
    m1 = m1+9
    m2 = m1
    m6 = m3
for x=0 to 640
    m4 = m4+19
    m2 = m2+15
   m6=m6+1
    r = abs(sin(m1/100)+sin(m2/100)+sin((m1+m4)/600))*(255/3)
    g = abs(sin((m6)/50) + sin(m3/100))*250
    b = abs(sin(x*y/100000)*200)
    Color r,g,b,255
    SetPixel x, y
next
next
redraw
'SetFps 10
wend
winExit
 

Demo Example 3
Code: [Select]
include "sdl.inc"
window 512,512,1

TgaLoad 1,"tga/baum.tga"
TgaLoad 2,"tga/wmas.tga"

single a
SetMousePos 200,200

while key(27)=0
cls 0,0,0
mx = xMouse()
my = yMouse()

SprPos 2,0,0,1,1
SprBright 1,mx,my,0,100
SprInvers 1,mx+128,my,0
SprDarken 1,mx+256,my,0,50

SprBRA 1,mx,my+128,0, 50, a,80
SprDRA 1,mx+128,my+128,0,150,-a,55
SprBRA 1,mx+256,my+128,0, 0, a,255
a +=6

redraw
setfps 60
wend
winExit



[attachment deleted by admin]

Aurel

  • Guest
Re: New SDL Library
« Reply #1 on: September 03, 2015, 11:02:16 AM »
I am wondering what might be a SDL library?
 ;D ;D ;D ;D

Peter

  • Guest
Re: New SDL Library
« Reply #2 on: September 05, 2015, 05:09:59 AM »
Quote
I am wondering what might be a SDL library?

Pozdrav iz grobnica
Is bananium rubens5-sdl for all groups.   ;D

Peter

  • Guest
Re: New SDL Library
« Reply #3 on: September 05, 2015, 05:17:18 AM »
Sdl Demo 4
Code: [Select]
include "sdl.inc"
window 320,240,1

int frames[2], float fv
frames[1] = 15

TgaLoad  1,"tga/oma.tga"
LoadFont 1,"sdlfonts/tahoma.ttf",12

while Key(27)=0
cls 255,255,255
SprSize 1,260,140,frames[0],2.5
SprSize 1, 64,140,frames[1],2.5

fv = fv+.13
if fv >=1.0
   fv =0.0
   frames[1] = frames[1]-1
   frames[0] = frames[0]+1
   if frames[0]=16 then frames[0]=0
   if frames[1] <0 then frames[1]=15
endif
textcolor 2,0,255
text "GRANDMOTHER DANCE",80,20,1
redraw
wait 10
wend
winExit



[attachment deleted by admin]

Peter

  • Guest
Re: New SDL Library
« Reply #4 on: September 06, 2015, 02:12:53 AM »
Sdl Demo 5
sunset flower
Code: [Select]
include "sdl.inc"
window 640,480,1

float i, a, c
r=rand(128,255):g=rand(128,255):b=rand(128,255)

Sub DrawCenter(sys x,y)
    color r,g,b,100
    fillcircle x,y,80
    color b,g,r,128
    drawcircle x,y,120
End Sub

while key(27)=0
clsA 28,28,28,128

for i=0 to 360 step 15
    x=sin(i+a) * 100 + 330
    y=cos(i+a) * 100 + 250
    DrawCenter x, y
next
redraw
setfps 24
a +=.05
if a >=360 then
   a=-a
end if
c +=.1
if c>=2 then
   c=0
   r=rand(96,255):g=rand(128,255):b=rand(64,255)
end if
wend
winExit

Peter

  • Guest
Re: New SDL Library
« Reply #5 on: September 06, 2015, 02:42:13 AM »
Sdl Demo 6
Sirpinski 3D
Code: [Select]
include "sdl.inc"
Window 640,480,1

cls 0,0,0
single x[3], y[3], c, px, py
x[1] =320
x[2] =0
x[3] =640
y[1] =0   
y[2] =480
y[3] =480
c = Rand(1,3)
px= x[c]
py= y[c]

For i=0 To 15000
   c= Rand(1,3)
   px = px + (x[c] - px) / 2
   py = py + (y[c] - py) / 2
   color  245,202,180,255
   DrawPoint px,py,14
   color 240,102,80,255
   DrawPoint px,py,12 
Next

WaitKey
Quit



Peter

  • Guest
Re: New SDL Library
« Reply #6 on: September 06, 2015, 08:31:23 AM »
Sdl Demo 7
Caveman Synapse
Code: [Select]
include "sdl.inc"
Window 800,600,1

single ce,cm,newRe,newIm,oldRe,oldIm,zoom=2,mx,my
sys max=256,x,y,i

w = scrW
h = scrH
ce = -.99
cm =  0.27015

For x=0 to w
For y=0 to h
    newRe = 2.5 * (x-w*.5) / (.7*zoom*w) + mx
    newIm = (y-h*.5) / (.5*zoom*h) + my
For i=0 To max
    oldRe = newRe
    oldIm = newIm
    newRe = oldRe * oldRe - oldIm * oldIm +ce
    newIm = 2 * oldRe * oldIm + cm
    if((newRe * newRe + newIm * newIm) >7) Then exit for
Next
    color i*6,45,i*9,255
    Setpixel x,y
Next
Next

WaitKey()
WinExit

jack

  • Guest
Re: New SDL Library
« Reply #7 on: September 06, 2015, 04:43:21 PM »
 8)

Peter

  • Guest
Re: New SDL Library
« Reply #8 on: September 07, 2015, 05:52:46 AM »
Hi Jack!

Peter

  • Guest
Re: New SDL Library
« Reply #9 on: September 07, 2015, 05:55:31 AM »
Sdl Demo 8
Sdl_Mandelbrot  and an  Accessoire.

Code: [Select]
include "sdl.inc"
window 512,512,1

single bx,by
single bw=256*2
single bh=256*2
single sx=-2.2
single sy=-1.7
single sw=3.4
single sh=3.4

cls 255,255,255

for x=bx to bx+bw
for y=by to by+bh
    gx=(x-bx)/bw*sw+sx
    gy=(y-by)/bh*sh+sy
    zx=gx
    zy=gy
for c=1 to 256
    col=c
    nzx=zx*zx - zy*zy + gx
    zy=2*zx*zy+gy
    zx=nzx
    if zx*zx + zy*zy >5 then
       col=c
       exit for
    end if   
next
r = GetR(col)*256+col*32*.5
g = GetG(col)*256+col*64*.5
b = GetB(col)*256+col*32*.8         
color r,g,b,255
setpixel x,y
next
next

waitkey
winExit

[attachment deleted by admin]

Peter

  • Guest
Re: New SDL Library
« Reply #10 on: September 08, 2015, 07:50:42 AM »
Sdl Demo 9
Alien Visit.
Code: [Select]
include "sdl.inc"
window 800,600,1
loadsprite 1,"bmp/stupid.bmp",1

float a,t,xp,yp,zp,xs,ys,w=0 
int xstars[400]
int ystars[400]

for x=0 to 400
    xstars[x] = rand(0,800)
    ystars[x] = rand(0,600)
next
while Key(27)=0
cls 0,0,0
for x=0 to 400
    color rand(64,255),rand(64,255),rand(64,255),255
    setpixel xstars[x],ystars[x]
next   
for t=0 to 360
    xp = 120 * cos(t*3) 
    yp = 120 * sin(t*w)   
    zp = (a*sin(t))/2
    xs = (200 + xp * 320 / 460)
    ys = (200 - yp * 320 / 460)
    sprite 1,200+xs+(-zp),100+ys+( zp),0
next
a +=1
if a >=440 then
   a= -a
   w +=1
   if w=14 then w=1
end if
redraw
wait 10
wend
winExit


[attachment deleted by admin]