From d5f88772a23528ef4f29faede4b4babb2ed1e164 Mon Sep 17 00:00:00 2001 From: Aurel Date: Sat, 20 May 2023 14:47:33 +0200 Subject: [PATCH 01/49] Create InputBox.bas --- Examples/InputBox.bas | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Examples/InputBox.bas diff --git a/Examples/InputBox.bas b/Examples/InputBox.bas new file mode 100644 index 0000000..e0d391f --- /dev/null +++ b/Examples/InputBox.bas @@ -0,0 +1,40 @@ +'create input box ( edit control used for input text) +ptr hbox ,hImg,hb +ptr wmKeyDown, wmCommand +str sText, cStr +var wp, tx ,ty +'LoadImage(0, strRes, imgType, imgW, imgH, cFlag) +LoadImg hImg,"microgirls.bmp" ,0, 264,236, 24 +wcolor 200,190,200 : swap +cStr = "test text" +'syntax INPUTBOX handle , x,y,w,h,text +ShowImgT hImg,400,80,264,236 :swap +INPUTBOX hbox , 10, 350, 300, 23 , "micro(A)" +print 10,10,"Testing IDOK event under WM_COMMAND message in micro(A) v10" +GETTEXT hbox , sText +print 10,400, sText : swap +ty = 50 + +'events................. +WinMsg wmCOMMAND +'in this case hWparam is LoWord(wParam) -> control ID +hWparam wp + +'if is -> IDOK / which is 1 +if wp = 1 + tx = 10 : ty = ty + 20 + get_text() + print tx,ty,sText + swap +endif + +EndWm +'.................. + + +func get_text() + GETTEXT hbox, sText + ' rect 10,400,100,23 + ' fcolor 200,230,250 : print 10,400, sText : swap + +endfn From c15b2bc89decb3a3543ac44739fb170e98cb94a0 Mon Sep 17 00:00:00 2001 From: Aurel Date: Sat, 20 May 2023 14:51:26 +0200 Subject: [PATCH 02/49] Create InterpreterKiller.bas --- Examples/InterpreterKiller.bas | 71 ++++++++++++++++++++++++++++++++++ 1 file changed, 71 insertions(+) create mode 100644 Examples/InterpreterKiller.bas diff --git a/Examples/InterpreterKiller.bas b/Examples/InterpreterKiller.bas new file mode 100644 index 0000000..6328166 --- /dev/null +++ b/Examples/InterpreterKiller.bas @@ -0,0 +1,71 @@ +' benchmark called interpreter killer by Ed Davis +var start,endtime,time +var accum,count,leftedge,rightedge,topedge, bottomedge,xstep ,ystep,maxiter,thechar,x,y,x0,y0,i,temp,xx,yy,xy,count3 +wcolor 0,0,0 : fcolor 120,140,200 : print 10,10,"Interpreter killer by Ed Davis":swap +accum = 0 +count = 0 +GETTICK start +while count < 1545 + leftedge = -420 + rightedge = 300 + topedge = 300 + bottomedge = -300 + xstep = 7 + ystep = 15 + + maxiter = 200 + + y0 = topedge + while y0 > bottomedge + x0 = leftedge + while x0 < rightedge + y = 0 + x = 0 + thechar = 32 + xx = 0 + yy = 0 + i = 0 + xy = xx + yy + while xy < 800 & i < maxiter + xx = int((x * x) / 200) + yy = int((y * y) / 200) + + if xy > 800 + thechar = 48 + i + if i > 9 + thechar = 64 + endif + else + temp = xx - yy + x0 + if x < 0 & y > 0 | x > 0 & y < 0 + y = (-1 * int((-1 * x * y) / 100)) + y0 + else + y = int(x * y / 100) + y0 + endif + x = temp + endif + + + i = i + 1 + fcolor 220,220,120:rect 5,45,100,23: print 10,50,i :swap + wend + x0 = x0 + xstep + accum = accum + thechar + wend + y0 = y0 - ystep + wend + + count3 = round(count /300) + if count3 = 0 + 'blue + fcolor 100,160,180::rect 5,95,150,23: print 10,100,accum:swap + endif + count = count + 1 +'green +fcolor 100,160,100::rect 5,145,150,23:print 10,150,count:swap +wend + +print 10,200,accum +GETTICK endtime +time = (endTime - start) / 1000 +fcolor 200,200,240: print 10,250,time : swap From aba5e2c6fa86c62269fd295d929a899fc710fa80 Mon Sep 17 00:00:00 2001 From: Aurel Date: Sat, 20 May 2023 14:52:32 +0200 Subject: [PATCH 03/49] Create Hills.bas --- Examples/Hills.bas | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 Examples/Hills.bas diff --git a/Examples/Hills.bas b/Examples/Hills.bas new file mode 100644 index 0000000..5b294da --- /dev/null +++ b/Examples/Hills.bas @@ -0,0 +1,35 @@ +' Hills from AllegroBasic by Cyb to micro(A) by Aurel +var xmax,ymax,i,rr,gg,bb,top,start,x,y +var red,green,blue,factor,offrand,offset, mount +xmax=640 :ymax=480 : wcolor 0,0,0 : fcolor 200,180,100 +print 10,10,"Lakeside" + +start = 100 +rr=70:gg=90:bb=70 +mount = 1 +while mount < 7 + offset=0 + y=start + +label doLoop + factor = (rand(9)-4)/2 + offrand = offset + rand(7) + + x=offset + While x < offrand + y = y + factor + fcolor rr,gg,bb : line x,y,x,ymax + x=x+1 + wend + offset=x +'fcolor 100,100,160 : print 10,30,offset + If offset < xmax : goto doLoop : endif + + rr=rr-20: gg=gg-10 : bb=bb-10 + If rr < 0 : rr=0 : EndIf + If gg < 0 : gg=0 : EndIf + If bb < 0 : bb=0 : EndIf + start = start + 20 + rand(40) +mount = mount + 1 +swap +wend From 699dbdbe92381acc2ef4399aea1a260fe1f72b95 Mon Sep 17 00:00:00 2001 From: Aurel Date: Sat, 20 May 2023 14:54:00 +0200 Subject: [PATCH 04/49] Create Henon.bas --- Examples/Henon.bas | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Examples/Henon.bas diff --git a/Examples/Henon.bas b/Examples/Henon.bas new file mode 100644 index 0000000..57467c5 --- /dev/null +++ b/Examples/Henon.bas @@ -0,0 +1,37 @@ +' orbits of Henon from toy528 +var a,sc,ox,oy,ly,lx,x,y,xx,n, ABS_LXLY ,px,py,red,green,blue +a= -10.1 : sc=175 : ox=400 : oy=240 +wcolor 0,0,0 : fcolor 120,140,200 : print 10,10,"Orbits of Henon" + +while a < 1 +fcolor 0,0,0 :rect 0,0,800,600 'cls +fcolor 120,140,200 : print 10,10,"Orbits of Henon" + +x = -0.1 +while x < 0.8 + y = -0.1 + while y < 0.8 + lx = x : ly = y +'--------------------------------------------------------- + n=1 + while n < 40 + xx = lx*cos(a)-(ly-lx*lx)*sin(a) + ly = lx*sin(a)+(ly-lx*lx)*cos(a) + lx = xx + ABS_LXLY = abs(lx+ly) + If ABS_LXLY > 300 : n=500 : EndIf + px = ly*sc+ox : py = lx*sc+oy + red=150+x : green=100+y : blue=200+x + fcolor red,green,blue : pset px,py + n=n+1 + wend + + y=y+0.05 + wend + +x=x+0.05 +swap + wend + +a=a+0.5 'play with value 0.005 to 0.5 give inteesting shapes +wend From 268e6b1d4c30ee44c1a8a28baa0478d042c29c33 Mon Sep 17 00:00:00 2001 From: Aurel Date: Sat, 20 May 2023 14:55:26 +0200 Subject: [PATCH 05/49] Create HeartShape.bas --- Examples/HeartShape.bas | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Examples/HeartShape.bas diff --git a/Examples/HeartShape.bas b/Examples/HeartShape.bas new file mode 100644 index 0000000..8c00d20 --- /dev/null +++ b/Examples/HeartShape.bas @@ -0,0 +1,24 @@ +' heart shape +'simple ploting with pixels +var x,y,r,a +wcolor 0,0,100 : fcolor 220,200,0 + +label start +r = 10 + +x = 200 + (r * 16 * sin(a) * sin(a) * sin(a)) +y = 200 + ( -r * ( 17 * cos( a) -8 * cos(2*a) +1.75 * cos(2*a) - cos(2*a)) ) + + + +circle x,y,3 + +a=a+0.01 + +if a < 6.28 +goto start +endif + + + +print 10,10,"simple ploting with circles - Heart curve" : swap From af1ef892e4f9cff07d7a7588b01d3f0e84337005 Mon Sep 17 00:00:00 2001 From: Aurel Date: Sat, 20 May 2023 14:56:38 +0200 Subject: [PATCH 06/49] Create GuessMyNumber.bas --- Examples/GuessMyNumber.bas | 86 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 86 insertions(+) create mode 100644 Examples/GuessMyNumber.bas diff --git a/Examples/GuessMyNumber.bas b/Examples/GuessMyNumber.bas new file mode 100644 index 0000000..737524c --- /dev/null +++ b/Examples/GuessMyNumber.bas @@ -0,0 +1,86 @@ +' guess my number ? micro(A) +ptr hbox ,hImg,hb +ptr wmKeyDown, wmCommand, wp +str sText, cStr , resText +var keyN ,tx ,ty ,turn ,newGame , randNumber , result +'LoadImage(0, strRes, imgType, imgW, imgH, cFlag) +LoadImg hImg,"crazyNumbers.bmp" ,0, 264,236, 24 +wcolor 200,190,200 : swap +cStr = "test text" +'syntax INPUTBOX handle , x,y,w,h,text +ShowImgT hImg,400,80,264,236 :swap +INPUTBOX hbox , 10, 350, 300, 23 , "enter number (1-10)" +print 10,10,"GUESS THE NUMBER ...in micro(A) v10" +print 10,40,"press key N for NEW GAME!" +GETTEXT hbox , sText +print 10,400, sText : swap +ty = 50 +print 400,40,"NEW GAME":swap +fcolor 220,200,150 : rect 470,38,30,24 : print 480,40,newGame : swap +'events................. +WinMsg wmCOMMAND +'in this case hWparam is LoWord(wParam) -> control ID +hWparam wp + +'if is -> IDOK / which is 1 +if newGame = 1 +if wp = 1 + tx = 10 : ty = ty + 20 + get_text() + get_result() + fcolor 0,0,0 : print tx,ty,result : print (tx + 40) ,ty , resText + swap + 'check if turn > 3 then reset game + if turn = 4 : newGame = 0 : SETTEXT hbox,"END": setfocus 0 :setfocus hbox: endif +endif +endif + +EndWm +'.................. +WinMsg wmKeyDown + +hWparam keyN +'vkN -> 78 +if keyN = 78 + if newGame = 0 + newGame = 1 + 'set random number + randNumber = RAND(10) + 'show rand number + fcolor 120,150,120 : rect 8,428,30,24 : print 14,430,randNumber :swap + 'set turn to 1 + turn = 1 + fcolor 220,200,150 : rect 470,38,30,24 : print 480,40,newGame : swap + 'print 480,40 ,turn :swa + endif +endif + +EndWm + +func get_text() + GETTEXT hbox, sText +endfn + +func get_result() + result = VAL(sText) + 'test typed number + print 50,430, result + '1. + if result > randNumber + resText = "result is larger than number!" + endif + '2. + if result < randNumber + resText = "result is lower than number!" + endif + '3. + if result = randNumber + resText = "BINGO..you guess the number!" + endif + + + turn = turn + 1 +endfn + + + From 5afa911386c3c39780c88ed764e49599091af757 Mon Sep 17 00:00:00 2001 From: Aurel Date: Sun, 21 May 2023 21:14:11 +0200 Subject: [PATCH 07/49] Create QuickSort.bas --- Examples/QuickSort.bas | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Examples/QuickSort.bas diff --git a/Examples/QuickSort.bas b/Examples/QuickSort.bas new file mode 100644 index 0000000..7237a5d --- /dev/null +++ b/Examples/QuickSort.bas @@ -0,0 +1,34 @@ +' Quick Sort in micro(A) by nOOb author of RCBasic + wcolor 0,0,0 : fcolor 150,180,240 + var startTime,endTime,time + var sort, index, itemCount, temp, i ,hasChanged, counter, tmp, j + itemCount = 1000 + var item[itemCount] + print 10,10,"Quick Sort micro(A)..please wait!":swap + 'before Sort...................... + i=1 + while i < itemCount + item[i] = rand(100) + i = i + 1 + wend + '................................. + 'ticks start + GETTICK startTime + i = 1 + tmp = 0 + while i < itemCount + j = i + while j < itemCount + if item[j] < item[i] + tmp = item[i] + item[i] = item[j] + item[j] = tmp + endif + j = j + 1 + wend + i = i + 1 + wend + 'ticks end + GETTICK endtime + time = (endTime - startTime) / 1000 + fcolor 230,140,120: print 10,250,time : swap From d9b35eaefa664b17fc21d97a703d21cc92b1c483 Mon Sep 17 00:00:00 2001 From: Aurel Date: Sun, 21 May 2023 21:15:21 +0200 Subject: [PATCH 08/49] Create GridCells.bas --- Examples/GridCells.bas | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Examples/GridCells.bas diff --git a/Examples/GridCells.bas b/Examples/GridCells.bas new file mode 100644 index 0000000..dc34377 --- /dev/null +++ b/Examples/GridCells.bas @@ -0,0 +1,24 @@ +'draw cells with grey scale +var ly,lx,cell +'draw grid +grid() + + +func grid() +'clear screen +fcolor 0,0,0 : rect 0,0,800,512 : + +'draw shadows +ly=0 +While ly < 480 + 'draw by X + lx=0 + While lx < 768 + fcolor 60,80,60 : rect lx,ly,32,32 + cell = cell + 1 : swap + lx = lx + 32 + Wend +ly = ly + 32 +Wend + +endfn From 08c027debf0ec7c51593cea5f0857c229768062b Mon Sep 17 00:00:00 2001 From: Aurel Date: Sun, 21 May 2023 21:17:09 +0200 Subject: [PATCH 09/49] Create GDIdemo2.bas --- Examples/GDIdemo2.bas | 195 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 195 insertions(+) create mode 100644 Examples/GDIdemo2.bas diff --git a/Examples/GDIdemo2.bas b/Examples/GDIdemo2.bas new file mode 100644 index 0000000..04e1c30 --- /dev/null +++ b/Examples/GDIdemo2.bas @@ -0,0 +1,195 @@ +'test demo in gdi +ptr img,img2,img3,img4 +ptr wmKeyDown, wmTimer +var wp,ix,iy,p,ex,ey,eh,ev,bx,by,bf,hit ,turn ,hex,hey +var sc ,time gameLoop , keyleft, keyright ,keyup ,keydown +wcolor 200,200,210 +fcolor 180,60,150 : print 10,510,"give banana to monkey" +LoadImg img,"beach.bmp",0,640,400,16 +'program name... +print 10,440,"Coconut Monkey m(A)": print 10,460,"Pressing ESC back to starting positions" +'show img on window +ShowImgT img,0,0,640,360 +'load another image +LoadImg img2,"explorer1.bmp" , 0, 32, 32,16 +LoadImg img3,"monkey1.bmp" , 0, 32, 32,24 +LoadImg img4,"banana.bmp" , 0, 32, 32,16 +ShowImgT img3,300, 300, 32, 32 +ex = 300 : ey = 30 : ix = 300 : iy = 360 +updateScreen() : sc=0 +'show score rect +fcolor 80,80,100 :rect 524,470,68,24 +fcolor 245,118,0 : print 530,475,sc + + +goto game_loop + +'events... +WinMsg wmKEYDOWN + + +hWparam wp + +'vkLEFT ----------------------------------- +if wp = 37 + keyleft = wp +endif + +'vkRIGHT ?---------------------------------- +if wp = 39 + keyright = wp +endif + +'vkUP -------------------------------------- +if wp = 38 + keyup = wp + 'if iy > 0 : iy = iy - 5 :endif +endif + +'vkDOWN -------------------------------------- +if wp = 40 + keydown = wp + 'if iy < 360 : iy = iy + 5 :endif +endif + +'vkSPACE +if wp = 32 + if bf = 0 + bf = 1 + bx = ix + by = iy + endif +endif + + +'game loop if key not ESC +while wp ! 27 + +' powerful GOTO commad ..he he ! +goto game_loop +'flip backbuffer +swap + +wend + + +EndWm + +'--------------------------------------------- +label game_loop +'move left +if keyleft = 37 + if ix > 0 :ix = ix - 5 : endif + keyleft = 0 +endif +'move right +if keyright = 39 + if ix < 600 : ix = ix + 5 : endif + keyright = 0 +endif +'move up +if keyup = 38 + if iy > 0 : iy = iy - 5 :endif + keyup = 0 +endif +'move down +if keydown = 40 + if iy < 360 : iy = iy + 5 :endif + keydown = 0 +endif + +updateBack() +'updateScreen() +updateEnemy() +updateBullet() +testCollision() +updateScreen() +if hit = 1 : updateScore() : endif + +turn = turn + 0.1 +print 10,10,turn +swap + +'for testing purpose i use variable -> turn +if turn < 10000 : goto game_loop : endif + +'--------------------------------------------- + +func updateScreen() + fcolor 80,80,100 : rect 524,415,68,24 + fcolor 100,160,220 : print 530,420,ix + + fcolor 80,80,100 : rect 524,440,68,24 + fcolor 100,160,220 : print 530,445,iy + + 'Display bullet + if bf = 1 + ShowImgT img4, bx, by, 32, 32 + endif + + 'show enemy + ShowImgT img3, ex, ey, 32, 32 + 'show ship + ShowImgT img2,ix,iy,32,32 + +'update score + 'if hit = 1 + 'fcolor 80,80,100 :rect 524,470,68,24 + 'fcolor 245,118,0 : print 530,475,sc + 'endif + + +endfn + +func updateBack() + ShowImgT img,0,0,640,400 +endFn + +func updateShip() + ShowImgT img2,ix,iy,32,32 +endFn + +func updateBullet() + if bf = 1 + by = by - 1 + 'Bullet has left the screen. + if by < 0 : bf = 0 : endif + endif +endfn + +func updateEnemy() + eh = ex+5 + ev = ey+5 + if ex = 595 : ex = 0 : endif + if ex < 600 : ex = ex + 1 : endif + +endfn + +func testCollision() + hit=0 + hex = ex+ 32 + hey = ey + 32 + if hey < by + + hit = 1 + + 'endif + else + hit=0 + endif + + if hit = 1 + 'fcolor 220,100,100 + 'print ex,ey,"-XX-" + sc=sc+1 + hit=0 + endif + +endfn + +func updateScore() + fcolor 80,80,100 : rect 524,470,68,24 + fcolor 245,118,0 : print 530,475,sc +endfn + + From d44b868d26c5491d7e30b9aebad2bd14d973fa01 Mon Sep 17 00:00:00 2001 From: Aurel Date: Sun, 21 May 2023 21:18:54 +0200 Subject: [PATCH 10/49] Create GDIPlatform.bas --- Examples/GDIPlatform.bas | 147 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 147 insertions(+) create mode 100644 Examples/GDIPlatform.bas diff --git a/Examples/GDIPlatform.bas b/Examples/GDIPlatform.bas new file mode 100644 index 0000000..5848757 --- /dev/null +++ b/Examples/GDIPlatform.bas @@ -0,0 +1,147 @@ +'gdi 2d platformer demo +ptr img0,img1,img2,img3 +ptr wmKeyDown +var wp,ix,iy,p,ex,ey,lx,ly,bx,by,cell, tmpx,tmpy,tmpCell +wcolor 0,0,0:swap +'syntax-> LoadImg (1)hImg , (3)str "img.bmp" ,(5)imgType , (7)w , (9)h, (11)colorFlags + +'load another image +'LoadImage(0, strRes, imgType, imgW, imgH, cFlag) +LoadImg img0,"grid.bmp" ,0, 770,482, 24 +'green blocks +LoadImg img1,"bush.bmp" ,0, 32,32, 24 +'print 10,200,img1 +LoadImg img2,"player4.bmp",0, 32,32, 24 +'print 10,250,img2 +LoadImg img3,"alien.bmp",0, 32,32, 24 +'print 10,300,img3 +'ShowImgT img3,300, 300, 40, 40 +info() +bx = 128 : by = bx + 32 +updateBush() + +ex = 300 : ey = 300 + +'call intro screen +'LoadCells() + +'events... +WinMsg wmKEYDOWN + +hWparam wp +'vkLEFT ----------------------------------- +if wp = 37 + if ix > 0 : ix = ix - 32 : endif +endif + +'vkRIGHT ?---------------------------------- +if wp = 39 + if ix < 736 : ix = ix + 32 : endif +endif + +'vkUP -------------------------------------- +if wp = 38 + if iy > 0 : iy = iy - 32 :endif +endif + +'vkDOWN -------------------------------------- +if wp = 40 + if iy < 420 : iy = iy + 32 :endif +endif + +while wp ! 27 + + updateBack() + updatePlayer() + updatePosition() + 'updateBullet() + 'updateEnemy() + 'testCollision() + 'delay loop + ' p=0 + ' while p < 800 + ' p=p+0.01 + 'wend +swap + +wend + +EndWm + +func updatePosition() + fcolor 80,80,100 : rect 524,512,68,24 + fcolor 100,160,220 : print 530,514,ix + fcolor 80,80,100 : rect 610,512,68,24 + fcolor 100,160,220 : print 612,514,iy + 'calculate cell position using sprite upper/left pixel pos + tmpx = int((ix + 32) / 32) + 'tmpy = int((iy + 32) / 32) + tmpy = int(iy/32) + 1 + 'calc temp cell + 'tmpCell = tmpx + tmpy + tmpCell = int(iy/32)*24 + int(ix/32) + 1 + + fcolor 180,100,50 : rect 306,512,68,24 : print 310,514, tmpx + fcolor 180,100,50 : rect 406,512,68,24 : print 410,514, tmpy + 'show cell number + fcolor 50,170,100 : rect 206,512,68,24 : print 210,514, tmpCell + + updateBush() + +endfn +'---------------------------------------- +func updateBack() + ShowImgT img0,0,0,770,482 +endFn +'---------------------------------------- +func updatePlayer() + ShowImgT img2,ix,iy,32,32 +endFn +'----------------------------------------- +func updateEnemy() + if ex < 600 : ex = ex + 1 : endif + if ex = 598 : ex = 10 : endif + fcolor 0,0,0 : rect 0,0,800,512 + ShowImgT img3, ex, ey, 40, 40 +swap +endfn +'---------------------------------- +func updateBush() + ShowImgT img1,bx,by,32,32 +endFn + +'********************************************* +'*** I N T R O ****************************** +'********************************************* +func info() +'clear screen +fcolor 0,0,0 : rect 6,518,200,32 : + +fcolor 200,180,100: print 10,520,"GDI Level by Aurel" + +'swap +endfn + +func LoadCells() + grid() +endFn + +func grid() +'clear screen +fcolor 0,0,0 : rect 0,0,800,512 : + +'draw shadows +ly=0 +While ly < 480 + 'draw by X + lx=0 + While lx < 768 + fcolor 60,80,60 : rect lx,ly,32,32 + cell = cell + 1 : fcolor 60,60,60: print lx,ly,cell : swap + lx = lx + 32 + Wend +ly = ly + 32 +Wend +swap +endfn + From 66349a9f2112f016397f11c08c8dbd23dce0320b Mon Sep 17 00:00:00 2001 From: Aurel Date: Sun, 21 May 2023 21:21:28 +0200 Subject: [PATCH 11/49] Create GDILevel.bas --- Examples/GDILevel.bas | 158 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 158 insertions(+) create mode 100644 Examples/GDILevel.bas diff --git a/Examples/GDILevel.bas b/Examples/GDILevel.bas new file mode 100644 index 0000000..dee849b --- /dev/null +++ b/Examples/GDILevel.bas @@ -0,0 +1,158 @@ +'gdi 2d platformer demo +ptr img0,img1,img2,img3 +ptr wmKeyDown +var wp,ix,iy,p,ex,ey,lx,ly,bx,by,cell, tmpx,tmpy,tmpCell +var tbx ,tby ,bushCell ,score +wcolor 0,0,0:swap +'syntax-> LoadImg (1)hImg , (3)str "img.bmp" ,(5)imgType , (7)w , (9)h, (11)colorFlags + +'load another image +'LoadImage(0, strRes, imgType, imgW, imgH, cFlag) +LoadImg img0,"grid.bmp" ,0, 770,482, 24 +'green blocks +LoadImg img1,"bush.bmp" ,0, 32,32, 24 +'print 10,200,img1 +LoadImg img2,"player4.bmp",0, 32,32, 24 +'print 10,250,img2 +LoadImg img3,"alien.bmp",0, 32,32, 24 +'print 10,300,img3 +'ShowImgT img3,300, 300, 40, 40 +info() +bx = 128 : by = bx + 32 +updateBush() + +ex = 300 : ey = 300 + +'call intro screen +'LoadCells() + +'events... +WinMsg wmKEYDOWN + +hWparam wp +'vkLEFT ----------------------------------- +if wp = 37 + if ix > 0 : ix = ix - 32 : endif +endif + +'vkRIGHT ?---------------------------------- +if wp = 39 + if ix < 736 : ix = ix + 32 : endif +endif + +'vkUP -------------------------------------- +if wp = 38 + if iy > 0 : iy = iy - 32 :endif +endif + +'vkDOWN -------------------------------------- +if wp = 40 + if iy < 420 : iy = iy + 32 :endif +endif + +while wp ! 27 + + updateBack() + updatePlayer() + updatePosition() + 'updateBullet() + 'updateEnemy() + 'testCollision() + 'delay loop + ' p=0 + ' while p < 800 + ' p=p+0.01 + 'wend +swap + +wend + +EndWm + +func updatePosition() + fcolor 80,80,100 : rect 524,512,68,24 + fcolor 100,160,220 : print 530,514,ix + fcolor 80,80,100 : rect 610,512,68,24 + fcolor 100,160,220 : print 612,514,iy + 'calculate cell position using sprite upper/left pixel pos + tmpx = int((ix + 32) / 32) + 'tmpy = int((iy + 32) / 32) + tmpy = int(iy/32) + 1 + 'calc temp cell + 'tmpCell = tmpx + tmpy + tmpCell = int(iy/32)*24 + int(ix/32) + 1 + + fcolor 180,100,50 : rect 306,512,68,24 : print 310,514, tmpx + fcolor 180,100,50 : rect 406,512,68,24 : print 410,514, tmpy + 'show cell number + fcolor 50,170,100 : rect 206,512,68,24 : print 210,514, tmpCell + + if tmpCell = bushCell + score = score + 1 + fcolor 50,170,100 : rect 206,482,68,24 : print 210,484,score + ix = ix + 32 : updatePlayer() ' move player one cell + + endif + +endfn +'---------------------------------------- +func updateBack() + ShowImgT img0,0,0,770,482 +updateBush() +endFn +'---------------------------------------- +func updatePlayer() + ShowImgT img2,ix,iy,32,32 +endFn +'----------------------------------------- +func updateEnemy() + if ex < 600 : ex = ex + 1 : endif + if ex = 598 : ex = 10 : endif + fcolor 0,0,0 : rect 0,0,800,512 + ShowImgT img3, ex, ey, 40, 40 +swap +endfn +'---------------------------------- +func updateBush() + ShowImgT img1,bx,by,32,32 + 'calculate bush position + tbx = int((bx + 32) / 32) + tby = int(by/32) + 1 + bushCell = int(by/32)*24 + int(bx/32) + 1 +endFn + +'********************************************* +'*** I N T R O ****************************** +'********************************************* +func info() +'clear screen +fcolor 0,0,0 : rect 6,518,200,32 : + +fcolor 200,180,100: print 10,520,"GDI Level by Aurel" + +'swap +endfn + +func LoadCells() + grid() +endFn + +func grid() +'clear screen +fcolor 0,0,0 : rect 0,0,800,512 : + +'draw shadows +ly=0 +While ly < 480 + 'draw by X + lx=0 + While lx < 768 + fcolor 60,80,60 : rect lx,ly,32,32 + cell = cell + 1 : fcolor 60,60,60: print lx,ly,cell : swap + lx = lx + 32 + Wend +ly = ly + 32 +Wend +swap +endfn + From 32198d50fcddc9fc85e100e2976c1cd459a9e06a Mon Sep 17 00:00:00 2001 From: Aurel Date: Sun, 21 May 2023 21:23:33 +0200 Subject: [PATCH 12/49] Create GameXY2.bas --- Examples/GameXY2.bas | 140 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100644 Examples/GameXY2.bas diff --git a/Examples/GameXY2.bas b/Examples/GameXY2.bas new file mode 100644 index 0000000..9d38741 --- /dev/null +++ b/Examples/GameXY2.bas @@ -0,0 +1,140 @@ +'primitive game in microA with Johnno help +'collision not work properly! +var r,g,b , mx , my, ax,ay, wp ,p,score, game +var bf, bx, by ,bs, ex,ey,hit,eh,ev +ptr wmKeyDown, wmTimer + ay = 175 : ax = 120 : ex = 5 : ey = 10 +wcolor 0,0,0 : fcolor 140,180,200 +print 20,410,"primitive game in micro(A)" +print 20,430,"move 'A' with LEFT<->RIGHT arrow keys" +print 20,450,"Shoot with SPACE bar" +print 20,470,"Pause with ESC key" +print 456,10,"player" : print 456,40,"bullet" : print 456,70,"enemy" +print 456,100,"score" +updateScreen() : fcolor 220,10,10 : print ax,ay,"A" +hit = 0 + +'--------------------------------------------- + +WinMsg wmKEYDOWN + +hWparam wp +'vkLEFT ?----------------------------------- +if wp = 37 + if ax > 11 : ax = ax - 5 :endif + +endif + +'vkRIGHT ?---------------------------------- +if wp = 39 + if ax < 229 : ax = ax + 5 : endif + +endif + +'vkSpace ?---------------------------------- +if wp = 32 + if bf = 0 + bx = ax + by = ay + bf = 1 + endif +endif + +'game loop --------------------------------- +game = 1 +while wp > 0 + fcolor 180,180,120 : rect 1,1,256,192 + + updateScreen() + updateBullet() + updateEnemy() + testCollision() + updateScore() + 'delay loop + p=0 + while p < 800 + p=p+0.1 + wend + swap +game = game + 1 +wend + + + + +EndWm + + +'-------------------------------------------------- +func updateScreen() + 'update ax position + fcolor 80,80,100 :rect 524,5,68,24 + fcolor 100,160,220 : print 530,10,ax + + 'display player + fcolor 100,210,230 : print ax,ay,"A" + + 'Display bullet + if bf = 1 + fcolor 255,255,0 : print bx, by,"^" + 'update by bullet position + fcolor 80,80,100 :rect 524,35,68,24 + fcolor 235,218,100 : print 530,40,by + endif + + 'display enemy + fcolor 100,150,100 : print ex,ey,"-o-" + 'update ex enemy position + fcolor 80,80,100 :rect 524,65,68,24 + fcolor 100,160,100 : print 530,70,ex + 'update score + ' fcolor 80,80,100 :rect 524,95,68,24 + 'fcolor 245,118,0 : print 530,100,score + + swap + +endfn +'---------------------------------------------------------------- +func updateBullet() + if bf = 1 + by = by - 5 + 'bx = bx + 'Bullet has left the screen. + if by < 1 : bf=0 : endif + endif +endfn +'---------------------------------------------------------------- +func updateEnemy() + if ex < 250 : ex=ex+5 : endif + if ex > 240 : ex=5 : endif + if ey > 100 : ey = 5 : endif + eh=ex+10: ev=ey+10 + 'fcolor 0,150,100 : print ex,ey,"-o-" +endfn +'------------------------------------------------------------ +func testCollision() + + if bx = ex & by = ey + if bf ! 0 + hit = 1 : bf=0 + fcolor 220,100,100: print ex,ey,"-XX-" + endif + else + hit = 0 + endif + + if hit = 1 + score = score + 10 + hit = 0 + endif + +endfn +'--------------------------------------------------------------------- +func updateScore() + fcolor 80,80,100 :rect 524,95,68,24 + fcolor 245,118,0 : print 530,100,score +endfn + + + + From b6081bfa23a125593d6ea07f61ebdd604e463b62 Mon Sep 17 00:00:00 2001 From: Aurel Date: Sun, 21 May 2023 21:24:29 +0200 Subject: [PATCH 13/49] Create Galaxy.bas --- Examples/Galaxy.bas | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 Examples/Galaxy.bas diff --git a/Examples/Galaxy.bas b/Examples/Galaxy.bas new file mode 100644 index 0000000..66f9f5c --- /dev/null +++ b/Examples/Galaxy.bas @@ -0,0 +1,10 @@ +'galaxy qb +var x,pi,px,py ,r: wcolor 0,0,0 +pi = 3.14159 +x=1 +while x < 720 + px = SIN(x / 180 * pi) * RAND(185) + 320 : py = COS(x / 180 * pi) * RAND(73) + 240 + fcolor 220,220,100: r=rand(5) : pset px,py + x=x+0.1 +swap +wend From f58d19b8c52f3ff6d4cdb25753b0258add5e278d Mon Sep 17 00:00:00 2001 From: Aurel Date: Sun, 21 May 2023 21:25:41 +0200 Subject: [PATCH 14/49] Create FullCircle.bas --- Examples/FullCircle.bas | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Examples/FullCircle.bas diff --git a/Examples/FullCircle.bas b/Examples/FullCircle.bas new file mode 100644 index 0000000..d5b0a8d --- /dev/null +++ b/Examples/FullCircle.bas @@ -0,0 +1,34 @@ +'full_circle by [B+=MGA]2017->micro(A) by aurel +'everything was supposed to be turning around another circle +var xc,yc,xx,yy,x,y,x3,y3,r,w,ww,w3,pi,i,j,k,ww,loop +xc=640/2 : yc=480/2 :pi=3.14: i=1 : j=1: k=1: loop=1 +wcolor 0,0,0 +while loop < 2400 + r = r + pi/180 + w = w + pi/72 + i=1 : j=1: k=1 + while i < 12 + x=xc+200*cos(w+i*pi/6)*sin(r) + y=yc+200*sin(w+i*pi/6)*sin(r) + fcolor 120,150,100 : circle x,y,40 + ww = ww + pi/80 + while j < 12 + xx=x+100*cos(ww + j*pi/6)*sin(r) + yy=y+100*sin(ww + j*pi/6)*sin(r) + fcolor 150,100,100 : circle xx,yy,20 + w3 = w3 + pi/80 + while k < 12 + x3=xx+50*cos(w3 + k*pi/6)*sin(r) + y3=yy+50*sin(w3 + k*pi/6)*sin(r) + fcolor 100,120,150 : circle x3,y3,r + k = k + 1 + wend + j = j + 1 + wend + i = i + 1 + wend +'wcolor 0,0,0 + + loop = loop + 0.1 +swap +wend From 70914ccfb021d2d2dbc50923eb2108e4e3318942 Mon Sep 17 00:00:00 2001 From: Aurel Date: Sun, 21 May 2023 21:26:35 +0200 Subject: [PATCH 15/49] Create Fractal19.bas --- Examples/Fractal19.bas | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Examples/Fractal19.bas diff --git a/Examples/Fractal19.bas b/Examples/Fractal19.bas new file mode 100644 index 0000000..31e132e --- /dev/null +++ b/Examples/Fractal19.bas @@ -0,0 +1,33 @@ +'Fractal19 from mySmallBasic-> in micro(A) +var x,y ,i,r,ux,uy +wcolor 20,60,40 : fcolor 180,180,230 +print 10,10,"Fractal19 from MySmallBasic-github...in micro(A)" +x = 100 : y = 100 +'change color +fcolor 220,220,100 + +while i < 10000 + +r = rand(2) + +ux = 150 + uy = 30 + + If r = 1 + ux = 30 + uy = 1000 + EndIf + + If r = 2 + ux = 1000 + uy = 1000 + EndIf + + x = (x + ux) / 2 + y = (y + uy) / 2 + pset x, y + +i=i+0.5 +wend + +swap From f4a06b59bb0650c5099f1f55c6d889077a1b7f2d Mon Sep 17 00:00:00 2001 From: Aurel Date: Sun, 21 May 2023 21:27:28 +0200 Subject: [PATCH 16/49] Create FloorMapper.bas --- Examples/FloorMapper.bas | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 Examples/FloorMapper.bas diff --git a/Examples/FloorMapper.bas b/Examples/FloorMapper.bas new file mode 100644 index 0000000..982b0bf --- /dev/null +++ b/Examples/FloorMapper.bas @@ -0,0 +1,36 @@ +'Floormaper by Antoni Gual / micro(A) version +'for Rel's 9 LINER contest at QBASICNEWS.COM 1/2003 +'--------------------------------------------------- +var r,x,y,y1,y2,rc +wcolor 0,0,0 : fcolor 255,255,255 + +label fakeinkey + r = r + 1 + +y=1 +while y < 400 + ' FOR y = 1 TO 99 + y2 = 6 / y + x=0 + while x < 600 + ' FOR x = 0 TO 319 + y2=y+100 + if r= 1 : rc= (159 - x) * y2 : endif + if r= 2 : rc= (sqr(125) - x) * y2 : endif + 'rc=rand(x) + fcolor rc,rc,rc + pset x, y2 + 'rect x , y ,8,8 + x=x+1 + + wend + +y=y+1 +swap +wend + + +if r < 2 + goto fakeinkey +endif + From e27377be13aae75e23106b27e7c17e50a10c747e Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 12:39:19 +0200 Subject: [PATCH 17/49] Create FillArray.bas --- Examples/FillArray.bas | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 Examples/FillArray.bas diff --git a/Examples/FillArray.bas b/Examples/FillArray.bas new file mode 100644 index 0000000..2fc30ae --- /dev/null +++ b/Examples/FillArray.bas @@ -0,0 +1,30 @@ +'test fill numeric array in micro(A) +wcolor 40,40,80:fcolor 140,180,230 : swap +var arr[4000] ,brr[4000] +var n,i,start,end,time + +n=1 +'fill array elements with values +while n < 4001 + arr[n] = n + n=n+1 +wend + +time = (end - start) / 1000 +print 10,10,"array with 4000 elements in micro(A)" +fcolor 230,200,100 :print 10,50,"read array elements with printing": swap + +i=1 +'copy values from first array to second array +GETTICK start +while i < 4001 + rect 5,75,100,25 + brr[i] = arr[i] + fcolor 230,200,100: print (10),(80),brr[i] + i=i+1 +swap +wend +GETTICK end +time = (end - start)/1000 +fcolor 140,180,130 :print 15,120,"time" +rect 10,145,100,20: print 15,150,time : swap From 19382f213b644d8372fbe6b12a7f605bcd4f037a Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 12:41:14 +0200 Subject: [PATCH 18/49] Create Fibonnaci.bas --- Examples/Fibonnaci.bas | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) create mode 100644 Examples/Fibonnaci.bas diff --git a/Examples/Fibonnaci.bas b/Examples/Fibonnaci.bas new file mode 100644 index 0000000..9b4ac33 --- /dev/null +++ b/Examples/Fibonnaci.bas @@ -0,0 +1,28 @@ +' fibonacci series in micro(A) +var a, b, s, i ,n ,x ,y,r +str fbs,noe +fbs="fibonacci sequence in micro(A)" +wcolor 0,0,0 : fcolor 220,180,100 +noe = "number of elements ->" +print 380,10,fbs +fcolor 80,140,120 +print 380,30,noe +fcolor 100,200,200 +a = 1 +b = 1 +n = 20 +y = 50 + +label start +s = a + b +print 500,y,s +y = y + 20 +a = b +b = s +i = i + 1 +r=s/3.14 +circle y,s,r : circle n,s,r : swap + +if i < 23 + goto start +endif From 38a4c15e5b5e37c099d265adb566502d0bd43d00 Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 12:43:19 +0200 Subject: [PATCH 19/49] Create Fern.bas --- Examples/Fern.bas | 49 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Examples/Fern.bas diff --git a/Examples/Fern.bas b/Examples/Fern.bas new file mode 100644 index 0000000..0ecba86 --- /dev/null +++ b/Examples/Fern.bas @@ -0,0 +1,49 @@ +'fern test in micro(A) +var xp,yp,r,n,x1,y1 ,xx,yy,x,y +xp=0: yp=0 : wcolor 0,0,0 +fcolor 0,150,0 +n=1 +while n < 5000 + +r = rand(100) +if r < 1 + 'if r > 0 + xp = 0 + yp = 0.16 * y + 'endif +endif + +if r > 1 + if r < 8 + xp = 0.2 * x - 0.26 * y + yp = 0.23 * x + 0.22 * y + 1.6 + endif +endif + +if r > 8 + if r < 15 + xp = -0.15 * x + 0.28 * y + yp = 0.26 * x + 0.24 * y + 0.44 + endif + +if r > 15 + Xp = 0.85 * X + 0.04 * Y + Yp = -0.04 * X + 0.85 * Y + 1.6 +endif +endif + +x = xp +y = yp + +xx = x * 45 +yy = y * 45 - 225 + +Pset (xx + 320),( -yy + 240) +'swap +n = n + 1 +wend +swap + + +fcolor 220,210,100 +print 10,10," fern fractal in micro(A) ":swap From ad1169611aa5cfabb17021c2285e6966f26dfc4b Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 12:44:40 +0200 Subject: [PATCH 20/49] Create Feingebaum.bas --- Examples/Feingebaum.bas | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 Examples/Feingebaum.bas diff --git a/Examples/Feingebaum.bas b/Examples/Feingebaum.bas new file mode 100644 index 0000000..9637785 --- /dev/null +++ b/Examples/Feingebaum.bas @@ -0,0 +1,23 @@ +'feingebaum example in micro(A) +var r,dr,x,i,px,py,scrw,s2 +str title +x=0.5: r=2.4 : scrw=700 : s2= 1/scrw +wcolor 0,0,0 +fcolor 220,200,100 + +label start +x=r*x*(1-x) +px = ((r-2.4)/1.6)*scrw : py = (1-x)*scrw +pset px,py + +r = r + 0.0009 +pset px,py + + +if r < 4 +'coment or uncoment next instrction +swap + goto start +endif +title = "feingebaum in micro(A)" +print 10,10,title :swap From a456ff814369f9075c7a6c8756ff4084a2ad3d93 Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 12:46:42 +0200 Subject: [PATCH 21/49] Create FakePyramid.bas --- Examples/FakePyramid.bas | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Examples/FakePyramid.bas diff --git a/Examples/FakePyramid.bas b/Examples/FakePyramid.bas new file mode 100644 index 0000000..dd63e4a --- /dev/null +++ b/Examples/FakePyramid.bas @@ -0,0 +1,44 @@ +' Fake 3D Pyramid-by ZXdunny +var a,x,y,ya,ab,ax,cr +var f,ay,ox,oy,p,px +var angle : wcolor 0,0,0 +fcolor 100,170,200 : print 4,4,"fakePyramid": swap +fcolor 0,0,0 : rect 20,20,400,400 : swap +x=400/2 : y=400/2 +ya=y-120 : a=18 + +'main +LABEL main +f=1 +while f < 6 + p=0 + while p < 6 + + ab=a+90*f + ax=x+100 * cos(ab) + ay=y-50 * sin(ab) + + fcolor 0,187,250 + + if x > 399 :x=200 : endif + x=x+0.01 + CIRCLE x,ya,4 + + CIRCLE ax,ay,4 + LINE ox,oy,ax,ay + LINE x,ya,ax,ay + + ox=ax + oy=ay + + p=p+0.4 + wend + +f=f+0.4 +wend +a=a+1 +swap + +fcolor 0,0,0 : rect 20,20,500,400 + +goto main From b066926821e489b5befcbd1639b2b7495c9141be Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 12:52:45 +0200 Subject: [PATCH 22/49] Create Factorial,.bas --- Examples/Factorial,.bas | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Examples/Factorial,.bas diff --git a/Examples/Factorial,.bas b/Examples/Factorial,.bas new file mode 100644 index 0000000..b7fccfd --- /dev/null +++ b/Examples/Factorial,.bas @@ -0,0 +1,27 @@ +' factorial with recursion in micro(A) +var value,res +var number ,fact +number = 7 +fact = 1 +value = 1 + +print 10, 10, "The factorial of -> " : +print 180,10,number :swap + +factorial() + +fcolor 230,80,60: print 10,240,"RECURSION OVER!" +swap + +func factorial() + + if value < number + value = value + 1 + fcolor 140,180,220: rect 95,95,80,23: print 100,100,value :swap + fact = fact * value + fcolor 240,180,120: rect 95,195,80,23 : print 100,200,fact :swap + ' recursive call + factorial() + endif + +endfn From 573abfce1ed71fb1561b62d856f39f318ee4a3d7 Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 12:54:10 +0200 Subject: [PATCH 23/49] Create EyeCandy.bas --- Examples/EyeCandy.bas | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 Examples/EyeCandy.bas diff --git a/Examples/EyeCandy.bas b/Examples/EyeCandy.bas new file mode 100644 index 0000000..ba24273 --- /dev/null +++ b/Examples/EyeCandy.bas @@ -0,0 +1,42 @@ +' EyeCandy #9 from "Sprezzo #2 Problem 2022-03-06" +var xc,yc,xmax,ymax,pi,p2,px,py,s,r,colr,a,i,pR,pG,pB,red,green,blue,cN +xmax = 800 : ymax = 600 : xc = xmax/2 : yc = ymax/2 : pi=3.14159 : p2 = pi*2 +wcolor 0,0,0 : var t +t=0 +while t < 10 + resetPlasma() + 'Plasma() + s = 0 + a=0 + while a < p2 + Plasma() + 'For a = 0 To p2 Step p2 / (16 * 360) + i = 50 * Sin(s) ' 2 * s or just s + 'For r = 0 To yc + r=0 + while r < yc + px=xc + r * Cos(a) : py= yc + r * Sin(a) + 'fcolor red,green,blue + PSet px,py 'colr(r + i) + 'Next + r=r+1 + wend + s = s + p2 / 180 + 'next + a = a+p2/(3.14*360) 'step a + swap + wend + 'delay 3000 +t=t+1 +fcolor 0,150,180 : rect 2,2,30,30 : print 10,10,t +wend + +Func Plasma() + cN = cN + 0.2 + red = 127+127 * Sin(pR * cN): green= 127+127 * Sin(pG * cN):blue= 127+127 * Sin(pB * cN) + fcolor red,green,blue +Endfn + +Func resetPlasma() + pR = Rand(255): pG = Rand(255): pB = Rand(255) +Endfn From 37068d21c2d74edc95ccf1a44ec2186442e0c263 Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 12:55:19 +0200 Subject: [PATCH 24/49] Create EggPlasma.bas --- Examples/EggPlasma.bas | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) create mode 100644 Examples/EggPlasma.bas diff --git a/Examples/EggPlasma.bas b/Examples/EggPlasma.bas new file mode 100644 index 0000000..09c4664 --- /dev/null +++ b/Examples/EggPlasma.bas @@ -0,0 +1,38 @@ +'easter eggs QB by MGA=B+ +var x,y,xup,px,py,scale,sw,sh,r,g,b,colorCnt,cr,cg,cb +sw = 500 : sh = 500 +scale = 200 : wcolor 0,0,0 + +label DoLoop + x = -1 + r = Rand(2): g = Rand(2): b = Rand(2) ' setup for Plasma Coloring! + While x < 1 + y = -1 + While y < 1 + + ' Plasma coloring changes color: ColorCnt, at every step in loop whether we draw or not + 'this gets symmetry between left and right ends of egg + If x < 0 : colorCnt = colorCnt + 0.0005 : Else : colorCnt = colorCnt - 0.0005 : endif ' setup for color + + ' Plasma Coloring Method + ' Color _RGB32(128 + 127 * Sin(r * colorCnt), 128 + 127 * Sin(g * colorCnt), 128 + 127 * Sin(b * colorCnt)) + cr=128 + 127 * Sin(r * colorCnt): cg=128 + 127 * Sin(g * colorCnt) : cb=128 + 127 * Sin(b * colorCnt) + fcolor cr,cg,cb + xup = x * x + (1.4 ^ x * 1.6 * y) ^ 2 - 1 + px = scale * x + sw / 2: py = scale * y + sh / 2 + + If xup < 0.01 + ' Line (px, py)-Step(1, 1) + rect px,py,2,2 + EndIf + + y = y + 0.01 + Wend + x = x + 0.01 + swap + Wend + 'swap + + colorCnt = 0 + '_Delay 2 +Goto DoLoop From 2d3b55ba110e86e6256c30be111513976a5d7294 Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 12:56:34 +0200 Subject: [PATCH 25/49] Create Effect.bas --- Examples/Effect.bas | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 Examples/Effect.bas diff --git a/Examples/Effect.bas b/Examples/Effect.bas new file mode 100644 index 0000000..102ae29 --- /dev/null +++ b/Examples/Effect.bas @@ -0,0 +1,34 @@ +'specBas effect in micro(A)-by Aurel +var a,b,x,y,u,v,t,hw,hh,n,r,px,py,p +var wp,rr,gg,bb,i,j, cx,cy,cr,rix +var TAU +wcolor 0,0,0 +TAU = 6.28 +hw=400/2 : hh=400/2: n=180 : r = TAU/235 +t=0 + +While t < 50 + +i=10 +'while i < n +rect 0,0,600,600 +label loop_i + j=10 + 'while j < n + label loop_j + u = sin(i + v) + sin(r*i + x) : v = cos(i + v) + cos(r * i + x) + x = u + t + 'fcolor i,j,199 + 'px = hw + u * hw * 0.4 : py = hh + v * hh * 0.4 : pset px,py + fcolor i,j,199 : pset ( hw + u * hw * 0.4) , (py = hh + v * hh * 0.4) + j=j+1 + if j < n : goto loop_j : endif + i=i+1:swap + +'wend +if i < n : goto loop_i : endif + +t=t+1 +'rect 0,0,600,600 +wend + From c862125985d4fb1b4073b21c6331549e9cc0fd64 Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 12:59:07 +0200 Subject: [PATCH 26/49] Create EBulb.bas --- Examples/EBulb.bas | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Examples/EBulb.bas diff --git a/Examples/EBulb.bas b/Examples/EBulb.bas new file mode 100644 index 0000000..6d91015 --- /dev/null +++ b/Examples/EBulb.bas @@ -0,0 +1,19 @@ +'energy bulb +var t,x,y,col +'X varies between -1.7 and +1.7, Y from -1.1 to + 1.1 +wcolor 0,0,0 : fcolor 200,200,140 : print 10,10,"Please Wait..." : swap +t=0 +fcolor 180,220,140 : +while t < 3500 +x = sin(0.99*t)-0.7 * cos(3.01*t) +y = cos(1.01*t)+0.1 * sin(15.03*t) +x = x*100+300 +y = y*100+300 +pset y,x + +t=t+0.1 +'swap +wend + + +print 10,30,"Energy Bulb": swap From daff6d7492e4bb2ddf0837d23f36f7aa958a22f9 Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 13:07:54 +0200 Subject: [PATCH 27/49] Create EasySpiral.bas --- Examples/EasySpiral.bas | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 Examples/EasySpiral.bas diff --git a/Examples/EasySpiral.bas b/Examples/EasySpiral.bas new file mode 100644 index 0000000..1e377c9 --- /dev/null +++ b/Examples/EasySpiral.bas @@ -0,0 +1,24 @@ +'Easy spiral by MGA,johnno56 +var pi,s,tick,c,h,x,y,rx,ry,cr,fr,fg,fb +wcolor 0,0,0: pi = 3.14159 +s = 7 +tick = 1 +fr=250: fg=180 : fb=100 +label doLoop + fcolor 0,0,0:rect 0,0,700,700 + c=1 + label inner + h = c + tick + x = Sin(6 * h / pi) + Sin(3 * h) + h = c + tick * 2 + y = Cos(6 * h / pi) + Cos(3 * h) + 'fr=rand(255) : fg=rand(255) : fb=rand(255) + + fcolor fr,fg,fb : rx = s * (20 * x + 50) : ry = s * (20 * y + 50):cr=rand(3) + circle rx,ry,2 + 'pset rx,ry + c=c+1 + if c < 1000 : goto inner : endif + swap + tick = tick + 0.1 +goto doLoop From b0259f6eda2dbfeef5c51b2038eeb66a94cd56e8 Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 13:09:55 +0200 Subject: [PATCH 28/49] Create Dragon.bas --- Examples/Dragon.bas | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Examples/Dragon.bas diff --git a/Examples/Dragon.bas b/Examples/Dragon.bas new file mode 100644 index 0000000..d477639 --- /dev/null +++ b/Examples/Dragon.bas @@ -0,0 +1,37 @@ +' Coded By Ashish - "Dragon curve" in QB64 +' micro(A) version by Aurel +var sx,sy,ox,oy,z,i,x,y,xx,yy,n,a,b,r,px,py +wcolor 0,0,0 : fcolor 155, 180, 250:print 5,5,"please wait..." + z = 40 + ox = 600 * 0.46 + oy = 380 * 0.09 + fcolor 255, 180, 0 +i=0 + while i < 3000 + a = sx: b = sy + x=a : y=b + label drawDragon + r=rnd(1) + if r>0 & r<0.8 + xx = 0.824074 * x + 0.281428 * y - 1.88229 + yy = -0.212346 * x + 0.864198 * y - 0.110607 + else + xx = 0.088272 * x + 0.520988 * y + 0.78536 + yy = -0.463889 * x - 0.377778 * y + 8.095795 + endif + + px = xx * z + ox : py = yy * z + oy + pset px,py + + + if n < 5 + n=n+1: goto drawDragon + else + sx = xx: sy = yy + n=1 + endif + i=i+1 +swap +wend +print 10,510,"Dragon Curve in micro(A) by Aurel based on Ashish /Dragon curve/ in QB64 " :swap + From 9d7ba8d2fb237881eb8a27f132fcdb7c5efdf6e1 Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 13:39:11 +0200 Subject: [PATCH 29/49] Update Transformer.bas --- Examples/Transformer.bas | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/Examples/Transformer.bas b/Examples/Transformer.bas index 669c754..7ff943a 100644 --- a/Examples/Transformer.bas +++ b/Examples/Transformer.bas @@ -1,6 +1,7 @@ -' Transformer Calculator in micro(A) by Aurel,(c)AurelSoft +'Transformer Calculator in micro(A) by Aurel,(c)AurelSoft var mx, my, wp, pvolt, pturns, svolt, sturns, tpv ,trlen -ptr wmMouseMove ,wmKeyDown +ptr wmKeyDown +var leftkey, rightkey ,upkey, downkey tpv = 1 : trlen = 200 wcolor 40,60,120 fcolor 140,180,200 print 5,310,"PRIMARY(turns)" : print 5,350,"VOLTAGE ( V )" @@ -48,8 +49,13 @@ if wp = 34 tpv = tpv - 1 : pturns = pvolt * tpv : sturns = svolt * tpv : DisplayUpdate() endif +While wp ! 27 + 'wait... +Wend + EndWm + func DisplayUpdate() 'primary fcolor 90,90,90 :rect 130,310,120,24 From cefd66a0a626ba2043caeb7f0e993a3ec47aed21 Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 13:43:31 +0200 Subject: [PATCH 30/49] Create DipolCalc.bas --- Examples/DipolCalc.bas | 81 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 Examples/DipolCalc.bas diff --git a/Examples/DipolCalc.bas b/Examples/DipolCalc.bas new file mode 100644 index 0000000..f85eb6e --- /dev/null +++ b/Examples/DipolCalc.bas @@ -0,0 +1,81 @@ +'Antenna Dipol Calculator demo +var mx, my, wp, cons, freq, length ,dlen, ox, cx, dx +ptr wmKeyDown +var mode +cons = 142.5 : freq = 10 : length = cons/freq : ox = 400 : dx = ox - length/10 : cx = 400 +wcolor 40,60,120 : fcolor 140,180,200 : ' rect 0,0,800,600 +print 6,10,"FREQENCY(MHz)" +print 6,40,"LENGTH ( m )" +fcolor 220,180,150 : print 300,10,"Antenna Dipol Calculator micro(A)-DEMO":swap +mode = 1 ' 1 to 10 Mhz +dlen = int(length*3.14) : dx = ox - (dlen/2) +print 300,24,dx : fcolor 100,140,100 : print 300,44,(1.41*5) +DisplayUpdate() +Info() +DrawDipol() + + +WinMsg wmKEYDOWN + +hWparam wp +'vkLEFT ? +if wp = 37 + if freq > 1 + freq = freq - 1 : length = cons/freq : dlen = int(length*5) + if dx > 0 + dx = ox - (dlen/2) + DisplayUpdate() : DrawDipol() + endif + endif +endif + +'vkRIGHT ? +if wp = 39 + if freq < 2500 + freq = freq + 1 : length = cons/freq : dlen = int(length*5) + if dx < 400 + dx = ox - (dlen/2) + DisplayUpdate() : DrawDipol() + endif + endif +endif + +'select mode +while wp ! 27 +'wait +wend + +EndWm + +func DisplayUpdate() + fcolor 90,90,90 :rect 124,5,100,24 + fcolor 100,160,220 : print 130,10,freq + fcolor 90,90,90 :rect 124,35,100,24 + fcolor 100,160,220 : print 130,40,length + swap +endfn + +func Info() + fcolor 140,180,200 + print 20,410,"LEFT Key... <-- -1 MHz" + print 20,430,"RIGHT Key.. --> +1 Mhz" + print 20,450,"UP Key... <-- +10 MHz" + print 20,470,"DOWN Key... <-- -10 MHz" + 'swap +endfn + +func DrawDipol() + 'draw frame + fcolor 90,90,90 :rect 0,180,800,60 + 'draw dipol + fcolor 190,90,90 :rect dx,200,dlen,20 + 'draw connector + fcolor 200,200,100 : circle cx,220,6 +swap +endfn + + + + + + From d57387a6085cddd1881bab4308995dfad00dfe74 Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 13:44:48 +0200 Subject: [PATCH 31/49] Create Dice.bas --- Examples/Dice.bas | 154 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 Examples/Dice.bas diff --git a/Examples/Dice.bas b/Examples/Dice.bas new file mode 100644 index 0000000..02aa827 --- /dev/null +++ b/Examples/Dice.bas @@ -0,0 +1,154 @@ +'Dice in micro(A) v10 +wcolor 0,0,0 : fcolor 180,220,180 +print 10, 10," ROLL DICE micro(A) v 10" : swap +print 10, 40," press key [ R ] to roll dice !" : swap +ptr wmKeyDown +var wp ,cx,cy,cw,ch,ci ,roll, result, turn, cscore, pscore ,pause ,Rkey +roll = 0 : wp=0 : rkey = 82 +fcolor 150,190,250 : print 10,364,"COMPUTER:" : swap +fcolor 250,190,150 : print 10,404,"PLAYER:" : swap +redrawDice() + +'simulate >> WAIT << with Goto Exit +Goto Exit + +'events.................................... +WinMsg wmKEYDOWN + +hWparam wp + +'vk_R ...ROLL DICE ! +If wp = 82 + if roll = 1 : playerTurn() : Goto Exit : endif + if roll = 0 : computerTurn() : Goto Exit : endif +EndIf + +ENDWM +'......................................... + +func computerTurn() + 'computer turn + result = rand(6) + if result = 0 :result = 1 : endif + cscore = cscore + result + update_cscore() + redrawDice() + if result = 1 : drawOne() : endif + if result = 2 : drawTwo() : endif + if result = 3 : drawThree() : endif + if result = 4 : drawFour() : endif + if result = 5 : drawFive() : endif + if result = 6 : drawSix() : endif + result = 0 + roll = 1 : fnPause() + +endfn + +func playerTurn() + + 'player turn + result = rand(6) + if result = 0 :result = 1 : endif + pscore = pscore + result + update_pscore() + redrawDice() + if result = 1 : drawOne() : endif + if result = 2 : drawTwo() : endif + if result = 3 : drawThree() : endif + if result = 4 : drawFour() : endif + if result = 5 : drawFive() : endif + if result = 6 : drawSix() : endif + result = 0 + roll = 0 : fnPause() + +endfn + +func fnPause() + pause=0 +while pause < 550 : pause = pause + 0.1 : wend +endfn + +'--------------------------------------------- +func redrawDice() + 'cube init and redraw + cx = 100 : cy = 100 : cw = 200 : ch = 200 + ci = 2 + while cx < 200 + fcolor 250,250,200 + rect cx, cy, cw ,ch : swap + cx = cx + ci : cy = cy + ci : cw = cw - ci - 2 : ch = ch - ci - 2 + wend +endfn +'-------------------------------------- +func update_cscore() + 'draw computer score + fcolor 200,220,240 : rect 90,360,80,24 + print 100,364,cscore + 'clear pointer arrow + rect 200,360,40,24 : print 204,364," " + fcolor 250,220,140 : rect 200,400,40,24 : print 204,404,"<--" +swap +endfn +'-------------------------------------- +func update_pscore() + 'draw player score + fcolor 250,220,140 : rect 90,400,80,24 + print 100,404,pscore + rect 200,400,40,24 : print 204,404," " + fcolor 200,220,240 : rect 200,360,40,24 : print 204,364,"<--" + +swap +endfn + +'-------------------------------------- +func drawOne() + fcolor 150,180,200 + Circle 200,200,10 : swap +endfn + +func drawTwo() + fcolor 150,180,200 + Circle 150,150,10 + Circle 250,250,10 : swap +endfn + +func drawThree() + fcolor 150,180,200 + Circle 150,150,10 'ul + Circle 200,200,10 'center + Circle 250,250,10 'lr + swap +endfn + +func drawFour() + fcolor 150,180,200 + Circle 150,150,10 + Circle 250,250,10 + Circle 150,250,10 + Circle 250,150,10 + swap +endfn + +func drawFive() + fcolor 150,180,200 + Circle 150,150,10 + Circle 250,250,10 + Circle 150,250,10 + Circle 250,150,10 + Circle 200,200,10 + swap +endfn + +func drawSix() + fcolor 150,180,200 + Circle 150,150,10 + Circle 250,250,10 + Circle 150,250,10 + Circle 250,150,10 + Circle 250,200,10 + Circle 150,200,10 + swap +endfn + +Label Exit + From d9c76d4095085103e74dddab9ce07ee5abf13215 Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 13:46:07 +0200 Subject: [PATCH 32/49] Create Defender.bas --- Examples/Defender.bas | 230 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 230 insertions(+) create mode 100644 Examples/Defender.bas diff --git a/Examples/Defender.bas b/Examples/Defender.bas new file mode 100644 index 0000000..648aa40 --- /dev/null +++ b/Examples/Defender.bas @@ -0,0 +1,230 @@ +' Defender in micro(A) by Aurel based on CraftBasic example +ptr img1,img2 ' image handlers +ptr wmKeyDown, wmTimer ' message handlers +var rightkey, leftkey, spacekey , esckey,score ,wp, pause, level,key +var apics , npics ,r, playerx ,playery,bullet, bulletx, bullety ,a,b,x,y +wcolor 0,0,100 : fcolor 230,200,160 +'game frame... +rect 0,0,512,512 +'load images... +LoadImg img1,"playerT.bmp",0,32,32,16 +LoadImg img2,"alien1.bmp",0,32,32,16 + +apics = 8 : level = 1 +'create alien arrays +var alienx[apics] +var alieny[apics] + + +'player origin position... +playerx=256 : playery=448 : score=0 + +bullet=0 : bulletx=0 :bullety=0 +rightkey = 39 : leftkey = 37 ' arrow keys +spacekey = 32 : esckey = 27 +'.................................................... +label create_alien_pics + + 'random X pos -> 400 + alienx[npics] = 1.5 + rand(400) + +'random Y pos -> 100 + alieny[npics] = rand(100) + + npics = npics + 1 + +If npics < apics : Goto create_alien_pics : EndIf +'................................................ +fcolor 220,220,200 : wcolor 0,0,150 +rect 0,0,330,290 : swap + +print 530,10, "DEFENDER by Aurel" +print 530,30, "in micro(A) BASIC " +print 530,50, "Use arrow keys to move" +print 530,70, "SPACE to shoot, and ESC to quit." +showimgT img1,playerx,playery,20,20 :swap +swap : esckey = 0 :Goto loop + +'events................................................ +WINMSG wmKEYDOWN + +hWparam wp +'push keydown message to key variables +'vkLEFT 37 --------------------------------- +If wp = 37 + leftkey = wp + wp=0 +EndIf + +'vkRIGHT 39 ------------------------------- +If wp = 39 + rightkey = wp + wp=0 +EndIf + +'vkSPACE +If wp = 32 '& bullet = 0 + spacekey = wp +EndIf + +'if wp = 27 : esckey = wp :goto loop: endif + +'test ESC key +While wp ! 27 + 'esckey = 0 + Goto start + ' esckey = 0 +Wend + +ENDWM +'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +label loop +'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +label start +'bullet = 0 + If leftkey = 37 + If playerx > 10 :playerx=playerx-4 : EndIf + leftkey = 0 + EndIf + + If rightkey = 39 + If playerx < 500 : playerx=playerx+4 : EndIf + rightkey = 0 + EndIf + + +If spacekey = 32 + 'bullet = 0 + bullet=1 + bulletx=playerx+9 + bullety=playery + spacekey = 0 + ' bullet=0 +EndIf + +If bullet = 1 + + fcolor 0,0,255 + x=bulletx + y=bullety+5 + 'line bulletx,bullety,x,y + + fcolor 255,0,0 + bullety=bullety-5 + + If bullety < 30 + bullet=0 + EndIf + +endif + + If bullety > 0 + x=bulletx + y=bullety+5 + line bulletx,bullety,x,y + EndIf + + + +npics = 1 ' first array index must be 1 +'--------------- + label move_pics +'--------------- + + +If bullet = 1 + + If bulletx > alienx[npics]-30 & bulletx < alienx[npics]+30 & bullety < alieny[npics]+30 + '(bulletx>=npcx[npc])&(bulletx<=(npcx[npc]+20))&(bullety<(npcy[npc]+20)) + fcolor 100,200,255 + + a=bulletx + b=bullety+5 + line bulletx,bullety,a,b + + x = alienx[npics] + y = alieny[npics] + fcolor 0,0,0 : rect x,y,32,32 + ' showimgT img2,x,y,20,20 + + score=score+1 + bullet=0 + + 'npics = npics - 1 + alienx[npics] = rand(400) + alieny[npics] = 1 + + EndIf + + EndIf +'------------------------------------ +r = rnd(1) ' decimal random 0 to 1 +r = r*0.2 +r = Round(r) + +If r = 0 + + fcolor 0,0,250 + x = alienx[npics] + y = alieny[npics] + + alieny[npics] = alieny[npics] + 0.1 + y = alieny[npics] + ' showimgT img2,x,y,20,20 + showEnemy() + 'showShip() + + if y > playery + cls() : goto gameover + endif + +endif +'------------------------------------- +npics = npics + 1 +'if npc > 10 : goto gameover : endif +if npics < apics : goto move_pics : endif +'------------------------------------- + fcolor 255,255,0 + print 10,10,"Score: " + print 80,10,score + +'............................... + + +showShip() + +flip() +'fnPause() +cls() + +' back to label loop <<<<<<<<<<<<<<<<<<<<<<<<< +if esckey = 0 : goto loop : endif +'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +func fnPause() + pause=0 +while pause < 150 : pause = pause + 0.1 : wend +endfn +'-------------------------------------------- +func showShip() + showimgT img1,playerx,playery,32,32 +endfn +'------------------------------------------ +func showEnemy() + if level = 1 : showimgT img2,x,y,32,32 : endif + + +endfn +'........................... +func flip() + swap +endfn +'........................... +func cls() + 'clear area + rect 0,0,512,512 +endfn +'........................... + +label gameover + print 100,100, "G A M E O V E R !": swap From afc6bc610f520ca3782f9f6b66ae8ca2a9bec818 Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 13:46:58 +0200 Subject: [PATCH 33/49] Create DaricFern.bas --- Examples/DaricFern.bas | 49 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 Examples/DaricFern.bas diff --git a/Examples/DaricFern.bas b/Examples/DaricFern.bas new file mode 100644 index 0000000..d7c916b --- /dev/null +++ b/Examples/DaricFern.bas @@ -0,0 +1,49 @@ +'Daric Fern +var x,y,nextX,nextY,i,sx,sy,a,xx,yy +var start,endtime,time +var rc , bc : rc = 144 : bc = 144 +wcolor 0,0,0: fcolor 144,238,144 +nextX = 0 : nextY = 0 +sx=400/10 : sy = 300/10 +i=1 + +GETTICK start +while i < 10000 +'play with rand value 50 to 100 +a = rand(70) +If a < 1 + nextX = 0 + nextY = 0.16 * y +EndIf + +If a > 1 + if a < 8 + nextX = 0.2 * x - 0.26 * y + nextY = 0.23 * x + 0.22 * y + 1.6 + endif +EndIf + +If a > 8 + if a < 15 + nextX = -0.15 * x + 0.28 * y + nextY = 0.26 * x + 0.24 * y + 0.44 + endif +EndIf + +If a > 15 + nextX = 0.85 * x + 0.04 * y + nextY = -0.04 * x + 0.85 * y + 1.6 +EndIf + +x = nextX +y = nextY + +Pset (x * sx+200),( y * sy) +swap ' uncomment this line if you want to watch drawing + +i=i+1 +wend +'swap +GETTICK endtime +time = (endTime - start) / 1000 +fcolor 200,200,240: print 10,450,time : swap From ac2560f8e2309b640e6936e4e52d67b567967ea7 Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 13:48:36 +0200 Subject: [PATCH 34/49] Create Curlicue.bas --- Examples/Curlicue.bas | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 Examples/Curlicue.bas diff --git a/Examples/Curlicue.bas b/Examples/Curlicue.bas new file mode 100644 index 0000000..d3e525b --- /dev/null +++ b/Examples/Curlicue.bas @@ -0,0 +1,19 @@ +'curlicue fractal +var x,y,f,i,df,pi,seed +x=400:y=300 : wcolor 0,0,0 : bcolor 0,0,0 +seed = 0.34 +df=0 +f=0 +fcolor 0,100,200 +label start +swap +x = abs(-x + cos(f*f)/0.4) +y = abs(-y + sin(f*f)/0.4) +pset x,y +f = f + 0.19 +if f < 2000 + fcolor 0,0,0 : bcolor 0,0,0 :rect 200,10,100,20 + fcolor 100,150,220 : print 200,10,f + goto start +endif +fcolor 120,160,190 : print 310,10,"curlicue fractal in micro(A)":swap From 5d334115785099eeabb25b9f251a187fd844dd2d Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 13:49:51 +0200 Subject: [PATCH 35/49] Create ChristmassTree2.bas --- Examples/ChristmassTree2.bas | 77 ++++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100644 Examples/ChristmassTree2.bas diff --git a/Examples/ChristmassTree2.bas b/Examples/ChristmassTree2.bas new file mode 100644 index 0000000..9e3b366 --- /dev/null +++ b/Examples/ChristmassTree2.bas @@ -0,0 +1,77 @@ +'chTree 2 by Aurel +var rise, rad, frad, xshorten +var left, top, width, height, bpx, bpy, tpx, tpy +var x1, y1, x2, y2 +var ht,xs,aa,msto +var tpxx,tpyy,bpxx,bpyy,minus4 +var x,y,px,py +wcolor 0,0,0 +drawStars() +msto = -100 +minus4 = -4 +bpx=220 : bpy=410 : tpx=bpx + +'brown .............................. +fcolor 130, 100, 0 +aa = minus4 +while aa < 4 + bpxx=bpx+aa : bpyy=bpy-390 + line bpxx, bpy, bpx, bpyy +aa = aa + 1 +swap +wend + +'green............................... +fcolor 30,120,40 +rad=160 : tpy=bpy-40 +ht=1 +while ht < 40 +xs= -100 + while xs < 100 + xshorten=xs/100 + rise= rnd(0.93) : tpxx = tpx+(xshorten*rad) : tpyy = tpy-rise*rad + line tpx, tpy, tpxx, tpyy + + aa=1 + while aa < 30 + frad=rnd(0.9)*rad + x1=tpx+(xshorten*frad) + y1=tpy-rise*frad + x2=tpx+xshorten*(frad+rad/5) + y2=tpy-rise*frad+(-rise + (rnd(0.9)-0.456))*(rad/5) + line x1, y1, x2, y2 + aa=aa+1 + wend + + xs = xs + 40 + wend + +rad=rad-4 : tpy=tpy-9 +ht = ht + 1 : swap +wend + +bcolor 80,0,100 :fcolor 200,220,200 +print 300,40," * * * Merry Christmas ! * * * " +print 300,80," * * * Happy New Year ! * * * " +bcolor 60,0,120 :fcolor 200,220,200 +print 350,120," micro(A) by Aurel " + +fcolor 220,200,100 : circle 190,100,6 : circle 190,100,4: circle 190,100,2 +fcolor 250,100,100 : circle 250,180,6 : circle 250,180,4: circle 250,180,2 +fcolor 150,100,250 : circle 175,165,6 : circle 175,165,4: circle 175,165,2 +fcolor 80,150,255 : circle 140,225,6 : circle 140,225,4: circle 140,225,2 +fcolor 80,250,255 : circle 270,245,6 : circle 270,245,4: circle 270,245,2 +fcolor 200,150,255 : circle 90,302,6 : circle 90,302,4 : circle 90,302,2 +fcolor 250,180,255 : circle 295,302,6 : circle 295,302,4: circle 295,302,2 +swap + +func drawStars() +wcolor 0,0,80 +x=10 : y=0 + while x < 400 + px= rand(600) : py= rand(480) + bcolor 0,0,80 : fcolor 220,220,110 : print px,py,"." + fcolor 120,220,210 + x=x+4 + wend +endfn From e5613b366112441ed02df83df60a94b88afbd1cd Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 13:51:08 +0200 Subject: [PATCH 36/49] Create ChStar2.bas --- Examples/ChStar2.bas | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 Examples/ChStar2.bas diff --git a/Examples/ChStar2.bas b/Examples/ChStar2.bas new file mode 100644 index 0000000..1e03c21 --- /dev/null +++ b/Examples/ChStar2.bas @@ -0,0 +1,21 @@ +'christmas star 2 by Rhiannon Jo fB +var m,n,m4,m23 +m4 = -4 +wcolor 0,0,0 : fcolor 160,160,240 +m=5 +while m < 10 +n = m-4 +m23 = 23 - m +while n < m23 + print ((m*8)),((18-n)*8) , "*" + print ((18-n)*8),(m*8), "*" + print ((18-m)*8),(n*8), "*" + print (n*8),(8*(18-m)), "*" +n = n+1 +swap +wend +m=m+1 +wend + +print 10,300,"Christmas Star 2 by Rhiannon Jo faceBook - micro(A) by Aurel" +swap From 71f01dc38f60608150e22fe2a82ea51a144e14b5 Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 13:51:54 +0200 Subject: [PATCH 37/49] Create ButterFly.bas --- Examples/ButterFly.bas | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Examples/ButterFly.bas diff --git a/Examples/ButterFly.bas b/Examples/ButterFly.bas new file mode 100644 index 0000000..07ee600 --- /dev/null +++ b/Examples/ButterFly.bas @@ -0,0 +1,31 @@ +'butterfly micro(A) +var x,y,i,a,turn,rr,gg,bb,cx,cy,cr +wcolor 0,0,0 +'frontpen 200,200,0 +while turn < 30 + +i=0 +fcolor 0,0,0 : rect 0,0,640,480 +'print 10,90,turn + while i < 120 + rr=rand(255) :gg=rand(255): bb=rand(255) + fcolor rr,gg,bb + x = sin(i+a)*50 - cos(i-a)*i + y = cos(i+a)*50 + sin(i-a)*i + cx=x+320: cy=y+240: cr=sin(i)*5 + circle cx,cy,cr + 'pset cx,cy +i=i+0.6 +'swap +wend + +a = a + 0.073 + +if a > 360 +a = -a +endif + +turn = turn + 0.1 +swap +'print 5,5,turn +wend From 1150365f934439b2d9d2a60a7e80f18d27ef1958 Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 13:53:16 +0200 Subject: [PATCH 38/49] Create BubbleUniverse.bas --- Examples/BubbleUniverse.bas | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100644 Examples/BubbleUniverse.bas diff --git a/Examples/BubbleUniverse.bas b/Examples/BubbleUniverse.bas new file mode 100644 index 0000000..07ee600 --- /dev/null +++ b/Examples/BubbleUniverse.bas @@ -0,0 +1,31 @@ +'butterfly micro(A) +var x,y,i,a,turn,rr,gg,bb,cx,cy,cr +wcolor 0,0,0 +'frontpen 200,200,0 +while turn < 30 + +i=0 +fcolor 0,0,0 : rect 0,0,640,480 +'print 10,90,turn + while i < 120 + rr=rand(255) :gg=rand(255): bb=rand(255) + fcolor rr,gg,bb + x = sin(i+a)*50 - cos(i-a)*i + y = cos(i+a)*50 + sin(i-a)*i + cx=x+320: cy=y+240: cr=sin(i)*5 + circle cx,cy,cr + 'pset cx,cy +i=i+0.6 +'swap +wend + +a = a + 0.073 + +if a > 360 +a = -a +endif + +turn = turn + 0.1 +swap +'print 5,5,turn +wend From 167976147bd8595092e082903e487fbe59f69fef Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 13:54:09 +0200 Subject: [PATCH 39/49] Create BubbleSort.bas --- Examples/BubbleSort.bas | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) create mode 100644 Examples/BubbleSort.bas diff --git a/Examples/BubbleSort.bas b/Examples/BubbleSort.bas new file mode 100644 index 0000000..0c1c7c6 --- /dev/null +++ b/Examples/BubbleSort.bas @@ -0,0 +1,40 @@ +'bubble sort in micro(A) from LBB +wcolor 0,0,0 : fcolor 150,180,240 +var startTime,endTime,time +var sort, index, itemCount, temp, i ,hasChanged, counter +itemCount = 1000 +var item[itemCount] + +print 10,10,"Bubble Sort micro(A)..please wait!":swap +'before Sort...................... +i=1 +while i < itemCount + item[i] = rand(100) + i = i + 1 +wend +'................................. +'ticks start +GETTICK startTime + +counter = itemCount +label doLoop + hasChanged = 0 + i=1 + while i < counter + if item[i] > item[i + 1] + temp = item[i] + item[i] = item[i + 1] + item[i + 1] = temp + hasChanged = 1 + endif + i = i + 1 + wend + counter = counter - 1 +if hasChanged = 1 : goto doLoop : endif + +'ticks end +GETTICK endtime +time = (endTime - startTime) / 1000 +fcolor 230,140,120: print 10,250,time : swap + + From e8bbbfe60f54a0612da8a522a532a7248f136aba Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 13:55:12 +0200 Subject: [PATCH 40/49] Create BubbleCatch.bas --- Examples/BubbleCatch.bas | 62 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) create mode 100644 Examples/BubbleCatch.bas diff --git a/Examples/BubbleCatch.bas b/Examples/BubbleCatch.bas new file mode 100644 index 0000000..320db65 --- /dev/null +++ b/Examples/BubbleCatch.bas @@ -0,0 +1,62 @@ +'bubble catcher / demo +var HX, HY, i, hits, score, s,sx,sy +var nStars,wp : nStars = 150 +var ex1,ex2 +var ey1,ey2 +HX = 320 : HY = 400 ' hero stuff (you) +ex1 = 20 + Rand(600) : ey1=10 +'init wm_KeyDown +ptr wmKeyDown +wcolor 0,0,0 : fcolor 100,150,200 +print 10,510,"Bubble catcher in micro(A)..unfinished?":swap +'stars +i=1 +while i < nStars + sx = rand(640) : sy=rand(480) + pset sx,sy + i=i+1 +wend +swap + +WinMsg wmKEYDOWN + +hWparam wp + 'vkLEFT key + if wp = 37 : if hx > 10 : hx = hx - 10 : endif : endif + + 'vkRIGHT key + if wp = 39 : if hx < 600 : hx = hx + 10 : endif : endif + +goto DoLoop + +EndWm + +Label DoLoop +'cls +fcolor 0,0,0 : rect 0,0,640,480 +'stars +moveStars() +'move quad +moveQuad() +'move bubbles +moveBubbles() + + +swap +goto DoLoop +'-------------------------------------------- +func moveQuad() + fcolor 220,220,100 : rect hx,hy,20,20 +endfn +'-------------------------------------------- +func moveStars() + 'stars + fcolor 100,150,200 + s=1 : while s < nStars :sx = rand(640) : sy=rand(480) :print sx,sy,"." : s=s+1 :wend +endfn +'--------------------------------------------- +func moveBubbles() + 'move bubbles + ey1 = ey1 + 1 : if ey1 > 470 : ey1=10: ex1=20 + Rand(600): endif + fcolor 100,150,100: circle ex1,ey1,10 +endfn From 276e10033dd63188d804aa6f83d4759c6d1ae822 Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 13:56:43 +0200 Subject: [PATCH 41/49] Create Borg.bas --- Examples/Borg.bas | 160 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 160 insertions(+) create mode 100644 Examples/Borg.bas diff --git a/Examples/Borg.bas b/Examples/Borg.bas new file mode 100644 index 0000000..ead5ddc --- /dev/null +++ b/Examples/Borg.bas @@ -0,0 +1,160 @@ +' Borg attack in micro(A) by Aurel /demo +ptr img1,img2 ' image handlers +ptr wmKeyDown ' message handlers +var rightkey, leftkey, spacekey , esckey, score ,wp, pause, level, key, fire, run +var deltaX ,deltaY,bullet, bulletX, bulletY, borg ,borgX, borgY, x,y +var borgX2,borgY2,borgX3,borgY3 +wcolor 0,0,100 : fcolor 230,200,160 +'game frame... +rect 0,0,512,512 +'load images... +LoadImg img1,"deltaf.bmp",0,32,32,16 +LoadImg img2,"sphere.bmp",0,32,32,16 + +borg = 8 : level = 1 +'create alien arrays +var alien[8] + +'player origin position... +deltaX=512/2 : deltaY=512-64 : score=0 + +bullet=0 : bulletx=0 :bullety=0 +rightkey = 39 : leftkey = 37 ' arrow keys +spacekey = 32 : esckey = 27 +'.................................................... +'init borg position... +setBorg() +'................................................ +fcolor 220,220,200 : wcolor 0,0,150 +rect 520,0,200,290 : swap +fcolor 120,200,150 +print 530,10, "BORG ATTACK by Aurel" +print 530,30, "in micro(A) BASIC " +fcolor 180,210,240 : print 530,50, "[ARROWS <-->] to move" +fcolor 180,210,140 : print 530,70, "[SPACE] to fire" +fcolor 230,210,180 : print 530,90, "[R] to run" +rect 0,0,512,512 +'show delta flyer................... +showimgT img1, deltaX, deltaY, 32, 32 : swap +esckey = 0 : run = 0 + +'events................................................ +WINMSG wmKEYDOWN + +hWparam wp +'push keydown message to key variables +'vkLEFT 37 --------------------------------- +If wp = 37 + leftkey = wp + if run = 1 : goto mainloop : endif +EndIf + +'vkRIGHT 39 ------------------------------- +If wp = 39 + rightkey = wp + if run = 1 : goto mainloop : endif +EndIf + +'vkSPACE +If wp = 32 '& bullet = 0 + spacekey = wp + if run = 1 : goto mainloop : endif +EndIf + +'vk_R -> RUN +if wp = 82 + if run = 0 : run = 1 : goto mainloop: endif +endif + +'test ESC key +While wp ! 27 + 'wait... +Wend + +if wp = 27 : run = 0 : endif + +if wp ! 27 : goto start : endif + +ENDWM +'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +label mainloop +'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> + +label start +fcolor 220,220,200 : print 10,10 ,y + + If leftkey = 37 + If deltaX > 4 : deltaX = deltaX - 4 : EndIf + leftkey = 0 + EndIf + + If rightkey = 39 + If deltaX < 480 : deltaX = deltaX + 4 : EndIf + rightkey = 0 + EndIf + + + If spacekey = 32 + bullet = 1 + spacekey = 0 + ' bullet=0 + EndIf + +'move enemy -------------------------- +'0y = y + 1 : ' borgY = y * 0.1 +if y = 480 : y = 0 : endif +if borgY < 480 : borgY = borgY + 0.2 : else : borgY = y : endif +if borgY2 < 480 : borgY2 = borgY2 + 0.2 : else : borgY2 = y + (32*4) : endif +if borgY3 < 480 : borgY3 = borgY3 + 0.2 : else : borgY3 = y + (32*2) : endif + +'------------------------------------ + showEnemy() +'------------------------------------ + showPlayer() +'------------------------------------ + flip() + 'fnPause()-------------------------- +cls() + + +' back to mainloop <<<<<<<<<<<<<<<<<<<<<<<<< +if run = 1 : goto mainloop : endif +'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< + +func fnPause() + pause=0 + while pause < 150 : pause = pause + 0.1 : wend +endfn +'-------------------------------------------- +func showPlayer() + showimgT img1, deltaX, deltaY, 32, 32 +endfn +'------------------------------------------ +func showEnemy() + if level = 1 + if alien[1] = 1 : showimgT img2, borgX , borgY, 32, 32 : endif + if alien[2] = 1 : showimgT img2, borgX2, borgY2, 32, 32 : endif + if alien[3] = 1 : showimgT img2, borgX3, borgY3, 32, 32 : endif + endif +endfn +'........................... +func flip() + swap +endfn +'........................... +func cls() + 'clear area + rect 0,0,512,512 +endfn +'-------------------------------------------------- +func setBorg() + if level = 1 + alien[1] = 1 : borgX = 32 * 4 : borgY = 32 * 2 + alien[2] = 1 : borgX2 = 32 * 6 : borgY2 = 32 * 4 + alien[3] = 1 : borgX3 = 32 * 8 : borgY3 = 32 * 2 + endif +endfn +'------------------------------------------------- + +label gameover + print 100,100, "G A M E O V E R !": swap From 595112ef03d3b4703c31482d39fd96a433601b88 Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 13:57:52 +0200 Subject: [PATCH 42/49] Create BlackHole.bas --- Examples/BlackHole.bas | 44 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 Examples/BlackHole.bas diff --git a/Examples/BlackHole.bas b/Examples/BlackHole.bas new file mode 100644 index 0000000..895fc65 --- /dev/null +++ b/Examples/BlackHole.bas @@ -0,0 +1,44 @@ +' black Hole demo in micro(A) +var w,h,a,r,ps,i,px,py,rad +var rr,gg,bb,rx,ry + w=640/2 : h=480/2 +wcolor 0,0,100 + fcolor 200,220,160 +print 10,10,"Black hole" +a=1 : r=1 + +label again +i=1 +fcolor 0,0,0 : rect 0,0,800,600 + +while i < 60 + ps=70/(i/a) + rx=cos(i*r)*ps+w + ry=sin(i*r)*ps+h + fcolor 200,220,160 + circle ry,rx,4 + print 10,10,"Black hole" +'change values between 0.1 and 0.08 +i=i+0.3 +'swap +wend + +a=a+0.01 + +if a < 20 + a=a+0.1 + r = r - 0.19 +endif + +if r < 360 + r=r+0.01 +endif + +if r>360 + r=r-1 +endif + +swap +goto again +'commenr + From 432941272a0d83f1e7873958043713e9164f350e Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 13:58:57 +0200 Subject: [PATCH 43/49] Create BioRythm.bas --- Examples/BioRythm.bas | 113 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) create mode 100644 Examples/BioRythm.bas diff --git a/Examples/BioRythm.bas b/Examples/BioRythm.bas new file mode 100644 index 0000000..90b37fa --- /dev/null +++ b/Examples/BioRythm.bas @@ -0,0 +1,113 @@ +' current month bio-rythm in micro(A) +var lx1 ,ly1 ,lx2 ,ly2, f, y, startx, stopx, ndays,fd,fm,fy +var dd ,mm ,yy ,cd, cm, cy, bd, bm, by,dx,n,pi,t,tf +'set maincolor +wcolor 50, 80, 30 : fcolor 220, 200, 130 +print 20,5,"BioRythm in micro(A)" +pi = 3.14159 +'call draw raster fn +drawRaster() + +'current date +cd=13 +cm=7 +cy=2022 +'user birthday +bd=8 +bm=5 +by=1969 + +'calc difference +fd = 31 - (cd+bd) : fcolor 100,180,140 : print 20,330,fd +fm = 31 - (cm+bm) : fcolor 100,180,170 : print 20,360,fm + +'calc number of days +'current year - birth year -> number of years * 365 +ndays = (cy - by ) * 365 +fcolor 220,220,120 : print 20,300,"Number of days: " :print 200,300,ndays + +'call 3 func... +showPhysical() +showEmotional() +showIntellectual() +'show days.. +showDays() + +func drawRaster() +fcolor 100, 140, 110 : rect 20, 40, 601, 240 +lx1=20 :lx2=620 : ly1=60 +'horizontal lines ........................... +while ly1 < 280 + ly2=ly1 + line lx1, ly1, lx2, ly2 +ly1 = ly1 + 20 +wend + +ly1=40 +ly2=240 +'vertical lines............................. +while lx1 < 620 + lx2=lx1 + line lx1, ly1, lx2, ly2 +lx1=lx1+20 +wend +'center line +fcolor 100, 140, 181 : Line 20,140,620,140 + +swap +endfn + +'.......................................................... +func showPhysical() +'test phisyical : sin(2*PI/23 * t) +'fcolor 255,100,100 : print 40,262,dd +t = 0 : t = nDays +'phisical curve... +startx = 20 : f = startx: stopx = 620 : fColor 255,100,100 +tf = 620/28 + while f < stopx + y = 140 + sin( 2*(pi/23) * f/23)*(50+fd) + rect f,y,2,2 +f=f+1 + +wend +swap +endfn +'.......................................................... +func showEmotional() +'test emotional sin(2*PI/28 * t) +'emotional curve... +startx = 20 : f = startx: stopx = 620 : fColor 100,240,240 +while f < stopx + y = 140 + sin( 2*(pi/28) * f/28) * (50+fm) + rect f,y,2,2 +f=f+1 +wend + +swap +endfn +'......................................................... +func showIntellectual() +'test sin(2*PI/33 * t) +'intelectual curve... +startx = 20 : f = startx: stopx = 620 : fColor 100,180,140 + while f < stopx + y = 140 + sin( 2*(pi/33) * f/33) * 50 + rect f,y,2,2 +f=f+1 +wend + +swap +endfn +'............................................................ +func showDays() +dx=30 : n=1 : fcolor 100,150,220 +while dx < 620 + print dx,240,n + n=n+1 +dx=dx+20 +wend +swap +endfn + + From be9ce89440d84bf2cf881761307d4429797dd327 Mon Sep 17 00:00:00 2001 From: Aurel Date: Mon, 22 May 2023 14:00:57 +0200 Subject: [PATCH 44/49] Create Bench2.bas --- Examples/Bench2.bas | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 Examples/Bench2.bas diff --git a/Examples/Bench2.bas b/Examples/Bench2.bas new file mode 100644 index 0000000..90241c4 --- /dev/null +++ b/Examples/Bench2.bas @@ -0,0 +1,33 @@ +'floating point bench_02 by Aurel +var start,endtime,time +var i,ix,ixtra,x,y,t,t0,t2,n5,checsum +wcolor 0,0,0 : fcolor 120,140,200 : print 10,10,"bench FLOAT by Aurel" +fcolor 220,140,100 : print 10,40,"...please WAIT!" : swap +ixtra = 100 +n5 = 32 * 100 +t = 0.49999975 +t2 = 2.0 + +GETTICK start + X = 0.5 + Y = 0.5 + 'FOR ix = 1 TO ixtra + ix=1 + while ix < ixtra + ' FOR i = 1 TO n5 + i=1 + while i < n5 + X = t * ATAN(t2 * SIN(X) * COS(X) / (COS(X + Y) + COS(X - Y) - 1)) + Y = t * ATAN(t2 * SIN(Y) * COS(Y) / (COS(X + Y) + COS(X - Y) - 1)) + i = i + 1 + wend + t = 1.0 - t + ' NEXT ix + ix = ix + 1 + wend + t = t0 + checsum = Y +print 10,200,checsum +GETTICK endtime +time = (endTime - start) / 1000 +fcolor 200,200,240: print 10,250,time : swap From 91bff25781f9f2f6963f23ed182101080ba9e8d6 Mon Sep 17 00:00:00 2001 From: Aurel Date: Sat, 19 Aug 2023 21:36:02 +0200 Subject: [PATCH 45/49] Update Defender.bas --- Examples/Defender.bas | 231 +----------------------------------------- 1 file changed, 1 insertion(+), 230 deletions(-) diff --git a/Examples/Defender.bas b/Examples/Defender.bas index 648aa40..6f8f3b1 100644 --- a/Examples/Defender.bas +++ b/Examples/Defender.bas @@ -1,230 +1 @@ -' Defender in micro(A) by Aurel based on CraftBasic example -ptr img1,img2 ' image handlers -ptr wmKeyDown, wmTimer ' message handlers -var rightkey, leftkey, spacekey , esckey,score ,wp, pause, level,key -var apics , npics ,r, playerx ,playery,bullet, bulletx, bullety ,a,b,x,y -wcolor 0,0,100 : fcolor 230,200,160 -'game frame... -rect 0,0,512,512 -'load images... -LoadImg img1,"playerT.bmp",0,32,32,16 -LoadImg img2,"alien1.bmp",0,32,32,16 - -apics = 8 : level = 1 -'create alien arrays -var alienx[apics] -var alieny[apics] - - -'player origin position... -playerx=256 : playery=448 : score=0 - -bullet=0 : bulletx=0 :bullety=0 -rightkey = 39 : leftkey = 37 ' arrow keys -spacekey = 32 : esckey = 27 -'.................................................... -label create_alien_pics - - 'random X pos -> 400 - alienx[npics] = 1.5 + rand(400) - -'random Y pos -> 100 - alieny[npics] = rand(100) - - npics = npics + 1 - -If npics < apics : Goto create_alien_pics : EndIf -'................................................ -fcolor 220,220,200 : wcolor 0,0,150 -rect 0,0,330,290 : swap - -print 530,10, "DEFENDER by Aurel" -print 530,30, "in micro(A) BASIC " -print 530,50, "Use arrow keys to move" -print 530,70, "SPACE to shoot, and ESC to quit." -showimgT img1,playerx,playery,20,20 :swap -swap : esckey = 0 :Goto loop - -'events................................................ -WINMSG wmKEYDOWN - -hWparam wp -'push keydown message to key variables -'vkLEFT 37 --------------------------------- -If wp = 37 - leftkey = wp - wp=0 -EndIf - -'vkRIGHT 39 ------------------------------- -If wp = 39 - rightkey = wp - wp=0 -EndIf - -'vkSPACE -If wp = 32 '& bullet = 0 - spacekey = wp -EndIf - -'if wp = 27 : esckey = wp :goto loop: endif - -'test ESC key -While wp ! 27 - 'esckey = 0 - Goto start - ' esckey = 0 -Wend - -ENDWM -'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -label loop -'>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> -label start -'bullet = 0 - If leftkey = 37 - If playerx > 10 :playerx=playerx-4 : EndIf - leftkey = 0 - EndIf - - If rightkey = 39 - If playerx < 500 : playerx=playerx+4 : EndIf - rightkey = 0 - EndIf - - -If spacekey = 32 - 'bullet = 0 - bullet=1 - bulletx=playerx+9 - bullety=playery - spacekey = 0 - ' bullet=0 -EndIf - -If bullet = 1 - - fcolor 0,0,255 - x=bulletx - y=bullety+5 - 'line bulletx,bullety,x,y - - fcolor 255,0,0 - bullety=bullety-5 - - If bullety < 30 - bullet=0 - EndIf - -endif - - If bullety > 0 - x=bulletx - y=bullety+5 - line bulletx,bullety,x,y - EndIf - - - -npics = 1 ' first array index must be 1 -'--------------- - label move_pics -'--------------- - - -If bullet = 1 - - If bulletx > alienx[npics]-30 & bulletx < alienx[npics]+30 & bullety < alieny[npics]+30 - '(bulletx>=npcx[npc])&(bulletx<=(npcx[npc]+20))&(bullety<(npcy[npc]+20)) - fcolor 100,200,255 - - a=bulletx - b=bullety+5 - line bulletx,bullety,a,b - - x = alienx[npics] - y = alieny[npics] - fcolor 0,0,0 : rect x,y,32,32 - ' showimgT img2,x,y,20,20 - - score=score+1 - bullet=0 - - 'npics = npics - 1 - alienx[npics] = rand(400) - alieny[npics] = 1 - - EndIf - - EndIf -'------------------------------------ -r = rnd(1) ' decimal random 0 to 1 -r = r*0.2 -r = Round(r) - -If r = 0 - - fcolor 0,0,250 - x = alienx[npics] - y = alieny[npics] - - alieny[npics] = alieny[npics] + 0.1 - y = alieny[npics] - ' showimgT img2,x,y,20,20 - showEnemy() - 'showShip() - - if y > playery - cls() : goto gameover - endif - -endif -'------------------------------------- -npics = npics + 1 -'if npc > 10 : goto gameover : endif -if npics < apics : goto move_pics : endif -'------------------------------------- - fcolor 255,255,0 - print 10,10,"Score: " - print 80,10,score - -'............................... - - -showShip() - -flip() -'fnPause() -cls() - -' back to label loop <<<<<<<<<<<<<<<<<<<<<<<<< -if esckey = 0 : goto loop : endif -'<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< - -func fnPause() - pause=0 -while pause < 150 : pause = pause + 0.1 : wend -endfn -'-------------------------------------------- -func showShip() - showimgT img1,playerx,playery,32,32 -endfn -'------------------------------------------ -func showEnemy() - if level = 1 : showimgT img2,x,y,32,32 : endif - - -endfn -'........................... -func flip() - swap -endfn -'........................... -func cls() - 'clear area - rect 0,0,512,512 -endfn -'........................... - -label gameover - print 100,100, "G A M E O V E R !": swap +' this file is removed from examples From cbe490a08fcf1c5e0937f024da6dbeddf0563c28 Mon Sep 17 00:00:00 2001 From: Aurel Date: Sat, 19 Aug 2023 21:37:50 +0200 Subject: [PATCH 46/49] Update microA_Interpreter --- microA_Interpreter | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/microA_Interpreter b/microA_Interpreter index 34a103d..c71cb04 100644 --- a/microA_Interpreter +++ b/microA_Interpreter @@ -1,5 +1,5 @@ 'micro(A) Interpreter - with recursive descent token evaluator -'CURRENT VERSION v 10 +'CURRENT VERSION v 11 'Artistic Licence ,copyright (c)AurelSoft ' by Aurel - last update: 18.5.2023 From 5c784026cb9015366ce5993b28bd5ce116451deb Mon Sep 17 00:00:00 2001 From: Aurel Date: Sat, 19 Aug 2023 21:41:39 +0200 Subject: [PATCH 47/49] Create mandelbrot256 --- Examples/mandelbrot256 | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Examples/mandelbrot256 diff --git a/Examples/mandelbrot256 b/Examples/mandelbrot256 new file mode 100644 index 0000000..ebc95d9 --- /dev/null +++ b/Examples/mandelbrot256 @@ -0,0 +1,43 @@ +' mandelbrot translation from BASIC-256 +var graphwidth,graphheight,kt,m,xmin,xmax,ymin,ymax +var dx,dy,x,y,jx,jy,k,wx,wy,tx,ty,r +graphwidth = 600 : graphheight = 600 +kt=30 : m=4.0 +xmin=2.1 : xmax = -0.6 : ymin = -1.5 : ymax = 1.5 +dx=(xmax-xmin)/graphwidth : dy=(ymax-ymin)/graphheight +wcolor 0, 0, 0:swap + +x=0 +while x < graphwidth +jx=xmin+x*dx +y=0 +while y < graphheight +jy=ymin+y*dy +k = 0 : wx = 0 : wy = 0 + +Label MainCalculation +tx=wx*wx-(wy*wy+jx) +ty=2*wx*wy+jy +wx=tx +wy=ty +r=wx*wx+wy*wy +k=k+1 +if r < m & k < kt : goto MainCalculation : endif + + +if k > 0 : fcolor 0, 0, 139 : endif +if k > 5 : fcolor 0, 0, 139 : endif ' darkblue +if k > 10 : fcolor 0, 0, 255 : endif ' blue +if k > 15 : fcolor 0, 100, 0 : endif 'darkgreen +if k > 20 : fcolor 0, 250 ,0 : endif 'green +if k > 25 : fcolor 139, 0, 0 : endif ' darkred +if k > 30 : fcolor 250, 0, 0 : endif 'red +if k > 35 : fcolor 48,25,52 : endif 'darkpurple +if k > 40 : fcolor 160,32,240 : endif 'purple +if k > 45 : fcolor 0,0,0 : endif 'black +pset x,y +y=y+1 +wend +swap +x=x+1 +wend From 2bd8aa1dcce4bda022f03cc16ea474b0d91e1c63 Mon Sep 17 00:00:00 2001 From: Aurel Date: Sat, 19 Aug 2023 21:42:43 +0200 Subject: [PATCH 48/49] Create particleFountain.bas --- Examples/particleFountain.bas | 48 +++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 Examples/particleFountain.bas diff --git a/Examples/particleFountain.bas b/Examples/particleFountain.bas new file mode 100644 index 0000000..0e35bec --- /dev/null +++ b/Examples/particleFountain.bas @@ -0,0 +1,48 @@ +' particle fountain attempt in micro(A) 14.8.2023 +' original by B+ in sb/qb64 +var nP, i, xmax, ymax ,lp ,run +xmax = 800 : ymax = 600 : nP = 1000 +'declare arrays +var px[nP] ,py[nP] ,pdx[nP] , pdy[nP] ,pr[nP] , pc[nP] + +i=1 +while i < nP + new() + i=i+1 +wend + +'print 10,10 ,"array filled" : swap +run = 1 +'repeat +WHILE run = 1 + rect 0,0,800,600 'cls + If lp < nP : lp = lp + 10 : endif + ' For i = 1 To lp + i=1 + while i < lp + pdy[i] = pdy[i] + 0.1 + px[i] = px[i] + pdx[i] + py[i] = py[i] + pdy[i] + If px[i] < 0 | px[i] > xmax : new() : endif + If py[i] > ymax & pdy[i] > 0 + pdy[i] = -0.75 * pdy[i] : py[i] = ymax - 5 + EndIf + fcolor 200 , 200, 250 + Circle px[i], py[i], pr[i] + i=i+2 + wend + 'showpage + swap + WEND + + + +func new() + px[i] = xmax / 2 + Rand(20) - 10 + py[i] = ymax + Rand(5) + pdx[i] = Rnd(0.95) - 0.5 + pdy[i] = -10 + pr[i] = Rand(5) + pc[i] = Rand(55) + 245 '< 245? you want something bluish aqua for bubbly water +endfn + From 79dfe1d691d6866a7971f88194dcf726ccbbd18b Mon Sep 17 00:00:00 2001 From: Aurel Date: Sun, 20 Aug 2023 15:37:53 +0200 Subject: [PATCH 49/49] Update README.md --- README.md | 76 +------------------------------------------------------ 1 file changed, 1 insertion(+), 75 deletions(-) diff --git a/README.md b/README.md index bfc05a4..1756d55 100644 --- a/README.md +++ b/README.md @@ -4,78 +4,4 @@ It is Easy to Use BASIC like Programming Language. micro(A) interpreter comes with complete IDE in which you can make your programs. For more information look on -Community Forum - -Binary version is under Discussion board. -Source code only by request! - -![ScreenShot](https://aurelsoft.ucoz.com/logoA3.png) -![ScreenShot](https://aurelsoft.ucoz.com/microA_Interpreter.png) - -# List of built-in statements and functions -## variable types : -**var a,b,c,d** floating point variable type -**var a[10],b[20],c[30]** floating point array type - -**str e,f,g,h** string variable type -**str e[10],f[20],g[20]** string array type - -**ptr i,j,k,l** int | pointer variable type -**ptr i[10],j[20],k[30]** integer / pointer array type - -## statements : -** NOTE : Expressions are not allowed as argument !!! - -**print** x , y ,var | QS -> print variable or quoted string on window - -**wColor** r , g , b -> set window color - -**fColor** r , g , b -> set front color - -**bColor** r , g , b -> set back color - -**pset** x , y -> draw pixel on x,y position - -**circle** x , y , r -> draw circle on x,y position with radius r - -**line** x , y , x1 , y1 -> draw line from x,y position to x1,y1 - -**rect** x , y , w , h1 -> draw rectangle on x,y - -**label** name -> label - -**goto** name -> goto label - -**if** var **operator** n|s **Logic operator** var **operator** n|s -> if statement - -**operator** : **<** - less, **>** - greater, **=** - equal, **!** - not - -**Logic operator** : **&** - and , **|** - or - -**else** - else statement , **endif** - end if - -**loops** : - -**while** var **operator** n|s **Logic operator** var **operator** n|s - -**wend** - while end - -**func** - function / type null as subroutine - -**endfn** - function end - -//testing window messages use : WinMsg msgName .. EndWm - -new winApi functions added : - -**MouseX** var , **MouseY** var - -**hWparam** var , **hLParam** var - -//before you use message name you must declare it by ptr statement - -**ptr** wmMouseMove ,wmKeyDown - -**WinMsg** msagName **EndWm** - - +https://sourceforge.net/projects/micro-a-interpreter