Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
micro(A)v11
#5
I think i smell robot
 [Image: grin.png]
this is updated example with robot and hero
but without plants just to test scanning all 360 cells.

Code: (Select All)
'gdi demo aka CrazyRobot
ptr img0,img1,img2,img3
ptr wmKeyDown
var wp,ix,iy,p,ex,ey,run
var lx,ly,bx,by,cell, tmpx,tmpy,tmpCell,robotCell
var moveLeft,moveRight,moveUp,moveDown,moveTemp
wcolor 0,0,0:swap
'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,"hero.bmp",0, 32,32, 24
'print 10,250,img2
LoadImg img3,"robot.bmp",0, 32,32, 24
'print 10,300,img3
'ShowImgT img3,300, 300, 40, 40
info()
bx = 128 : by = bx + 32
updateBush()
'init positions..........................
ex = 32 : ey = 0 : robotCell = 2

run = 1
'main loop
WHILE run = 1

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

    updateBack() 
    updatePlayer()
    updatePosition()
    updateBush()
    updateRobot()
    'testCollision()
 
swap
' tiny delay for game loop
p=1 : while p < 800 : p=p+0.1 : wend

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 player 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 updateRobot()

    if robotCell = 360 : robotCell = 2 : ex = 32 : ey = 0 : endif         

    if robotCell < 361
                   
        'calc x,y position to cell
          ex = (ex + 32)
          cell = (robotCell % 24)*24
   
        if cell = robotCell :  ey = ey + 32 : ex = 0  : endif
        robotCell = robotCell + 1
        cell = 0
    endif
 
  'show robot
  ShowImgT img3, ex, ey, 32, 32
 
endfn
'----------------------------------
func updateBush()
  ShowImgT img1,bx,by,32,32
endFn

'*********************************************
'***  I N F O  ******************************
'*********************************************
func info()
'clear screen
fcolor 0,0,0 : rect 6,518,200,32 :

fcolor 200,180,100: print 10,520,"GDI_Robot 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
Reply


Messages In This Thread
micro(A)v11 - by aurel - 07-07-2023, 03:05 PM
RE: mAv11 - by mnrvovrfc - 07-07-2023, 06:52 PM
RE: mAv11 - by mnrvovrfc - 07-07-2023, 07:08 PM
RE: mAv11 - by aurel - 07-07-2023, 09:30 PM
RE: mAv11 - by aurel - 07-10-2023, 04:13 PM
RE: mAv11 - by aurel - 07-10-2023, 07:17 PM
RE: micro(A)v11 - by aurel - 07-12-2023, 05:03 PM
RE: micro(A)v11 - by aurel - 07-13-2023, 06:38 PM
RE: micro(A)v11 - by mnrvovrfc - 07-13-2023, 07:08 PM
RE: micro(A)v11 - by aurel - 07-15-2023, 04:27 PM
RE: micro(A)v11 - by aurel - 07-16-2023, 02:52 PM
RE: micro(A)v11 - by bplus - 07-16-2023, 03:56 PM
RE: micro(A)v11 - by aurel - 07-16-2023, 06:19 PM
RE: micro(A)v11 - by bplus - 07-16-2023, 06:39 PM
RE: micro(A)v11 - by mnrvovrfc - 07-16-2023, 07:34 PM
RE: micro(A)v11 - by aurel - 07-16-2023, 09:34 PM
RE: micro(A)v11 - by aurel - 07-16-2023, 09:42 PM
RE: micro(A)v11 - by aurel - 07-19-2023, 11:53 AM
RE: micro(A)v11 - by aurel - 07-21-2023, 06:38 AM
RE: micro(A)v11 - by mnrvovrfc - 07-21-2023, 06:45 AM
RE: micro(A)v11 - by aurel - 07-21-2023, 09:09 PM
RE: micro(A)v11 - by mnrvovrfc - 07-24-2023, 02:23 AM
RE: micro(A)v11 - by aurel - 07-24-2023, 07:00 AM
RE: micro(A)v11 - by aurel - 07-25-2023, 09:16 PM
RE: micro(A)v11 - by aurel - 07-26-2023, 05:30 PM
RE: micro(A)v11 - by aurel - 07-26-2023, 10:42 PM
RE: micro(A)v11 - by aurel - 07-27-2023, 09:55 AM
RE: micro(A)v11 - by mnrvovrfc - 07-28-2023, 02:29 AM
RE: micro(A)v11 - by mnrvovrfc - 07-28-2023, 07:42 AM
RE: micro(A)v11 - by aurel - 07-28-2023, 06:43 AM
RE: micro(A)v11 - by aurel - 07-28-2023, 09:38 AM
RE: micro(A)v11 - by mnrvovrfc - 07-28-2023, 05:59 PM
RE: micro(A)v11 - by aurel - 07-28-2023, 07:14 PM
RE: micro(A)v11 - by bplus - 07-29-2023, 03:09 PM
RE: micro(A)v11 - by mnrvovrfc - 07-29-2023, 07:07 PM
RE: micro(A)v11 - by bplus - 07-29-2023, 07:45 PM
RE: micro(A)v11 - by aurel - 07-29-2023, 09:30 PM
RE: micro(A)v11 - by aurel - 07-29-2023, 09:31 PM
RE: micro(A)v11 - by bplus - 07-29-2023, 09:53 PM
RE: micro(A)v11 - by mnrvovrfc - 07-29-2023, 10:10 PM
RE: micro(A)v11 - by aurel - 07-30-2023, 09:49 AM
RE: micro(A)v11 - by bplus - 07-30-2023, 02:35 PM
RE: micro(A)v11 - by aurel - 07-30-2023, 03:05 PM
RE: micro(A)v11 - by mnrvovrfc - 07-31-2023, 01:54 PM
RE: micro(A)v11 - by aurel - 07-31-2023, 02:10 PM
RE: micro(A)v11 - by mnrvovrfc - 07-31-2023, 02:39 PM
RE: micro(A)v11 - by aurel - 07-31-2023, 03:09 PM
RE: micro(A)v11 - by aurel - 07-31-2023, 03:10 PM
RE: micro(A)v11 - by mnrvovrfc - 08-01-2023, 03:12 PM
RE: micro(A)v11 - by bplus - 08-01-2023, 03:36 PM
RE: micro(A)v11 - by mnrvovrfc - 08-01-2023, 11:49 PM
RE: micro(A)v11 - by aurel - 08-02-2023, 08:21 AM
RE: micro(A)v11 - by mnrvovrfc - 08-08-2023, 03:59 AM
RE: micro(A)v11 - by aurel - 08-08-2023, 10:18 AM
RE: micro(A)v11 - by mnrvovrfc - 08-11-2023, 08:43 AM
RE: micro(A)v11 - by bplus - 08-11-2023, 09:17 AM
RE: micro(A)v11 - by aurel - 08-11-2023, 11:39 AM
RE: micro(A)v11 - by bplus - 08-11-2023, 01:19 PM
RE: micro(A)v11 - by aurel - 08-11-2023, 07:43 PM
RE: micro(A)v11 - by aurel - 08-11-2023, 10:41 PM
RE: micro(A)v11 - by aurel - 08-12-2023, 10:31 AM
RE: micro(A)v11 - by aurel - 08-12-2023, 10:36 AM
RE: micro(A)v11 - by aurel - 08-12-2023, 10:47 AM
RE: micro(A)v11 - by aurel - 08-12-2023, 10:49 AM
RE: micro(A)v11 - by mnrvovrfc - 08-12-2023, 12:18 PM
RE: micro(A)v11 - by bplus - 08-12-2023, 12:59 PM
RE: micro(A)v11 - by mnrvovrfc - 08-12-2023, 02:49 PM
RE: micro(A)v11 - by aurel - 08-12-2023, 07:14 PM
RE: micro(A)v11 - by bplus - 08-12-2023, 07:35 PM
RE: micro(A)v11 - by aurel - 08-12-2023, 09:02 PM
RE: micro(A)v11 - by mnrvovrfc - 08-14-2023, 04:43 PM
RE: micro(A)v11 - by aurel - 08-15-2023, 07:36 AM
RE: micro(A)v11 - by bplus - 08-15-2023, 12:42 PM
RE: micro(A)v11 - by aurel - 08-15-2023, 06:44 PM
RE: micro(A)v11 - by mnrvovrfc - 08-15-2023, 10:07 PM
RE: micro(A)v11 - by aurel - 08-16-2023, 06:51 AM
RE: micro(A)v11 - by aurel - 08-16-2023, 09:03 AM
RE: micro(A)v11 - by aurel - 08-20-2023, 10:54 AM
RE: micro(A)v11 - by mnrvovrfc - 08-20-2023, 01:23 PM
RE: micro(A)v11 - by aurel - 08-20-2023, 03:08 PM
RE: micro(A)v11 - by dbox - 08-20-2023, 03:46 PM
RE: micro(A)v11 - by mnrvovrfc - 08-20-2023, 04:19 PM
RE: micro(A)v11 - by aurel - 08-20-2023, 09:51 PM
RE: micro(A)v11 - by aurel - 08-25-2023, 01:47 PM
RE: micro(A)v11 - by aurel - 08-30-2023, 08:24 PM
RE: micro(A)v11 - by mnrvovrfc - 08-30-2023, 08:36 PM
RE: micro(A)v11 - by TerryRitchie - 08-30-2023, 09:18 PM
RE: micro(A)v11 - by aurel - 08-30-2023, 09:20 PM
RE: micro(A)v11 - by aurel - 08-31-2023, 07:40 PM
RE: micro(A)v11 - by aurel - 08-31-2023, 08:13 PM
RE: micro(A)v11 - by bplus - 08-31-2023, 09:14 PM
RE: micro(A)v11 - by aurel - 09-01-2023, 01:18 PM
RE: micro(A)v11 - by aurel - 09-08-2023, 07:05 AM
RE: micro(A)v11 - by aurel - 05-03-2024, 08:30 AM
RE: micro(A)v11 - by aurel - 05-03-2024, 08:44 AM
RE: micro(A)v11 - by aurel - 05-05-2024, 11:43 AM
RE: micro(A)v11 - by bplus - 05-05-2024, 05:25 PM
RE: micro(A)v11 - by aurel - 05-06-2024, 05:07 AM
RE: micro(A)v11 - by aurel - 08-03-2024, 10:57 AM
RE: micro(A)v11 - by bplus - 08-03-2024, 12:04 PM
RE: micro(A)v11 - by aurel - 08-03-2024, 12:49 PM
RE: micro(A)v11 - by Pete - 08-03-2024, 01:37 PM
RE: micro(A)v11 - by aurel - 08-03-2024, 03:41 PM
RE: micro(A)v11 - by bplus - 08-03-2024, 05:13 PM
RE: micro(A)v11 - by SMcNeill - 08-04-2024, 05:51 PM
RE: micro(A)v11 - by aurel - 08-04-2024, 06:41 PM
RE: micro(A)v11 - by Pete - 08-04-2024, 08:02 PM
RE: micro(A)v11 - by aurel - 08-05-2024, 06:26 AM



Users browsing this thread: 21 Guest(s)