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 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 + + 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 + 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 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 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 + + 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 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 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 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 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 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 diff --git a/Examples/Defender.bas b/Examples/Defender.bas new file mode 100644 index 0000000..6f8f3b1 --- /dev/null +++ b/Examples/Defender.bas @@ -0,0 +1 @@ +' this file is removed from examples 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 + 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 + + + + + + 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 + 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 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 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 + 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 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 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 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 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 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 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 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 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 + 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 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 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 + 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 + 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 + + 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 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 + + + + 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 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 + + + 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 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 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 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 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 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 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 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 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 + 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 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