Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
micro(A) demo : Santa Cutter
#1
hello boys..
i become annoying by not doing any programs Big Grin 
so i try to improve some demos in micro(A)
to see can i make it



Attached Files Thumbnail(s)
   
Reply
#2
here is little bit larger image of output window

if anyone want to look into code here is :
Code: (Select All)
'gdi santa demo 10.12.2025
ptr img0,img1,img2,img3,img4
ptr wmKeyDown
var wp,ix,iy,p,ex,ey,lx,ly,bx,by,cell, tmpx,tmpy,tmpCell
var bx1,by1,bx2,by2,bx3,by3,bx4,by4,bx5,by5,bx6,by6,bx7,by7
var tbx ,tby ,bushCell ,tbx1 ,tby1 ,bushCell1 ,tbx2 ,tby2 ,bushCell2, tbx3 ,tby3 ,bushCell3
var tbx4 ,tby4 ,bushCell4, tbx5 ,tby5 ,bushCell5, tbx6 ,tby6 ,bushCell6, tbx7 ,tby7 ,bushCell7
var plants[360] ,plantCell ,i, pcx, pcy, col, tempX, energy ,run
'var moveLeft,moveRight,moveUp,moveDown
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,"santa.bmp",0, 32,32, 24
'print 10,250,img2
LoadImg img3,"alien.bmp",0, 32,32, 24
'print 10,300,img3
LoadImg img4,"pine.bmp",0, 32,32, 24
'plant img
ShowImgT img4, 32*5, 32*2, 40, 40
energy = 100 : info() : fillPlants()
bx = 128 : by = bx + 32 : bx1 = 256 : by1 = bx1 + 32 : bx2 = 384 : by2 = 128 + 32 : bx3 = 512 : by3 = 288
bx4 = 128-32 : by4 = (bx4 + 64)+32 : bx5 = 256-32 : by5 = (bx5 +32)+ 64 :  bx6 = 384+32 : by6 = 128 
updateBush()  : updateBush1()  : updateBush2() :  updateBush3()
updateBush4() : updateBush5()  : updateBush6()
'ex = 300 : ey = 300

run = 1
'main loop
While run = 1
'read keys...
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 < 436 : iy = iy + 32 : endif
endif
'--------------------------------------------------

    updateBack() 
    updatePosition()
    updatePlayer()
    updatePlants()
   
swap

Wend

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 -> player cell
   tmpCell = int(iy/32)*24 + int(ix/32) + 1
   
   fcolor 180,100,50  : rect 306,512,56,24 : print 310,514, tmpx
   fcolor 180,100,50  : rect 406,512,56,24 : print 410,514, tmpy
   'show cell number
   fcolor 50,170,100  : rect 206,512,56,24 : print 210,514, tmpCell
   
  if tmpCell = bushCell
      energy = energy - 1
      fcolor 50,170,100  : rect 206,482,56,24 : print 210,484,energy
      ix = ix + 32  ' move player one cell
  endif
  if tmpCell = bushCell1
      energy = energy - 1
      fcolor 50,170,100  : rect 206,482,56,24 : print 210,484,energy
      ix = ix + 32  ' move player one cell
  endif
  if tmpCell = bushCell2
      energy = energy - 1
      fcolor 50,170,100  : rect 206,482,56,24 : print 210,484,energy
      ix = ix + 32  ' move player one cell
  endif
  if tmpCell = bushCell3
      energy = energy - 1
      fcolor 50,170,100  : rect 206,482,56,24 : print 210,484,energy
      ix = ix + 32  ' move player one cell
  endif
  if tmpCell = bushCell4
      energy = energy - 1
      fcolor 50,170,100  : rect 206,482,56,24 : print 210,484,energy
      ix = ix + 32  ' move player one cell
  endif
  if tmpCell = bushCell5
      energy = energy - 1
      fcolor 50,170,100  : rect 206,482,56,24 : print 210,484,energy
      ix = ix + 32  ' move player one cell
  endif
  if tmpCell = bushCell6
      energy = energy - 1
      fcolor 50,170,100  : rect 206,482,56,24 : print 210,484,energy
      ix = ix + 32  ' move player one cell
  endif
  if tmpCell = bushCell7
      energy = energy - 1
      fcolor 50,170,100  : rect 206,482,56,24 : print 210,484,energy
      ix = ix + 32  ' move player one cell
  endif

endfn
'----------------------------------------
func updateBack()
  ShowImgT img0,0,0,770,482
  updateBush() : updateBush1() : updateBush2() : updateBush3():  updateBush4()
  updateBush5(): updateBush6()
  'update plant
  'updatePlants()
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
'------------------------------------------------
func updateBush1()
   ShowImgT img1,bx1,by1,32,32
   'calculate bush1 position
     tbx1 = int((bx1 + 32) / 32)
     tby1 = int(by1/32) + 1
     bushCell1 = int(by1/32)*24 + int(bx1/32) + 1
endFn
'------------------------------------------------
func updateBush2()
   ShowImgT img1,bx2,by2,32,32
   'calculate bush2 position
     tbx2 = int((bx2 + 32) / 32)
     tby2 = int(by2/32) + 1
     bushCell2 = int(by2/32)*24 + int(bx2/32) + 1
endFn
'-------------------------------------------------
func updateBush3()
   ShowImgT img1,bx3,by3,32,32
   'calculate bush3 position
     tbx3 = int((bx3 + 32) / 32)
     tby3 = int(by3/32) + 1
     bushCell3 = int(by3/32)*24 + int(bx3/32) + 1
endFn
'-------------------------------------------------
func updateBush4()
   ShowImgT img1,bx4,by4,32,32
   'calculate bush4 position
     tbx4 = int((bx4 + 32) / 32)
     tby4 = int(by4/32) + 1
     bushCell4 = int(by4/32)*24 + int(bx4/32) + 1
endFn
'-------------------------------------------------
func updateBush5()
   ShowImgT img1,bx5,by5,32,32
   'calculate bush5 position
     tbx5 = int((bx5 + 32) / 32)
     tby5 = int(by5/32) + 1
     bushCell5 = int(by5/32)*24 + int(bx5/32) + 1
endFn
'-------------------------------------------------
func updateBush6()
   ShowImgT img1,bx6,by6,32,32
   'calculate bush6 position
     tbx6 = int((bx6 + 32) / 32)
     tby6 = int(by6/32) + 1
     bushCell6 = int(by6/32)*24 + int(bx6/32) + 1
endFn

'-------------------------------------------------
func updatePlants()
    i=1 : pcx = 0 : pcy = 0
    while i < 361
                 
          plants[1] = 0         
           if plants[i] = 1
               'show plant sprite
               ShowImgT img4, pcx, pcy, 32, 32
           endif
          ' if plants[i] = 0
           '   print pcx,pcy,"0"
          ' endif

          pcx = pcx + 32
          'modulus operator work
          cell = (i % 24)*24
          if cell = i :  pcy = pcy + 32 :pcx = 0  : endif

          'check bush positions   
          if bushCell  = i : plants[i] = 0 : endif
          if bushCell1 = i : plants[i] = 0 : endif
          if bushCell2 = i : plants[i] = 0 : endif
          if bushCell3 = i : plants[i] = 0 : endif
          if bushCell4 = i : plants[i] = 0 : endif
          if bushCell5 = i : plants[i] = 0 : endif
          if bushCell6 = i : plants[i] = 0 : endif

          'eat plant..?
          if tmpCell = i : plants[i] = 0 : endif
         
    i = i + 1
    wend
endfn

func fillPlants()
'fill plants array with rand 0 or 1
i=1
while i < 361
    plants[i] = rand(1)   
i = i + 1
wend

endfn

'*********************************************
'***  I N F O   ******************************
'*********************************************
func info()
'clear screen
fcolor 0,0,0 : rect 6,518,200,32 :
fcolor 200,180,100: print 10,530,"SantaCut by Aurel"
fcolor 50,190,100 : print 140,484,"ENERGY:"
print 140,514,"CELL:"
rect 206,482,56,24 : print 210,484,energy
fcolor 180,100,50  : print 270,514,"ROW:" : print 370,514,"COL:"
endfn


Attached Files Thumbnail(s)
   
Reply
#3
tiny addition ..roto spiral

Code: (Select All)
'roto spiral by ZXDunny micro(A) version by Aurel
var d,z0,p,q,b,tau,tau20,scrw,scrh : scrw = 800 : scrh = 600
var x,y,z,zz,a,b,yy,xx
d=700 : z0=2500 :p = -0.3 : q= -0.3 : b = -0.3 : tau = 6.2831
MODE 1 : wcolor 0,0,0 : fcolor 0,255,55

label doLoop
    b = b + 0.3 :
    rect 0,0,800,600  'cls
  
    a=0 : tau20 = 20 * tau
    While a < tau20
       x = 5*a*cos(a) : y = -a*10 : z=5*a*sin(a)
       yy = (y+350)*cos(b)-z*sin(b) : zz=(y+350)*sin(b)+z*cos(b)
       y=yy-350 : z=zz : xx=x*cos(b)-z*sin(b) : zz=x*sin(b)+z*cos(b)
       x=xx : z=zz : xx=x*cos(b)-(y+350)*sin(b) : yy=x*sin(b)+(y+350)*cos(b)

       print scrw/2+xx*d/(z+z0) , scrh/2-(100+yy-350)*d/(z+z0)-150 ,"*"

    a = a + 0.1
    Wend
swap
goto doLoop
'thanks for watching ...and merry christmas ...!!!!


Attached Files Thumbnail(s)
   
Reply
#4
Yeah vince had the QB64 version of that with the star last year at least:
Code: (Select All)
Dim Shared pi, sw, sh, d, z0, p, q
pi = 4 * Atn(1)
d = 700
z0 = 2500

sw = 800
sh = 600

Dim As Double a, b, x, y, z, xx, yy, zz
Screen _NewImage(sw, sh, 32)
Do
    b = b + 0.03
    Cls
    'tree
    For a = 0 To 20 * 2 * pi Step 0.1
        x = 5 * a * Cos(a)
        y = -a * 10
        z = 5 * a * Sin(a)

        yy = (y + 350) * Cos(b) - z * Sin(b)
        zz = (y + 350) * Sin(b) + z * Cos(b)
        y = yy - 350
        z = zz

        xx = x * Cos(b) - z * Sin(b)
        zz = x * Sin(b) + z * Cos(b)
        x = xx
        z = zz

        xx = x * Cos(b) - (y + 350) * Sin(b)
        yy = x * Sin(b) + (y + 350) * Cos(b)
        x = xx
        y = yy - 350

        proj x, y, z

        Circle (p, q), 1, _RGB(0, 155, 0)
    Next


    'star a pixel at a time
    For a = 0 To 6 * pi Step 0.1
        rr = 100
        r = 60
        x = (rr - r) * Cos(a + pi / 4) + 70 * Cos(((rr - r) / r) * a)
        y = 50 + (rr - r) * Sin(a + pi / 4) - 70 * Sin(((rr - r) / r) * a)
        z = 0

        yy = (y + 350) * Cos(b) - z * Sin(b)
        zz = (y + 350) * Sin(b) + z * Cos(b)
        y = yy - 350
        z = zz

        xx = x * Cos(b) - z * Sin(b)
        zz = x * Sin(b) + z * Cos(b)
        x = xx
        z = zz

        xx = x * Cos(b) - (y + 350) * Sin(b)
        yy = x * Sin(b) + (y + 350) * Cos(b)
        x = xx
        y = yy - 350

        proj x, y, z

        Circle (p, q), 1, _RGB(255, 255, 0)
    Next
    _Display
    _Limit 50
Loop

Sub proj (x, y, z)
    p = sw / 2 + x * d / (z + z0)
    q = sh / 2 - (100 + y) * d / (z + z0) - 150
End Sub

   
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply
#5
ahh i see
well i just modify ZXDunny specbas program
and yes with star is better Wink
Reply
#6
i have one for Pete


Attached Files Thumbnail(s)
   
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  micro(A) demo game: Ghost&Coin aurel 6 365 01-12-2026, 02:55 PM
Last Post: aurel
  micro(A)v11 aurel 114 19,233 05-01-2025, 10:06 AM
Last Post: aurel
  QBJS Sound Demo dbox 10 2,184 03-06-2024, 05:51 PM
Last Post: madscijr
Photo SVG lines to micro(A) string array initialization mnrvovrfc 2 744 08-03-2023, 12:35 PM
Last Post: aurel

Forum Jump:


Users browsing this thread: 1 Guest(s)