Si lo recuerdas, cuando dimos a los alienígenas la capacidad de disparar misiles, una de las comprobaciones que hace el código es ver si el alienígena está situado en un rango de 8 píxeles a cada lado del jugador. Esto me parece algo restrictivo, así que añadamos una variable nueva al evento Spawner (TYPE 7) que nos permita definir la distancia a cada lado del jugador a la que debe estar un alienígena para tener la posibilidad de disparar su misil.
Añadiremos la variable I a la lista de valores que vamos a leer
IF SETTINGA = 0 ; first time we run this LET JUMPSPEED = 0 ; reset the enemies spawned counter LET SETTINGB = 0 ; reset the timer RESTORE ; start from the beginning of the data table REPEAT L ; get the data for this level READ AIRBORNE ; get the spawner movement READ X ; get starting x position READ Y ; get starting y position READ J ; get the enemy sprite type READ K ; get the enemy image READ E ; how many enemies in this level? READ G ; delay between releasing each enemy READ P ; points for a kill READ C ; colour READ W ; weapon READ H ; fire weapon probability READ Q ; min height to release weapons READ I ; x distance for alien weapon triggering ENDREPEAT LET D = E ; how many kills to get bonus? LET F = E ; enemies remaining ADD 1 TO SETTINGA ; prevent this running again ENDIF
Luego asegúrate de añadir un valor nuevo al final de cada fila de tu tabla de datos:
DATA 0 132 8 5 2 8 8 5 67 1 10 100 8 DATA 0 100 8 5 2 10 8 10 68 1 10 100 32
Cambiando estos valores puedes hacer que los alienígenas disparen cuando están más lejos del jugador en horizontal (o más cerca)
Después, hay algo de código en el evento Alien (Type 5) que es repetitivo; podríamos ahorrar unos cuantos bytes optimizándolo, en concreto la comprobación de si el jugador está fuera de los límites:
Podríamos optimizarlo usando la variable DIRECTION, poniéndola a 254 cada vez que un enemigo sale de la pantalla:
Así que cambiaremos esto:
; BOUNDARY CHECKING ; =================== IF X <= LEFTEDGE ; if alien reaches the left edge REMOVE ; remove it SUBTRACT 1 FROM S ; decrement the sprite counter SUBTRACT 1 FROM F ; decrement the number of aliens still in ENDIF IF X >= RIGHTEDGE ; if alien reaches the right edge REMOVE ; remove it SUBTRACT 1 FROM S ; decrement the sprite counter SUBTRACT 1 FROM F ; decrement the number of aliens still in ENDIF IF Y >= BOTTOMEDGE ; if alien reaches the right edge REMOVE ; remove it SUBTRACT 1 FROM S ; decrement the sprite counter SUBTRACT 1 FROM F ; decrement the number of aliens still in ENDIF
por esto:
; BOUNDARY CHECKING ; =================== IF X <= LEFTEDGE ; if alien reaches the left edge LET DIRECTION = 254 ; enemy is out of bounds ENDIF IF X >= RIGHTEDGE ; if alien reaches the right edge LET DIRECTION = 254 ; enemy is out of bounds ENDIF IF Y >= BOTTOMEDGE ; if alien reaches the right edge LET DIRECTION = 254 ; enemy is out of bounds ENDIF IF DIRECTION =254 ; is enemy out of bounds? REMOVE ; remove it SUBTRACT 1 FROM S ; decrement the sprite counter SUBTRACT 1 FROM F ; decrement the alien counter ENDIF
Eso debería ahorrarnos unos cuantos bytes y, además, facilita las cosas si queremos quitar un sprite (pero sin matarlo) en otras partes del juego.
Y eso, creo yo, lo remata todo por ahora y te da una base ligera (actualmente usa unos 14.500 bytes) para construir shoot 'em ups en MPAGD.
Me voy a ordenar los comentarios del código y luego publicaré todo el proyecto en la web de itch, ¡para que puedas empezar enseguida!
