15154
DEMO -> Other
© _Public_Domain_ (2018)
 
 
 
Frog Pond Collision Test
cpc
 
 

Last Update : Saturday 07 July 2018 at 17 h 31

Manual n° 1

Frog in a Pond Collision Test How it works Line Function 100-160 Setup Variables, Array & Test Collision Points for cx & cy array 170 Set Screen Mode, Inks, Border & Set Screen Write Mode to Fill 180-210 Draw Pond 220 Define Frog 230 Initial Coordinates of Frog & x, y direction to move frog 240 Set Screen Write Mode to XOR. 250 Main Loop 260 Draw Frog in Grphics Mode using Graphics Pen 1 270-290 Test Top side of Frog, if any of the check points return Graphics Pen 2, change Y direction of The Frog. 300-320 As above, though checks Right Side of Frog and change X direction of the Frog. 330-350 As above, though checks Left Side of Frog. 360-380 And this checks the Bottom side of Frog. 390 Update old positions & new positions, also update new coorinates for array positions. 400 Uses old coorinate position to delete frog by print over itself. 410 End of Main Loop returning to Line 260 as Loop is infinite. 1000-1030 This Routine takes all 16 Check Points (x & y) which were placed around frog and calculates the new positions around the newly drawn frog. The Program: 100 DEFINT a-z:DIM cx(16),cy(16) 110 FOR l=1 TO 16 120 READ cx(l),cy(l) 130 NEXT l 140 DATA 344,202,324,200,328,200,332,200,336,200,340,200,352,198 150 DATA 352,196,348,194,348,190,316,196,316,192,316,188,324,184 160 DATA 336,186,340,186 170 MODE 0:INK 0,11:INK 1,26:BORDER 11:PRINT CHR$(23)+CHR$(0); 180 PLOT 150,100,2:DRAWR 100,25:DRAWR 100,-25:DRAWR -25,-10:DRAWR 100,8 190 DRAWR 100,-8:DRAWR -4,100:DRAWR 4,100 200 DRAWR -100,-8:DRAWR -100,8 210 DRAWR -25,-10:DRAWR -100,-25:DRAWR -100,25:DRAWR 50,-180 220 SYMBOL 255,2,125,191,50,228,90,204,64 230 x=320:y=200:xd=4:yd=-2 240 PRINT CHR$(23)+CHR$(1); 250 WHILE 1 260 PLOT -2,-2,1:MOVE x,y:TAG:PRINT CHR$(255);:TAGOFF 270 FOR ct=1 TO 6 280 IF TEST(cx(ct),cy(ct))=2 THEN yd=-2 290 NEXT ct 300 FOR cr=7 TO 10 310 IF TEST(cx(cr),cy(cr))=2 THEN xd=-4 320 NEXT cr 330 FOR cl=11 TO 13 340 IF TEST(cx(cl),cy(cl))=2 THEN xd=4 350 NEXT cl 360 FOR cb=14 TO 16 370 IF TEST(cx(cb),cy(cb))=2 THEN yd=2 380 NEXT cb 390 ox=x:oy=y:x=x+xd:y=y+yd:GOSUB 1000 400 TAG:MOVE ox,oy:PRINT CHR$(255);:TAGOFF 410 WEND 1000 FOR c=1 TO 16 1010 cx(c)=cx(c)+xd:cy(c)=cy(c)+yd 1020 NEXT c 1030 RETURN

Manual n° 2

org &8000 .checktop ld hl,(pcy1) ld e,(hl) inc hl ld d,(hl) ex hl,de ;; cy contents put into hl push hl ;; preserve hl ld hl,(pcx1) ld e,(hl) inc hl ld d,(hl) pop hl call &bbf0 cp 2 jr nz,ct2 ;; value not found continue to next position ld hl,-2 ld (ydir),hl .ct2 ld hl,(pcy1) inc hl inc hl ld (pcy1),hl ld hl,(pcx1) inc hl inc hl ld (pcx1),hl ld a,(ct) inc a ld (ct),a cp 7 jr nz,checktop ld a,1 ld (ct),a ld hl,cy1 ld (pcy1),hl ld hl,cx1 ld (pcx1),hl .checkright ld hl,(pcy2) ld e,(hl) inc hl ld d,(hl) ex hl,de push hl ld hl,(pcx2) ld e,(hl) inc hl ld d,(hl) pop hl call &bbf0 cp 2 jr nz,cr2 ;; value not found continue to next position ld hl,-4 ld (xdir),hl .cr2 ld hl,(pcy2) inc hl inc hl ld (pcy2),hl ld hl,(pcx2) inc hl inc hl ld (pcx2),hl ld a,(cr) inc a ld (cr),a cp 11 jr nz,checkright ld a,7 ld (cr),a ld hl,cy2 ld (pcy2),hl ld hl,cx2 ld (pcx2),hl .checkleft ld hl,(pcy3) ld e,(hl) inc hl ld d,(hl) ex hl,de push hl ld hl,(pcx3) ld e,(hl) inc hl ld d,(hl) pop hl call &bbf0 cp 2 jr nz,cl2 ;; value not found continue to next position ld hl,4 ld (xdir),hl .cl2 ld hl,(pcy3) inc hl inc hl ld (pcy3),hl ld hl,(pcx3) inc hl inc hl ld (pcx3),hl ld a,(cl) inc a ld (cl),a cp 14 jr nz,checkleft ld a,11 ld (cl),a ld hl,cy3 ld (pcy3),hl ld hl,cx3 ld (pcx3),hl .checkbottom ld hl,(pcy4) ld e,(hl) inc hl ld d,(hl) ex hl,de push hl ld hl,(pcx4) ld e,(hl) inc hl ld d,(hl) pop hl call &bbf0 cp 2 jr nz,cb2 ;; value not found continue to next position ld hl,2 ld (ydir),hl .cb2 ld hl,(pcy4) inc hl inc hl ld (pcy4),hl ld hl,(pcx4) inc hl inc hl ld (pcx4),hl ld a,(cb) inc a ld (cb),a cp 17 jr nz,checkbottom ld a,14 ld (cb),a ld hl,cy4 ld (pcy4),hl ld hl,cx4 ld (pcx4),hl ret .calnewpos ld b,16 .calloop push bc ld hl,(pcx1) ld e,(hl) inc hl ld d,(hl) ex hl,de ;; contents of pcx1 in hl ld de,(xdir) add hl,de ex hl,de ;; move contents of pcx1 into de ld hl,(pcx1) ld (hl),e inc hl ld (hl),d ld hl,(pcy1) ld e,(hl) inc hl ld d,(hl) ex hl,de ld de,(ydir) add hl,de ex hl,de ld hl,(pcy1) ld (hl),e inc hl ld (hl),d ld hl,(pcx1) inc hl inc hl ld (pcx1),hl ld hl,(pcy1) inc hl inc hl ld (pcy1),hl pop bc djnz calloop ld hl,cx1 ld (pcx1),hl ld hl,cy1 ld (pcy1),hl ret .ct defb 1 .cr defb 7 .cl defb 11 .cb defb 14 .loop defb 1 .ydir defw -2 .xdir defw 4 .pcx1 defw cx1 .pcx2 defw cx2 .pcx3 defw cx3 .pcx4 defw cx4 .pcy1 defw cy1 .pcy2 defw cy2 .pcy3 defw cy3 .pcy4 defw cy4 .cx1 defw 344,324,328,332,336,340 .cx2 defw 352,352,348,348 .cx3 defw 316,316,316 .cx4 defw 324,336,340 .cy1 defw 202,200,200,200,200,200 .cy2 defw 198,196,194,190 .cy3 defw 196,192,188 .cy4 defw 184,186,186


Goto Top
CPC-POWER/CPCSOFTS, programming by Kukulcan © 2007-2018 all rights reserved.
Reproduction forbidden without any express authorization. All the game titles used belong to their respective owners.