'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
Page created in 0.125 seconds with 8 queries.