Author Topic: More Sdl  (Read 3122 times)

0 Members and 1 Guest are viewing this topic.

Peter

  • Guest
More Sdl
« on: October 02, 2015, 06:41:43 AM »
Hello,
more sdl: example 21
Code: [Select]
include "sdl.inc"
loadwinIcon "bitmaps/happy.bmp"
window 1024,600,1
LoadFont 1,"sdlfonts/bullpen.ttf",34

type particle
  single x
  single y
  single xi
  single yi
  sys life
end type
particle pc[200]

int i, v, h, p1, p2,size=96
float a
LoadSprite 1,"bitmaps/happy.bmp",1

For i=0 to 100
    pc[i].x=0
    pc[i].y=0
    pc[i].xi=Rand(10,1000)/400 
    pc[i].yi=Rand(10,1000)/200 
    pc[i].life=1400
Next 

while Key(27)=0   
Cls 0,0,255       
For i=0 to 100
    iF pc[i].life then
       pc[i].x += pc[i].xi
       pc[i].y += pc[i].yi
       pc[i].life -=1
       pc[i].yi +=0.01
       iF pc[i].y > 500 then
          pc[i].yi = -pc[i].yi * 0.6
       End iF
    End iF     
Next
For i=0 to 100
    iF pc[i].life then
       size=pc[i].life*10/100
       Sprite 1,pc[i].x,pc[i].y,0
    Else
       For i=0 to 100
           pc[i].x=0
           pc[i].y=0
           pc[i].xi=Rand(10,1000)/300 
           pc[i].yi=Rand(10,1000)/200 
           pc[i].life=1400
       Next     
    End iF
Next
a +=.2
iF a >=1 then
   a=0
   v +=1
   iF v=15 Then v=0
End iF
h +=1
iF h=240 then h=0
textcolor 255,255,255
text "HAPPY EUROS",350,10,1
Redraw
wait 10
wend
winExit


[attachment deleted by admin]
« Last Edit: October 02, 2015, 11:52:01 AM by Peter »

Peter

  • Guest
Re: More Sdl
« Reply #1 on: October 03, 2015, 01:19:07 AM »
Hello,

Sdl Example 22: 3D Tree
Do you see a 3D effect?
Code: [Select]
include "sdl.inc"
window 640,480,1

LoadFont 1,"sdlfonts/rubic.ttf",24
TgaLoad  1,"tga/tree.tga"

for y=0 To 480 step 10
for x=0 To 640 step 10
    color rand(200,255),10,10,255
    drawcircle x,y,10
next
next
SprPos 1,0,0,1,1
textcolor 0,220,0
Text "3D TREE",16,8,1
waitkey
winExit





[attachment deleted by admin]

Peter

  • Guest
Re: More Sdl
« Reply #2 on: October 03, 2015, 03:31:07 AM »
Hi,
Sdl Example 23: 3D Cube
Code: [Select]
include "sdl.inc"
window 640,480,1

single a,b,x,y,z,u

while key(27)=0
cls 0,0,0
a = xmouse()/90
b = ymouse()/90

for x=-1 to 1 step 0.1
for y=-1 to 1 step 0.1
for z=-1 to 1 step 0.1
u = x
v = y
w = z
u2 = u * cos(a) - v * sin(a)
v2 = u * sin(a) + v * cos(a)
w2 = w
u = u2
v = v2
w = w2
u2 = u
v2 = v * cos(b) - w * sin(b)
w2 = v * sin(b) + w * cos(b)
u = u2
v = v2
w = w2
sx = 300 + u * (w+2) * 40
sy = 240 + v * (w+2) * 40
color 250,250,250,255
drawcircle sx,sy,40
next
next
next
textcolor 255,255,255
drawstring 10,10,"MOVE YOUR MOUSE POINTER"
redraw
wait 10
wend
winExit

Peter

  • Guest
Re: More Sdl
« Reply #3 on: October 03, 2015, 03:35:38 AM »
Hello,
Sdl Example 24: Colour Gradient
Code: [Select]
include "sdl.inc"
window 640,480,1

textcolor 255,255,255
drawstring 260,100,"WAIT..."

single j, angle, px, py, amp=30, frq, fg=2.5
sys c, i, fl, height=ScrH, width=ScrW, a=255

for i=-75 to height+75
    angle=0
    frq +=.002
for j=0 to width+75
    py=i+sin(rad(angle))*amp
    angle += frq
    r = abs(py-i)*255/amp
    g = 255-abs(py-i)*255/amp
    b = j*(255/(width+50))
for fl=0 to < fg
    fl +=1
    color r,g,b,a
    setpixel j-fl,py-fl
    setpixel j, py
    setpixel j+fl, py+fl
next
next
redraw
wait 10
next

waitkey
winExit

Peter

  • Guest
Re: More Sdl
« Reply #4 on: October 03, 2015, 03:59:04 AM »
Hello,
Sdl Example25: Fern Points
Code: [Select]
include "sdl.inc"
Window 640,500, 1

single a, b, c, d, e, f, newx, newy, xy[2]
sys r, wa
color 0,210,55,155

Sub DrawFern
r = Rand(0,100)
iF r <=10
   a = 0
   b = 0
   c = 0
   d = 0.16
   e = 0
   f = 0
ElseiF r > 1 and r <=86
   a = 0.85
   b = 0.04
   c = -.04
   d = 0.85
   e = 0
   f = 1.60
ElseiF r > 86 and r <=93
   a = 0.2
   b = -.26
   c = 0.23
   d = 0.22
   e = 0
   f = 0.16
Else
   a = -.15
   b = 0.28
   c = 0.26
   d = 0.24
   e = 0
   f = 0.44
EndiF
newx = ((a * xy[1]) + (b * xy[2]) + e)
newy = ((c * xy[1]) + (d * xy[2]) + f)
xy[1] = newx
xy[2] = newy
SetPixel -xy[1]*40+175,-xy[2]*40+480
SetPixel  xy[1]*40+475,-xy[2]*40+480
SetPixel  xy[1]*20+320,-xy[2]*20+230
SetPixel -xy[1]*20+340, xy[2]*20+230
End Sub

Cls 0,0,0
wa=0
Do
For i=1 to 10
    wa++
    iF wa=50000 Or Key(27) Then Exit Do
    DrawFern
Next
End Do

textcolor 255,255,255
DrawString 10,10,"Fern Points:  " + wa
WaitKey
winExit

JRS

  • Guest
Re: More Sdl
« Reply #5 on: October 03, 2015, 04:30:13 AM »
Curious. Is your work passing Jockhen's (JJ) review? (baring everything you do being ridiculously slow)

Peter

  • Guest
Re: More Sdl
« Reply #6 on: October 03, 2015, 05:50:26 AM »
Quote
Curious. Is your work passing Jockhen's (JJ) review? (baring everything you do being ridiculously slow)

Hi John,
I do not understand what you wrote here?

What is Jockhen's (JJ) review ?? And what is  "baring everything you do being ridiculously slow)" ??

« Last Edit: October 03, 2015, 07:18:52 AM by Peter »

JRS

  • Guest
Re: More Sdl
« Reply #7 on: October 03, 2015, 09:06:16 PM »
You're safe.  ::)

Peter

  • Guest
Re: More Sdl
« Reply #8 on: October 04, 2015, 04:46:39 AM »
Quote
You're safe.

thanks for rescue.

example: ufo observation.
Code: [Select]
include "sdl.inc"
window 386,240,1

int j,uz,ux,uy=40,b1,b2,b3,b4
float us

dim xstars(200) as int
dim ystars(200) as int
dim sstars(200) as int
dim colors(200) as int

TgaLoad 1,"ufos/baum.tga"
TgaLoad 2,"ufos/gate.tga"
TgaLoad 3,"ufos/moon.tga"
TgaLoad 4,"ufos/ufos.tga"

for j=1 to 200
    xstars(j) = Rand(1,386)
    ystars(j) = Rand(1,120)
    sstars(j) = Rand(1,4)
    colors(j) = Rand(64,255)
next   

while Key(27)=0
cls 0,255,0
color 0,0,0,255
fillrect 0,0,388,140
SprPos 2, 0 ,102,1,1
SprPos 2,128,102,1,1
SprPos 2,256,102,1,1
   
SprPos 1, 0 ,100, 1,1.2
SprPos 1,100,100, 1,1.34
SprPos 1,192,100, 1,0.8
SprPos 1,288,100, 1,1.1
SprPos 3, 10, 10, 1,1

for j=1 to 200
    color colors(j),colors(j),colors(j),255
    DrawPoint xstars(j),ystars(j),2
next

SprAnimate 4,ux + sin(rad(us))*60 ,uy+ cos(rad(us)) *10 ,uz
SprAnimate 4,ux+(-sin(rad(us))*60),uy+ cos(rad(us)) *20 ,uz
SprAnimate 4,ux+(-sin(rad(us))*30),uy+(-cos(rad(us))*10),uz
   
ux +=1
if ux >=412 then ux=-24
uz +=1
if uz=3 then uz=0
us +=1
if us >=360 then us=-us
Redraw
wait 10   
Wend
WinExit


   

[attachment deleted by admin]
« Last Edit: October 04, 2015, 05:43:40 AM by Peter »