IGNORED

# PULSAR SUBROUTINE

## Recommended Posts

Is there some way to make this better? How can you control the length of time this "enemy" stays on screen?

1100 SUB PULSAR

1110 CALL CLEAR!TEST LINE

1120 CALL SCREEN(2)

1130 CALL CHAR(72,"804020100F080B0A0A0B080F1020408001020408F010D05050D010F008040201")

1140 P=7 :: CALL MAGNIFY(3)

1150 CALL SPRITE(#4,72,P,18,1,0,20)

1153 P=6 :: CALL COLOR(#4,P)

1160 FOR J=1 TO 8 :: FOR I=1 TO 7 :: P=7 :: CALL COLOR(#4,P) :: CALL SOUND(100,-1,I,2000,0) :: P=6 :: CALL COLOR(#4,P) :: NEXT I :: NEXT J

1165 FOR I=1 TO 100

1170 P=6 :: CALL COLOR(#4,P) :: P=7

1175 P=7 :: CALL COLOR(#4,P) :: P=6

1180 !ALL COINC(#1,#4,10,C)

1185 NEXT I

1190 GOTO 1190! TEST LINE

1200 SUBEND

Edited by orion1052003
##### Share on other sites

Generate a random number, then count it down every time through your game loop. When it reaches zero, remove the enemy.

##### Share on other sites

If you're generally experimenting with 2 colors (not knowing their final values), here they are 6 and 7, then perhaps setting the values in the beginning of your program, like C1=6 and C2=7, could be used. Setting the value of P every time and right before you use it may only slow down execution.

For example

1140 P=7 :: CALL MAGNIFY(3)

1150 CALL SPRITE(#4,72,P,18,1,0,20)

would become

1140 CALL MAGNIFY(3)

1150 CALL SPRITE(#4,72,7,18,1,0,20)

etc.

In lines 1170 and 1175 you even set the value of P after the COLOR, but it's never used (overwritten).

1170 P=6 :: CALL COLOR(#4,P) :: P=7

1175 P=7 :: CALL COLOR(#4,P) :: P=6

##### Share on other sites

1150 CALL SPRITE(#4,72,7,18,1,0,20) You don't have to keep 7 as P to allow the sprite to change colors? 1150 CALL SPRITE(#4,72,P,18,1,0,20)

It seemed like the other day, when I had 6 or 7 in the CALL SPRITE statement it would only stay one color and when I plugged in a variable it changed colors back and forth, PULSATING, when I did 1170 P=6 :: CALL COLOR(#4,P) and 1175 P=7 :: CALL COLOR(#4,P).

1170 should be changed to this?

10 P1=6 :: P2=7

1170 CALL COLOR(#4,P1)

1175 CALL COLOR(#4,P2)

##### Share on other sites

This is a pretty cool effect. The noise is annoying, but I like the sonar.

##### Share on other sites

I changed it to the below, but it no longer works. The sound is remmed out, but there is an error and it stops at 1150.

1100 SUB PULSAR

1130 CALL CHAR(72,"804020100F080B0A0A0B080F1020408001020408F010D05050D010F008040201")

1140 !ALL MAGNIFY(4)

1150 CALL SPRITE(#4,72,6,18,1,0,20)

1160 !OR J=1 TO 8 :: FOR I=1 TO 7 :: P=7 :: CALL COLOR(#4,P):: CALL SOUND(100,-1,I,2000,0):: P=6 :: CALL COLOR(#4,P):: NEXT I :: NEXT J

1165 FOR I=1 TO 100

1170 CALL COLOR(#4,P1) :: CALL COLOR(#4,P2)

1180 !ALL COINC(#1,#4,10,C)

1185 NEXT I

1190 GOTO 1190

1200 SUBEND

##### Share on other sites

1150 CALL SPRITE(#4,72,7,18,1,0,20) You don't have to keep 7 as P to allow the sprite to change colors? 1150 CALL SPRITE(#4,72,P,18,1,0,20)

It seemed like the other day, when I had 6 or 7 in the CALL SPRITE statement it would only stay one color and when I plugged in a variable it changed colors back and forth, PULSATING, when I did 1170 P=6 :: CALL COLOR(#4,P) and 1175 P=7 :: CALL COLOR(#4,P).

1170 should be changed to this?

10 P1=6 :: P2=7

1170 CALL COLOR(#4,P1)

1175 CALL COLOR(#4,P2)

Yes.

##### Share on other sites

I changed it to the below, but it no longer works. The sound is remmed out, but there is an error and it stops at 1150.

1100 SUB PULSAR

1130 CALL CHAR(72,"804020100F080B0A0A0B080F1020408001020408F010D05050D010F008040201")

1140 !ALL MAGNIFY(4)

1150 CALL SPRITE(#4,72,6,18,1,0,20)

1160 !OR J=1 TO 8 :: FOR I=1 TO 7 :: P=7 :: CALL COLOR(#4,P):: CALL SOUND(100,-1,I,2000,0):: P=6 :: CALL COLOR(#4,P):: NEXT I :: NEXT J

1165 FOR I=1 TO 100

1170 CALL COLOR(#4,P1) :: CALL COLOR(#4,P2)

1180 !ALL COINC(#1,#4,10,C)

1185 NEXT I

1190 GOTO 1190

1200 SUBEND

As it is the value of P1 and P2 is zero. Think you forgot to set them with: 10 P1=6 :: P2=7

This seems to do it ...

```10 P1=6 :: P2=7
20 CALL SCREEN(2)
1130 CALL CHAR(72,"804020100F080B0A0A0B080F1020408001020408F010D05050D010F008040201")
1140 CALL MAGNIFY(4)
1150 CALL SPRITE(#4,72,6,18,1,0,20)
1170 CALL COLOR(#4,P1) :: CALL COLOR(#4,P2)
1190 GOTO 1170```

## 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.

×   Pasted as rich text.   Paste as plain text instead

Only 75 emoji are allowed.