Se te lembras, quando demos aos alienígenas a capacidade de disparar mísseis, um dos testes que o código faz é ver se o alienígena está posicionado num intervalo de 8 píxeis para cada lado do jogador. Isto parece-me um pouco restritivo, por isso vamos acrescentar uma nova variável ao evento Spawner (TYPE 7) que nos permita definir a distância de cada lado do jogador a que um alienígena tem de estar para ter a hipótese de disparar o seu míssil.
Vamos acrescentar a variável I à lista de valores que vamos ler
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
Depois garante que acrescentas um novo valor ao final de cada linha da tua tabela de dados:
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
Alterando estes valores podes fazer com que os alienígenas disparem quando estão mais afastados do jogador na horizontal (ou mais perto)
Depois, há algum código no evento Alien (Type 5) que é repetitivo; podíamos poupar alguns bytes otimizando-o, em concreto o teste para ver se o jogador está fora dos limites:
Podíamos otimizá-lo usando a variável DIRECTION, pondo-a a 254 sempre que um inimigo sai do ecrã:
Então vamos mudar isto:
; 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
para isto:
; 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
Isso deve poupar-nos alguns bytes e, além disso, facilita as coisas se quisermos remover um sprite (mas sem o matar) noutras partes do jogo.
E isso, penso eu, conclui tudo por agora e dá-te uma base leve (atualmente usa cerca de 14.500 bytes) para construir shoot 'em ups no MPAGD.
Vou arrumar os comentários do código e depois publico o projeto completo no site do itch, para que possas começar rapidamente!
