Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 24, 2012 12:37:38 GMT -5
Hi, Here a further demo. Construction of a Atom. include "library.b2d"
Window 640,480,0 ColorKey 0,0,0
Dim a,b,zx,zy,x,y,z,y2,x2,y3,x3,z2,sx,sy,drop,bunt drop= LoadBmp("bmp/drop.bmp",64,64,0) bunt= LoadBmp("bmp/bunt.bmp",320,240,0)
While EscKey()=0 iF Key.Pressed(0) Then WinEnd SetBmp bunt,0,0,2,2,0 zx = zx + 2 zy = zy + 2 a = zx / 99 b = zy / 99 For x= -1 To 1 For y= -1 To 1 For z= -1 To 1 y2 = y x2 = x * cos(a) - y2 * sin(a) y3 = x * sin(a) + y2 * cos(a) y2 = y3 y3 = y2 * cos(b) - z * sin(b) z2 = y2 * sin(b) + z * cos(b) sx = x2 * (z2 + 2) * 35: iF sx >340 Then sx=340 sy = y3 * (z2 + 2) * 35: iF sy >280 Then sy=280 SetBmp drop,sx+300, sy+200,(z2+2)/2.5,(z2+2)/2.5,0 Next 'Events Next Next Flip WaitFPS 60 Wend WinEnd
Attachments:
|
|
|
Post by matthew on Feb 25, 2012 6:13:52 GMT -5
Very impressive Peter
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 25, 2012 10:52:04 GMT -5
Thank you Matthew, This demo is similar. include "library.b2d"
Dim x,y,z,x1,y1,z1,x2,y2,z2,xx,yy,zz,xm,ym,xp,yp,zp,fp,pk Dim dp,sw,rw,ih,pi,x3,y3,z3,Color,gx,ay,dragon
Dim xa(8) Dim ya(8) Dim za(8) Dim xb(8) Dim yb(8) Dim zb(8) Dim a1(8) Dim a2(8) Dim b1(8) Dim b2(8)
Window 640,480,0 Font= Graphics.CreateFont("times",24) ColorKey 0,0,0 dragon= LoadBmp ("bmp/dragon.bmp",72,72,0)
Initial()
While EscKey() =0 ClsColor 200,200,248 Text Font,254,16,"3D Test", 255,255,0 Text Font,20,40,"Use arrow keys",255,255,0 CalCulation() For pk =0 To ih For dp =0 To pk SetBmp dragon,a2(dp)-40,b2(dp)-40,1,1,0 Next Next Flip iF RightKey() Then gx = gx - 1 * pi / 360 iF UpKey() Then ay = ay - 1 * pi / 360 iF LeftKey() Then gx = gx + 1 * pi / 360 iF DownKey() Then ay = ay + 1 * pi / 360 Wend WinEnd
Sub Initial() ih = 8 fp = 512 xm = 320 ym = 240 sw = 1 rw = 6 xa(0) = 50:xa(1) =-50:xa(2) = 50:xa(3) = 50:xa(4) = 50:xa(5) = 50:xa(6) =-50:xa(7) = 50 ya(0) = 50:ya(1) = 50:ya(2) =-50:ya(3) =-50:ya(4) = 50:ya(5) =-50:ya(6) =-50:ya(7) =-50 za(0) = 50:za(1) = 50:za(2) = 50:za(3) =-50:za(4) = 50:za(5) = 50:za(6) = 50:za(7) = 50 xb(0) = 50:xb(1) =-50:xb(2) = 50:xb(3) =-50:xb(4) =-50:xb(5) =-50:xb(6) =-50:xb(7) = 50 yb(0) = 50:yb(1) = 50:yb(2) =-50:yb(3) =-50:yb(4) = 50:yb(5) =-50:yb(6) = 50:yb(7) = 50 zb(0) =-50:zb(1) =-50:zb(2) =-50:zb(3) =-50:zb(4) = 50:zb(5) = 50:zb(6) = 50:zb(7) = 50 End Sub
Sub Math() x1 = xx * cos(gx) - zz * sin(gx) y1 = yy z1 = xx * sin(gx) + zz * cos(gx) x2 = x1 + xp y2 = y1 * cos(ay) - z1 * sin(ay) + yp z2 = y1 * sin(ay) + z1 * cos(ay) + zp x = xm + (x2 * fp) / (fp - z2) y = ym + (y2 * fp) / (fp - z2) End Sub
Sub Calculation() For pk =0 To ih For dp =0 To pk xx = xa(dp) yy = ya(dp) zz = za(dp) Math() a1(dp) = x b1(dp) = y xx = xb(dp) yy = yb(dp) zz = zb(dp) Math() a2(dp) = x b2(dp) = y Next Next End Sub
Attachments:
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 25, 2012 12:33:05 GMT -5
Hi,
Some words to library. If you want to do some tests with this library, never click on the Window close button! Brutus2D has some difficulties therewith. Your program will not end, is still running in the Task manager. Use always ( EscKey() ). This is valid for a windowed mode.
Here another demo.
include "library.b2d"
Window 800,600,0
Dim fc,xq,yq,xo1,yo1,mo1,r,g,b,clic Dim a0,a1,r0,r1,r2,x1,x2,y1,y2,st,i
xq=400 yq=300
While EscKey()=0 ClsColor 0,0,0 r= Rand(64,255) g= Rand(64,255) b= Rand(64,255)
r0= Rand(1,5)/10: r1= Rand(1,5)/10: r2= Rand(1,5)/10 fc= Rand(1,200)/10: st= Rand(1,10*10)/100 xol=0 yol=0 mol=0 For i=0 To 120 step st a0=(i/r0)*(2*pi) a1=((i/r1)*(2*pi))*-1 x1=xq+(sin(a0)*((r0-r1)*fc))*20 y1=yq+(cos(a0)*((r0-r1)*fc))*20 x2=x1+(sin(a1)*((r2)*fc))*20 y2=y1+(cos(a1)*((r2)*fc))*20 iF mol= 0 Then mol= 1 xol= x2 yol= y2 Else Graphics.SetLine xol,yol, x2,y2,ARGB(255,r,g,b) xol=x2 yol=y2 End iF Events Next Flip Graphics.SetFPS 14 Wend WinEnd
|
|
|
Post by matthew on Feb 26, 2012 7:48:30 GMT -5
More nice demos Peter
|
|
|
Post by Guilect on Feb 26, 2012 11:20:38 GMT -5
In B2D the red X in the upper right of the window is treated like a key, and the programmer needs to look for the user clicking it. example:
sub main()
if (graphics.initialize(800,600) <> True) then exit sub graphics.setTitle "Demo" key.initialize background = graphics.loadimage("back.bmp") do while bRunning = True if key.pressed(1) or key.pressed(0) = True then bRunning = False graphics.clear graphics.setimage background graphics.display loop key.terminate graphics.terminate
end sub
Call Main()
When the user presses the escape or 'X' key then the while-loop stops and the program terminates properly.
Optionally, you can use the virtual key constants:
if key.pressed(vk_ESCAPE) or key.pressed(vk_WINDOWX) = True then bRunning = False
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 26, 2012 12:15:41 GMT -5
Hi Guilect,
I know your key-using. You say that WindowX key is treated as a key!
Why does not go this experiment here? My defined ASCKEY() routine works well. But KEY.PRESSED(vk_windowX) does not go!
Try my source code. Try once ESCAPE Key. Then try once the ( red X button.)
What is going wrong here?
include "library.b2d"
Window 640, 480, 1 Font= Graphics.CreateFont("roman",16) ColorKey 0,0,0
While Key.Pressed(vk_windowX)=False and EscKey()=0 Text Font,100,200,"HELLO, ONLY ASCKEY GOES",255,255,255 Flip Wend WinEnd
|
|
|
Post by Guilect on Feb 26, 2012 14:32:33 GMT -5
It has been many years, but I seem to recall that putting the key reads in the While statement did not work (as you are seeing). So just use the format in my example and all will be happy.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Feb 26, 2012 17:36:01 GMT -5
Okay, nothing is perfect.
Another MandelBrot with short algorithms.
include "library.b2d"
Window 320, 240, 1 Font= Graphics.CreateFont("times",18) ColorKey 255,255,255
Dim x,y,zx,zy,cx,cy,tmp,MaxIter,zoom,Iter MaxIter=255:zoom=120
ClsColor 255,255,255 Text Font,100,100,"WAIT...",0,0,0 Flip
For y=0 To Height For x=0 To Width zx=0 zy=0 cx= (x-220)/zoom cy= (y-130)/zoom Iter = MaxIter while zx * zx + zy * zy < 4 and iter > 0 tmp = zx * zx - zy * zy + cX zy = 2.0 * zx * zy + cY zx = tmp iter = iter -1 wend Graphics.SetPoint x,y, ARGB(255,iter,y,y) Next Events Next Graphics.SetTitle "PRESS SPACE BAR" Flip WaitKey() WinEnd
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Mar 1, 2012 10:18:00 GMT -5
Hi, A Plasma demo. include "library.b2d"
Window 640, 480, 1 Fnt = Graphics.CreateFont("times",24)
Dim x, y, c, r, g, b, ix
Dim Cols0(255) Dim Cols1(255) Dim Cols2(255)
for ix=0 to 255 Cols0(ix) = abs(128-127*sin(ix*pi/32)) Cols1(ix) = abs(128-127*sin(ix*pi/64)) Cols2(ix) = abs(128-127*sin(ix*pi/128)) next
ClsColor 255,0,0 Text Fnt,180,32,"PLASMANIA 2012", 255,150,200 Text Fnt,180,62," WAIT A WHILE ", 255,150,200 Flip
for y=1 to height for x=1 to width c= abs(sin(x/35)*128+sin(y/28)*32+sin(x+y)/16*64) if c >255 then c = c-256 end if if c <0 then c = 256+c end if r = cols0(c) if r >255 then r = r-256 end if if r <0 then r = 256+c end if g = cols1(c) if g >255 then g = g-256 end if if g <0 then g = 256+c end if b = cols2(c) if b >255 then b = b-256 end if if b <0 then b = 256+c end if SetPixel x,y, r,g,b next next Flip waitKey() WinEnd
And somewhat rain. include "library.b2d"
Window 640, 480, 0 ColorKey 0,0,0 Fnt = Graphics.CreateFont("times",24) Dim x(500), y(500), z(500) Dim i,pic,drop pic = LoadBmp("bmp/rainbow.bmp",320,240,0) drop= LoadBmp("bmp/mydrop.bmp",32,32,0)
For i=0 To 500 x(i) = Rand(0,640) y(i) = Rand(0,460) z(i) = Rand(1,3) Next
While EscKey()=0 SetBmp pic,0,0,2,2,0 For i=0 To 500 y(i) = y(i) + z(i) if y(i) >480 Then x(i) = Rand(0,649) y(i) = Rand(0,1) z(i) = Rand(1,3) End if SetBmp drop,x(i),y(i),.4,.4,0 Next Flip Wend WinEnd
Attachments:
|
|
|
Post by matthew on Mar 1, 2012 23:06:33 GMT -5
The Plasma Demo looked very good Peter.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Mar 7, 2012 3:16:37 GMT -5
Hi Matthew,
Do you know OxgenBasic? I have many projects and games here. It is a really fast compiler. Is worth a visit.
|
|
|
Post by matthew on Mar 9, 2012 16:21:14 GMT -5
Yes Peter, I've visited the Oxygen Forum before & seen some of your posts. You've written some interesting programs.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Mar 18, 2012 14:43:57 GMT -5
Hi Matthew,
Is over now with Brutus2D. I try now SdlBasic. The first game was written and the source code is given.
At the moment is a bit bored there. But I want see what the future has for me. Otherwise, I am with OxygenBasic, my number one here.
|
|
Deleted
Deleted Member
Posts: 0
|
Post by Deleted on Mar 27, 2012 11:06:17 GMT -5
|
|