Jump to content
IGNORED

CALL COINC


orion1052003

Recommended Posts

Well, many ways... but I would use a COINC detection, (one is detected)... then stop the motions of the SPRITEs and change the PATTERN of them... or you can make new SPRITEs after DELSPRITEing the existing ones...

 

***COLLISION HAPPENS

-CALL MOTION(#X,0,0)

-CALL PATTERN(#X,BLOWING-UP-PATTERN)

-CALL DELSPRITE

 

Any number of ways... just stop motion and create new designs.

Link to comment
Share on other sites

Ohhh - I should share my explosion from my Dr Who based game that I'll likely never finish. It's AWESOME! Sprite motion for Daleks is pretty damn effective and my Slitheens look awesome.

 

here's the code... play the game to see the explosion.

10 CALL SCREEN(1)::CALL CLEAR::RANDOMIZE::CALL INIT::CALL CHARPAT(45,A$)::CALL CHAR(81,A$)::FL=1
15 FOR I=0 TO 1::READ A$::CALL CHAR(36+(I*4),A$)::NEXT I::READ A$::CALL CHAR(44,A$)::READ A$::CALL CHAR(60,A$)
18 FOR I=0 TO 12::READ A$::CALL CHAR(92+(I*4),A$)::NEXT I::READ DL,DL$(0),DL$(1),DR,DR$(0),DR$(1)::READ A,A$::CALL CHAR(A,A$)
19 DIM MU(33)::FOR I=0 TO 32::READ MU(I)::NEXT I::FOR I=2 TO 13::CALL COLOR(I,16,2)::NEXT I::CALL COLOR(14,6,1)::GOTO 500
REM SETUP LEVEL
20 REM
21 CALL MAGNIFY(3)::FOR I=0 TO 9::CALL HCHAR(RND*12+1,INT(RND*32)+1,66)::NEXT I::TX=INT(RND*28)::CALL SPRITE(#28,136,5,1,17+TX*
22 CALL HCHAR(1,TX+3,94)::CALL HCHAR(1,TX+4,95)::CALL HCHAR(2,TX+3,142)::CALL HCHAR(2,TX+4,143)
23 RX=0::RY=0::R=177::C=129
25 F=1::S=5:=1::FOR I=2 TO 10 STEP 2::CALL SPRITE(#S,114+D*2,11,I*8+1,1,0,D*10):=-D::S=S+1::NEXT I
26 FOR I=14 TO 16 STEP 2::CALL SPRITE(#S,132,15,I*8+1,1,0,D*10):=-D::S=S+1::NEXT I
27 FOR I=18 TO 20 STEP 2::CALL SPRITE(#S,100+D*4,3,I*8+1,1,0,D*10):=-D::S=S+1::NEXT I
29 CALL SPRITE(#1,40,15,R,C)
REM GAME LOOP
30 IF RX=0 AND RY<>0 THEN 32
31 CALL JOYST(1,X,Y)::RX=X::RY=Y::GOTO 33
32 X=RX::Y=RY::RX=0::RY=0
33 IF X=0 THEN 35 ELSE CALL PATTERN(#1,38+(X/2))::C=C+X*2::IF C<17 THEN C=17 ELSE IF C>233 THEN C=233
35 IF Y=0 THEN 36 ELSE CALL PATTERN(#1,52-Y*2)::R=R-Y*2::IF R<2 THEN 101 ELSE IF R>177 THEN R=177
36 CALL LOCATE(#1,R,C)
99 CALL COINC(ALL,A)::IF A<>0 THEN 101
100 GOTO 30
101 REM CHECK FOR SUCCESS / DEATH
REM DEATH - nice eh?
110 CALL MOTION(#1,0,0)::CALL COLOR(#1,7)::SN=16::CALL POSITION(#1,X,Y)::CALL SOUND(-1000,-7,0)
112 FOR I=1 TO 4::CALL SPRITE(#I,120,7,X,Y)::NEXT I::CALL SOUND(-1000,-7,5)
113 CALL MOTION(#1,2,2)::CALL MOTION(#2,2,-2)::CALL MOTION(#3,-2,2)::CALL MOTION(#4,-2,-2)::CALL SOUND(-1000,-7,10)
114 FOR I=1 TO 45::NEXT I::FOR I=1 TO 4::CALL PATTERN(#I,124)::NEXT I::CALL SOUND(-1000,-7,15)
115 FOR I=1 TO 35::NEXT I::FOR I=1 TO 4::CALL PATTERN(#I,128)::NEXT I::CALL SOUND(-1000,-7,20)
116 FOR I=1 TO 25::NEXT I::FOR I=1 TO 4::CALL DELSPRITE(#I)::NEXT I
118 X=RND*60-30::CALL MOTION(#SN,X,RND*60-30)::SN=SN-1::CALL SOUND(-1000,500+X*10,4,900-X*10,10)::IF SN>1 THEN 118
119 FOR I=550 TO 110 STEP -50::CALL SOUND(-100,I,0,I+110,4,I+220,8,-2,0)::NEXT I
REM TITLE SCREEN
500 CALL DELSPRITE(ALL)::CALL CLEAR::CALL MAGNIFY(4)::DISPLAY AT(5,12):"KQ9 ESCAPE"::DISPLAY AT(8,1):"2010 UNHUMAN SOFTWARE"
501 DISPLAY AT(1,1):"LAST SCORE: "&STR$(S)::CALL SPRITE (#28,136,5,33,211)::CALL HCHAR(6,28,92)::CALL HCHAR(6,29,93)
502 CALL HCHAR(7,28,140)::CALL HCHAR(7,29,140)::CALL HCHAR(8,28,140)::CALL HCHAR(8,29,140)::DISPLAY AT(22,7):"NOT FOR SALE"
510 CALL SPRITE(#1,40,15,100,1,0,20)::FOR J=0 TO 150::NEXT J
511 FOR I=4 TO 2 STEP -1::FOR J=0 TO 150::NEXT J::CALL SPRITE(#I,116,12,100,1,0,20)::NEXT I
996 ML=MU(0)::ML2=ML::MN=0::CALL SAY("K 9")::DISPLAY AT(24,4):"PRESS ANY KEY TO START"
997 FL=1-FL::CALL CHAR(DR,DR$(FL))::CALL SOUND(-250,MU(MN),0,ML,5,ML2,10)::ML2=ML::ML=MU(MN)::MN=MN+1::IF MN>32 THEN MN=0
998 CALL KEY(0,K,S)::IF K=-1 THEN 997
999 CALL DELSPRITE(ALL)::CALL CLEAR::CALL MAGNIFY(3)::GOTO 20
REM k-9 LEFT & RIGHT 36, 40
1000 DATA 0020103C2CFCFE7E0403070A09091A1F00000000000000031CE0F08888E8ECFC,00000000000000C038070F151313353F0004083C343F7F7E20C0E01010D0D8F8
REM K-9 UP & DOWN 44,60
1001 DATA 06075F371F1F03000000000000000101000000031FA167677F6D73A19F830000,0000C1F985CEB6FEE6E685F8C0000000808000000000000000C0F8F8ECFAE060
REM 88 available
REM TARDIS WINDOWS 92,93 (TITLE SCREEN) 94,95 (IN-GAME)
1002 DATA 00003F3F3F3F3F3F0000FFFFFFFFFFFF0000000000000F0F000000000000F0F0
REM SLITHEEN (left) 96, 100
1004 DATA 1F2F467FF9F97F008FDFFF0F193163E7804020E0F0F0C0000080808000000000,1F2F467FFFF97F000F1F7F8F89080C1D804020E0F0F0C000008080800080C0C0
REM SLITHEEN (right) 104, 108
1005 DATA 010204070F0F03000001010100000000F8F462FE9F9FFE00F1FBFFF0988CC6E7,010204070F0F03000001010100010303F8F462FEFF9FFE00F0F8FEF1911030B8
REM DALEK - left & right 112, 116
1007 DATA 000103010341639A06040505080C0F0160F8FC08FC08FC0464629A9A6163FFF8,061F3F103F103F202646595986C6FF1F0080C080C082C6596020A0A01030F080
REM EXPLOSIONS 1,2 120, 124
1009 DATA 000004002001000010010400100000000004400010000000C480000480080000,000004002001000010010400100000000004400010000000C480000480080000
REM EXPLOSION 3 128 & CYBERMEN  132
1011 DATA 0000001000000020010000000400000000008008000000000008000000040000,00033F23272F39391F0F0F0C070700000080F888C8E83838F0E0E060C0C00000
REM TARDIS 136 & doors 140, 141 - TITLE SCREEN, 142,143 in GAME
1012 DATA 01030207081F15151F11111F11113F7F008080C020F05050F01010F01010F8FC,3F3F3F3F3F3F3F3FFFFFFFFFFFFFFFFF0F0F0F0F0F0F0F0FF0F0F0F0F0F0F0F0
REM TARDIS PARTS
REM DALEK going left hand positions and then going right hand positions
1018 DATA 112,000103010341639A,00010341C3A1130A,118,0080C080C082C659,0080C082C385C850
REM STAR
1020 DATA 66,00000010
REM SONG - LEFT HAND
REM D E E E D E E E D E E E F G G G D E E E D E E E D E E E F G G G D
1025 DATA 147,165,165,165,175,165,165,165,175,165,165,165,175,196,196,196,147,165,165,165,175,165,165,165,175
1029 DATA 165,165,165,175,196,196,196,147

Link to comment
Share on other sites

It seems like when you do CALL COINC from a subprogram, you must pass the variable for it to register with an object in a subprogram colliding with an object in the main program.

 

 

40 !COINCTEST(WORKS)

50 CALL CLEAR :: CALL SCREEN(3)

60 CALL COLOR(9,2,2,10,11,11)

70 CALL SPRITE(#1,96,2,89,1,0,10,#2,104,11,89,249,0,-10)

80 !ALL OBJECT

90 CALL COINC(#1,#2,10,C)

95 DISPLAY AT(24,1):"C= ";C

100 IF C THEN CALL SOUND(500,440,0)

110 GOTO 90

---------------------------------------------------------------------------

 

40 !COINCTEST(ALSO WORKS)

50 CALL CLEAR :: CALL SCREEN(3)

60 CALL COLOR(9,2,2,10,11,11)

70 CALL SPRITE(#1,96,2,89,1,0,10,#2,104,11,89,249,0,-10)

80 !ALL OBJECT

90 CALL COINC(#1,#2,10,C)

95 DISPLAY AT(24,1):"C= ";C

100 IF C THEN CALL SOUND(500,440,0)

110 GOTO 90

---------------------------------------------------------------------------

40 !COINCTEST(THISWORKS)

50 CALL CLEAR :: CALL SCREEN(3)

60 CALL COLOR(9,2,2,10,11,11)

70 CALL SPRITE(#1,96,2,89,1,0,10)! #2,104,11,89,249,0,-10)

80 CALL OBJECT©

90 CALL COINC(#1,#2,10,C)

95 DISPLAY AT(24,1):"C= ";C

100 IF C THEN CALL SOUND(500,440,0)

110 GOTO 90

120 SUB OBJECT©

130 CALL SPRITE(#2,104,11,89,249,0,-10)

140 !ALL COINC(#1,#2,10,C)

200 SUBEND

---------------------------------------------------------------------------

40 !COINCTEST(DOESNOTWORK)

50 CALL CLEAR :: CALL SCREEN(3)

60 CALL COLOR(9,2,2,10,11,11)

70 CALL SPRITE(#1,96,2,89,1,0,10)! #2,104,11,89,249,0,-10)

80 CALL OBJECT

90 !ALL COINC(#1,#2,10,C)

95 DISPLAY AT(24,1):"C= ";C

100 IF C THEN CALL SOUND(500,440,0)

110 GOTO 90

120 SUB OBJECT

130 CALL SPRITE(#2,104,11,89,249,0,-10)

140 CALL COINC(#1,#2,10,C)

200 SUBEND

---------------------------------------------------------------------------

40 !COINCTEST(DOESNOTWORK)

50 CALL CLEAR :: CALL SCREEN(3)

60 CALL COLOR(9,2,2,10,11,11)

70 CALL SPRITE(#1,96,2,89,1,0,10)! #2,104,11,89,249,0,-10)

80 CALL OBJECT©

90 !ALL COINC(#1,#2,10,C)

95 DISPLAY AT(24,1):"C= ";C

100 IF C THEN CALL SOUND(500,440,0)

110 GOTO 90

120 SUB OBJECT©

130 CALL SPRITE(#2,104,11,89,249,0,-10)

140 CALL COINC(#1,#2,10,C)

200 SUBEND

Link to comment
Share on other sites

Okay, can't really see any difference between WORKS and ALSO WORKS.

 

THISWORKS does much the same, only calls a subroutine for setting up sprite #2.

 

DOESNOTWORK has a loop (90-110) which does not call COINC. You continuously have to call COINC to try and detect any coincidence.

 

The last part seems to be a copy of DOESNOTWORK with another subroutine name. Oh, I guess it's not the copyright symbol there but you're trying to pass C as a parameter. At line 80 you're passing the value of C, which is 0 at this time. The subroutine receives C, but does not use it, and line 140 overwrites the value of C. Some of the problem may be that the loop (90-110) never calls the routine, but then again, it would be a mistake (I guess) to set up sprite #2 again and again.

Link to comment
Share on other sites

This is faster:

 

10 DR,DC=1
20 !TEST PROGRAM-USE CALL LOCATE WITH JOYST
25 P1=15 :: P2=10
30 CALL CLEAR :: CALL SCREEN(6) :: CALL COLOR(9,2,2)
40 A$="FFFFFFFFFFFFFFFF" :: B$="FFFFFFFFFFFFFFFF"
42 C$="FFFFFFFFFFFFFFFF" :: D$="FFFFFFFFFFFFFFFF" :: E$="FFFFFFFFFFFFFFFF"
50 CALL CHAR(96,A$,104,B$,112,C$,120,D$,128,E$)
60 CALL SPRITE(#1,96,2,89,121)
65 DR=100 :: DC=100
66 DISPLAY AT(16,1):"SAME KEY=0 NEW KEY=1 NO KEY PRESS=-1"
70 CALL JOYST(1,X,Y)
75 CALL COLOR(10,P1,6,11,P1,6,12,P1,6,13,P1,6)
80 !=R-Y/4 :: C=C+X/4
90 DR=DR-Y*4 :: DC=DC+X*4
100 !R=INT(R*8-7):: DC=INT(C*8-7)
110 !ALL POSITION(#1,DR,DC)
120 CALL LOCATE(#1,DR,DC)
130 CALL KEY(1,K,S)
145 DISPLAY AT(18,5):"KEY= ";K;"STATUS= ";S :: DISPLAY AT(20,1):"X= ";X;"Y= ";Y :: DISPLAY AT(21,1):"R= ";R;"C= ";C :: DISPLAY AT(22,1):"DR=";DR;"DC=";DC
180 CALL HCHAR(1,16,104)!UP
190 CALL HCHAR(24,16,112)!DOWN
195 CALL HCHAR(12,3,120)!LEFT
198 CALL HCHAR(12,30,128)!RIGHT
200 IF Y=4 THEN CALL COLOR(10,P2,6)
210 IF X=4 THEN CALL COLOR(13,P2,6)
220 IF Y=-4 THEN CALL COLOR(11,P2,6)
230 IF X=-4 THEN CALL COLOR(12,P2,6)
250 GOTO 70

 

Do not use single line code. Use multiple line code it runs faster then line searchs. RXB Author.

 

You could also do:

200 IF Y=4 THEN CALL COLOR(10,P2,6) ELSE IF X=4 THEN CALL COLOR(13,P2,6) ELSE IF Y=-4 THEN CALL COLOR(11,P2,6) ELSE IF X=-4 THEN CALL COLOR(12,P2,6)

 

Also you could:

40 A$,B$,C$,D$,E$=RPT$("F",16) and dump line 42

Edited by RXB
Link to comment
Share on other sites

I think WORKS and ALSO WORKS somehow got pasted twice and I didn't realize it.

 

In THISWORKS I was trying to find out if a Sprite set up in the Main Program could cause coincidence with another sprite if it was called from a subprogram. I had a lot of trouble understanding Subprograms and getting them to work.

 

In my text, it was not the copyright symbol, but the parameter ©. C=Coincidence. It think it was a text-edit to browser translation error.

 

In DOESNOTWORK, I wanted to see if CALL COINC would work when called from within a Subprogram. I tried it passing C for coincidence and without passing C and nothing happened. This seemed to support my thought that CALL COINC might not work within a subprogram until you told me that I just need to loop back to Call Coinc. This kind of strange or unusual nonunderstanding of simple or BASIC concepts, is what I deal with all the time. Since I'm more of a beginner self-taught type, I probably see this stuff in a different and even scattered way, and sometimes I have a hard time understanding this stuff. But I find I pick up more the more time I spend on it.

 

So I should have kept looping to CALL OBJECT?

Link to comment
Share on other sites

Even when someone understands every command in XB, there are different ways to do things, and one could discuss what is most efficient, smallest, most readable, beginner friendly or whatever - all pull in different directions and people have different feelings about them - even in a small community as ours here. What I'm saying is, there are really no "truth" about programming XB. I would say this is true about other big brothers like Java, C# and ActionScript too, but again it all depends (what are you looking at, does someone say that you have to do this and that because of company rules, common decency, bla bla etc.).

 

Starting out with XB, I would personally recommend, that you isolate your problems and try to have smaller programs focused on what you want something to do. That would in this case mean no use of subroutines if you're trying to deal with coincidence - let not one thing confuse another. Also remove lines commented out with ! - it even confuses me to see them, because I must admit to sometimes reading a line as if part of the example/code. Keep it simple and cut down to the problem, that makes it far easier to help.

 

Later, when you have all these small parts in working conditions, you start pulling them together to form bigger programs - and bigger problems ...

 

:)

Edited by sometimes99er
  • Like 1
Link to comment
Share on other sites

Ok I figured out what you were trying to do. Read page 180 XB manual SUB you forgot the [parameter list]

I looked over you program very closely and assumed what you were wanting by the way you put things where they were.

Then I fixed it to do that. Now the CALL LOCATE© works, but remember Subprograms calls do not share same memory for variables.

So it just passes value not the named value. See page 181 of XB manual for what I am saying.

 

40 !COINCTEST(DOESNOTWORK)
50 CALL CLEAR :: CALL SCREEN(3)
60 CALL COLOR(9,2,2,10,11,11)
70 CALL SPRITE(#1,96,2,89,1,0,10,#2,104,11,89,249,0,-10) :: GOTO 95
80 CALL OBJECT(C)
90 IF C THEN CALL SOUND(500,440,0) :: CALL SPRITE(#2,104,11,89,249,0,-10)ELSE 80
95 DISPLAY AT(24,1):"C= ";C
110 GOTO 80
120 SUB OBJECT(C)
140 CALL COINC(#1,#2,10,C)
150 SUBEND

Link to comment
Share on other sites

Thanks. This code with a man and a meteor didn't work. I will read pages 180 and 181 again. I tried to pass the variable C.

 

635 DR=130 :: DC=1

640 CALL SPRITE(#1,96,16,DR,DC) :: CALL MAGNIFY(4)

650 CALL METEOR©

 

 

662 CALL COINC(#1,#2,10,C) :: CALL KEY(1,K,S) :: IF K=18 THEN CALL JUMP(DR,DC,FACE)

663 IF X<>0 THEN CALL PATTERN(#1,ANIM+X*2+108) :: FACE=SGN(X+4) :: GOTO 660

 

 

920 SUB METEOR©

925 CALL COLOR(6,16,2)

930 M$="00000000000F10204980A0829041221C0000000000C020A02020204080000000"

935 CALL CHAR(72,M$) :: DR=169 :: DC=1

940 CALL SPRITE(#2,72,16,DR,DC,20,-20)

950 CALL COINC(#1,#2,10,C) :: IF C THEN CALL DELSPRITE(#1)

955 CALL POSITION(#2,DR,DC) :: IF DR=130 THEN CALL DELSPRITE(#2)

960 !OR I=1 TO 100 :: NEXT I

970 SUBEND

Link to comment
Share on other sites

The code posted executes without errors. Is the example complete or are there lines missing ?

 

SUB

 

Line 650 passes C to the sub, but C only has the initial value of 0.

 

In the sub, line 950 assigns C a value and act upon it.

 

Line 970 returns C to the caller.

 

The caller, line 650, does not use the recieved C for anything, and the next line, 662, overwrites the C value.

 

All in all, you're passing C, but neither the caller nor the receiver make use of it.

Edited by sometimes99er
Link to comment
Share on other sites

... passes over the man without a coincidence like you said in the above.

Actually I only talked about passing the parameter in your example. Without passing the variable, coincidence checking is still possible. Wherever your loop is, I think that's where we gotta have a COINC, but if it's like you go to a routine and stay there while a special enemy is on screen, then I guess a COINC (making it two) there would be in place. I then start to get the idea of passing the C. If this variable is called CO instead throughout, we'll avoid the forum conversion to the copyright sign, which of course do not translate to a SUB parameter when I copy and paste into Classic99.

 

:)

Edited by sometimes99er
Link to comment
Share on other sites

After much confusion, I got the coincidences to register a sound both in the main and in the sub with meteor. Put the coinc check in the jump loop. 2 different coinc sounds to help make it easier to see which coincidence check is working, called from main or called from sub. plus you see it hit the meteor when jumping and make a sound, when testing.

 

 

635 DR=130 :: DC=1

640 CALL SPRITE(#1,96,16,DR,DC) :: CALL MAGNIFY(4)

650 CALL METEOR

660 ANIM=ABS(ANIM-4) :: CALL JOYST(1,X,Y) :: DR=DR-Y*0 :: DC=DC+X*4 :: CALL LOCATE(#1,(DR AND 255)+1,(DC AND 255)+1)

661 CALL COINC(ALL,HIT) :: IF HIT THEN 662 ELSE 663

662 CALL SOUND(300,-1,10) :: CALL DELSPRITE(#1)

663 CALL KEY(1,K,S) :: IF K=18 THEN CALL JUMP(DR,DC,FACE,HIT)

664 IF X<>0 THEN CALL PATTERN(#1,ANIM+X*2+108) :: FACE=SGN(X+4) :: GOTO 660

665 CALL PATTERN(#1,FACE*16+96) :: GOTO 660

670 IF DC<2 THEN DC=240 ELSE IF DC>240 THEN DC=2

 

 

810 SUB JUMP(DR,DC,FACE,HIT)

840 SDR=DR :: A=1

845 IF DC<2 THEN DC=240 ELSE IF DC>240 THEN DC=2

850 CALL KEY(1,K,S) :: IF K=18 THEN DR=DR-4 :: DC=DC+(A*PI/45)*5 :: IF DC>240 THEN DC=1

855 CALL COINC(ALL,CO) :: IF CO THEN CALL SOUND(150,-2,4)

860 !DISPLAY AT(23,1):A;" ";SIN(A*PI/45)

870 IF DR<8 THEN 890

880 CALL LOCATE(#1,DR,DC) :: IF S<0 THEN A=A+1 :: GOTO 850

890 IF DR<SDR THEN DR=DR+4 :: DC=DC+1 :: CALL LOCATE(#1,DR,DC) :: IF DC>240 THEN DC=1

900 IF DR<SDR THEN 890

910 SUBEND

 

 

 

920 SUB METEOR

925 CALL COLOR(6,16,2)

930 M$="00000000000F10204980A0829041221C0000000000C020A02020204080000000"

935 CALL CHAR(72,M$) :: DR=169 :: DC=1

940 CALL SPRITE(#2,72,16,DR,DC,20,-20)

 

960 !OR I=1 TO 100 :: NEXT I

970 SUBEND

Link to comment
Share on other sites

After much confusion, I got the coincidences to register a sound both in the main and in the sub with meteor. Put the coinc check in the jump loop. 2 different coinc sounds to help make it easier to see which coincidence check is working, called from main or called from sub. plus you see it hit the meteor when jumping and make a sound, when testing.

 

 

635 DR=130 :: DC=1

640 CALL SPRITE(#1,96,16,DR,DC) :: CALL MAGNIFY(4)

650 CALL METEOR

660 ANIM=ABS(ANIM-4) :: CALL JOYST(1,X,Y) :: DR=DR-Y*0 :: DC=DC+X*4 :: CALL LOCATE(#1,(DR AND 255)+1,(DC AND 255)+1)

661 CALL COINC(ALL,HIT) :: IF HIT THEN 662 ELSE 663

662 CALL SOUND(300,-1,10) :: CALL DELSPRITE(#1)

663 CALL KEY(1,K,S) :: IF K=18 THEN CALL JUMP(DR,DC,FACE,HIT)

664 IF X<>0 THEN CALL PATTERN(#1,ANIM+X*2+108) :: FACE=SGN(X+4) :: GOTO 660

665 CALL PATTERN(#1,FACE*16+96) :: GOTO 660

670 IF DC<2 THEN DC=240 ELSE IF DC>240 THEN DC=2

 

 

810 SUB JUMP(DR,DC,FACE,HIT)

840 SDR=DR :: A=1

845 IF DC<2 THEN DC=240 ELSE IF DC>240 THEN DC=2

850 CALL KEY(1,K,S) :: IF K=18 THEN DR=DR-4 :: DC=DC+(A*PI/45)*5 :: IF DC>240 THEN DC=1

855 CALL COINC(ALL,CO) :: IF CO THEN CALL SOUND(150,-2,4)

860 !DISPLAY AT(23,1):A;" ";SIN(A*PI/45)

870 IF DR<8 THEN 890

880 CALL LOCATE(#1,DR,DC) :: IF S<0 THEN A=A+1 :: GOTO 850

890 IF DR<SDR THEN DR=DR+4 :: DC=DC+1 :: CALL LOCATE(#1,DR,DC) :: IF DC>240 THEN DC=1

900 IF DR<SDR THEN 890

910 SUBEND

 

 

 

920 SUB METEOR

925 CALL COLOR(6,16,2)

930 M$="00000000000F10204980A0829041221C0000000000C020A02020204080000000"

935 CALL CHAR(72,M$) :: DR=169 :: DC=1

940 CALL SPRITE(#2,72,16,DR,DC,20,-20)

 

960 !OR I=1 TO 100 :: NEXT I

970 SUBEND

Link to comment
Share on other sites

Thanks, RXB. I changed the lines around a little.

 

 

635 DR=130 :: DC=1
640 CALL SPRITE(#1,96,16,DR,DC) :: CALL MAGNIFY(4)
641 !METEOR SPRITE
642 CALL CHAR(136,M$) :: MDR=1 :: MDC=249
643 CALL SPRITE(#2,136,16,MDR,MDC,1,-1)!SPEED,20,-20
644 !MOVEMETEORBELOWSCREEN?DR=193
645 !MAIN LOOP
650 CALL METEOR(C)
660 ANIM=ABS(ANIM-4) :: CALL JOYST(1,X,Y) :: DC=DC+X*4 :: CALL LOCATE(#1,(DR AND 255)+1,(DC AND 255)+1)
661 CALL COINC(#1,#2,10,HIT) :: IF HIT THEN CALL SOUND(300,-1,10) :: CALL DELSPRITE(#1)::GOTO 780
663 CALL KEY(1,K,S) :: IF K=18 THEN CALL JUMP(DR,DC,FACE)
664 IF X<>0 THEN CALL PATTERN(#1,ANIM+X*2+108) :: FACE=SGN(X+4) :: GOTO 650
665 CALL PATTERN(#1,FACE*16+96) :: GOTO 650
770 !ENDOFMAINLOOP
780 CALL CHARPAT :: CALL SCREEN(5)
790 DISPLAY AT(12,16):"PLAY MOON MAN AGAIN? PRESS Y OR N"
800 ACCEPT AT(14,16)BEEP VALIDATE("YN"):Z$::IF Z$="Y" THEN 160
803 IF Z$="N" THEN END
805 !///SUBPROGRAMS///
810 SUB JUMP(DR,DC,FACE)
840 SDR=DR :: A=1
850 CALL KEY(1,K,S) :: IF K=18 THEN DR=DR-4 :: DC=DC+(A*PI/45)*5 :: IF DC>240 THEN DC=1
855 CALL COINC(#1,#2,10,CO) :: IF CO THEN CALL SOUND(150,-2,4) :: CALL DELSPRITE(#1):: SUBEXIT! GOTO 780?
860 !DISPLAY AT(23,1):A;" ";SIN(A*PI/45)
870 IF DR<8 THEN 890
880 CALL LOCATE(#1,DR,DC) :: IF S<0 THEN A=A+1 :: GOTO 850
890 IF DR<SDR THEN DR=DR+4 :: DC=DC+1 :: CALL LOCATE(#1,DR,DC) :: IF DC>240 THEN DC=1
900 IF DR<SDR THEN 890
910 SUBEND
920 SUB METEOR(C)
925 CALL COLOR(6,16,2)
950 CALL COINC(#1,#2,10,C) :: :: IF HIT THEN CALL SOUND(300,-2,10) :: IF C THEN CALL DELSPRITE(#1)
955 CALL POSITION(#2,DR,DC) :: IF DR>130 THEN CALL DELSPRITE(#2)
960 !HOWLONGSHOULDMETEORLAST?
970 SUBEND

Link to comment
Share on other sites

* SYNTAX ERROR IN 950

 

If I correct the double double colon, there are several problems with movement and jumping, and eventually it lead to

 

* BAD VALUE IN 880

IN JUMP

CALLED FROM 663

 

880 CALL LOCATE(#1,DR,DC) :: IF S<0 THEN A=A+1 :: GOTO 850

 

PRINT DR,DC

126 -102.2920367

 

Obviously DC is out of range (1-256).

Edited by sometimes99er
Link to comment
Share on other sites

The movement seems a little better than before. The problem I notice is when you run to the left, and are near the right edge or another spot more in the left of center screen,... when you press the button, the man pops into a much further spot to the left suddenly before jumping. The jump still only goes to the right, not sure how to make it jump left when facing left, and keep jumping right like it currently does when facing right. Now, that was a run-on sentence.

 

635 DR=130 :: DC=1
640 CALL SPRITE(#1,96,16,DR,DC) :: CALL MAGNIFY(4)
641 !METEOR SPRITE
642 CALL CHAR(136,M$) :: MDR=1 :: MDC=249
643 CALL SPRITE(#2,136,16,MDR,MDC,1,-1)!SPEED,20,-20
644 !MOVEMETEORBELOWSCREEN?DR=193
645 !MAIN LOOP
650 CALL METEOR
660 ANIM=ABS(ANIM-4) :: CALL JOYST(1,X,Y) :: DC=DC+X*4 :: CALL LOCATE(#1,(DR AND 255)+1,(DC AND 255)+1)
661 CALL COINC(#1,#2,10,HIT) :: IF HIT THEN CALL SOUND(300,-1,10) :: CALL DELSPRITE(#1)
663 CALL KEY(1,K,S) :: IF K=18 THEN CALL JUMP(DR,DC,FACE)
664 IF X<>0 THEN CALL PATTERN(#1,ANIM+X*2+108) :: FACE=SGN(X+4) :: GOTO 650
665 CALL PATTERN(#1,FACE*16+96) :: GOTO 650
770 !ENDOFMAINLOOP
780 CALL CHARPAT :: CALL SCREEN(5)
790 DISPLAY AT(12,16):"PLAY MOON MAN AGAIN? PRESS Y OR N"
800 ACCEPT AT(14,16)BEEPVALIDATE("YN"):Z$ :: IF Z$="Y" THEN 160
803 IF Z$="N" THEN END
805 !///SUBPROGRAMS///
810 SUB JUMP(DR,DC,FACE)
840 SDR=DR :: A=1
844 DISPLAY AT(16,12):"DC= ";DC
850 CALL KEY(1,K,S) :: IF K=18 THEN DR=DR-4 :: DC=ABS(DC)+ABS(INT(A*PI/45)*5) :: IF DC>240 THEN DC=17
855 CALL COINC(#1,#2,10,CO) :: IF CO THEN CALL SOUND(150,-2,4) :: CALL DELSPRITE(#1)
860 !DISPLAY AT(23,1):A;" ";SIN(A*PI/45)
870 IF DR<8 THEN 890
875 IF DR=126 THEN M=DC
880 CALL LOCATE(#1,DR,DC) :: IF S<0 THEN A=A+1 :: GOTO 850
890 IF DR<SDR THEN DR=DR+4 :: DC=DC+1 :: CALL LOCATE(#1,DR,DC) :: IF DC>240 THEN DC=17
900 IF DR<SDR THEN 890
910 SUBEND
920 SUB METEOR
925 CALL COLOR(6,16,2)
950 CALL COINC(#1,#2,10,CO) :: IF CO THEN CALL SOUND(300,-2,10) :: CALL DELSPRITE(#1)
955 CALL POSITION(#2,DR,DC) :: IF DR>130 THEN CALL DELSPRITE(#2)
960 !HOWLONGSHOULDMETEORLAST?
970 SUBEND

 

The collision detection between the Meteor and the Man seems to be such that it works when the man is standing or jumping upwards. When coming down from a jump, he passes right over the meteor without a beep or a flash.

Edited by orion1052003
Link to comment
Share on other sites

Notes.

 

642 - M$ is empty/not defined.

643 - Sprite has no pattern and is therefore invisible.

If you test the code you post, I guess you'll catch something like this.

I setup my own M$.

 

Loop start

SUB METEOR

925 - Must be there for a reason.

If player and meteor collide then remove player.

If meteor is going off screen then remove meteor.

ENDSUB METEOR

661 is then trying to do something which already happens in the SUB METEOR.

664+665 always loops to 650

780-803 is never run.

 

SUB JUMP

Face is passed but not used.

Looks like the jump is putting the loop out of commission. Nothing wrong with that. One could design things, so COINC is only once in the loop. Pseudo code might help (see my comments in the other thread).

875 - Must be there for a reason, M is local to the SUB, and not used anywhere.

890-900 is doing some looping without COINC.

 

:)

Edited by sometimes99er
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...