 rem Generated 14/03/2016 17:44:53 by Visual bB Version 1.0.0.554
 rem *********************************** 
 rem *<M4K video aula>                              *
 rem *<add som no game>                         *
 rem *<CanalMundo4k>                              *
 rem *<canalmundo4k@gmail.com>        *
 rem *<license free >                                   *
 rem ***********************************

 rem configuracao geral ( tamanho da rom sistemar de cor  da tv ) 

 set tv ntsc
 set romsize 4k
 set smartbranching on

 rem titulo 

title 

 playfield:
 ................................
 ................................
 ................................
 ..X....X.........XX....X...X....
 .XXX..XXX.......XXX....X..XX....
 XX..XX..XX.....XX.X....X.XX.....
 XX......XX....XX..X....XXX......
 XX......XX....XXXXXXX..XXX......
 XXX....XXX.XX....XXX...X.XX.....
 .XX....XX..XX....XX....X..XX....
 ..X....X..........X....X...X....
end

 rem cor do titulo e fundo da tela 

 COLUBK = 216
 COLUPF = $90
 drawscreen

 rem quando finalizar o game esconder os personagens fora da tela 

 player0x = 1 : player0y = 1
 player1x = 1 : player1y = 1

 rem se o acionado o botao de tiro pular o titulo 

 if joy0fire || joy1fire then goto skiptitle

 rem se nao acionado o botao de tiro permanecer no titulo 

 goto title

 rem inicio do loop principal 

skiptitle

 rem tela de jogo inicial (apos o titulo ) 

 playfield:
 ................................
 ................................
 ................................
 ................................
 ................................
 ................................
 ................................
 ................................
 ................................
 ................................
 XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
end

startposx
 player1x = rand
 if player1x > 150 then goto startposx
startposy
 player1y = rand
 if player1y > 100 then goto startposy

 rem posicao dos personagens na tela 

 player0x = 75 : player0y = 80
 player1x = 80 : player1y = 1 

 rem configura?o do missil saindo do heroi 

 missile0height = 4  : missile0y = 255

 rem cor do fundo da tela 

 COLUBK = 216

 rem configuracao das contagens de pontos e cor do score 

 score = 00000 :  scorecolor = $0E
 m = 0

 rem loop principal 

main

 rem cor dos personagens e da base do canhao (heroi)

 COLUP1 = $00
 COLUP0 = $0E
 COLUPF = $90
 f=f+1
 g=g+1

 rem heroi 


  if f=10 then player0:
 %01111100
 %00111000
 %00010000
 %00010000
 %00000000
 %00000000
 %00000000
 %00000000
end

 if f=20 then player0:
 %01011100
 %00111000
 %00010000
 %00010000
 %00000000
 %00000000
 %00000000
 %00000000
end

 if f=30 then player0:
 %01101100
 %00111000
 %00010000
 %00010000
 %00000000
 %00000000
 %00000000
 %00000000
end

 if f=40 then player0:
 %01110100
 %00111000
 %00010000
 %00010000
 %00000000
 %00000000
 %00000000
 %00000000
end



 rem vilao 

  
 if f=10 then player1:
 %10000001
 %10011001
 %10111101
 %11100111
 %10111101
 %10011001
 %10000001
 %00000000
end

 if f=20 then player1:
 %10000001
 %10011001
 %10100101
 %11111111
 %10111101
 %10011001
 %10000001
 %00000000
end

 if f=30 then player1:
 %10000001
 %10011001
 %10111101
 %11111111
 %10100101
 %10011001
 %10000001
 %00000000
end

 if f=40 then player1:
 %10000001
 %10011001
 %10111101
 %11111111
 %10111101
 %10011001
 %10000001
 %00000000
end

 if f=40 then f=0
 if g=40 then g=0

 rem velocidade que o vilao ataca o heroi 

 a = a + 1 : if a < 1 then goto checkfire
 a = 0

 rem forma que o vilao persegue o heroi 

 if player1y < player0y then player1y = player1y + 1
 if player1y > player0y then player1y = player1y - 1
 if player1x < player0x then player1x = player1x + 1
 if player1x > player0x then player1x = player1x - 1
 player1x = player1x : player1y = player1y

 rem verificando se o tiro saiu do heroi 

checkfire
 if missile0y>240 then goto skip
 missile0y = missile0y - 2 : goto draw

skip
 rem tiro emitido inicia o jogo e sons de fundo e disparo  
 if joy0fire then missile0y=player0y-2:missile0x=player0x+4: goto firesound

draw
 drawscreen

 rem se o tiro acertar o vilao somar pontos ordem crescente surgir outro vilao na tela e som de vilao abatido 

 if collision(missile0,player1) then score=score+1:player1x=rand/2:player1y=0:missile0y=255 : goto pointsound

 rem se o vilao encostar no heroi som de explosao retorna para o titulo 

 if collision(player0,player1) goto deadsound : then title 


 rem configuracao de limite de tela 

 if m = 1 && collision(player0,playfield) then player0y = player0y + 1 : goto skipmove
 if m = 2 && collision(player0,playfield) then player0x = player0x + 1 : goto skipmove
 if m = 3 && collision(player0,playfield) then player0y = player0y - 1 : goto skipmove
 if m = 4 && collision(player0,playfield) then player0x = player0x - 1: goto skipmove

 rem configuracao de movimentos do heroi 

  rem if joy0up && !collision(player0,playfield) then player0y = player0y - 1 : m = 1 : goto skipmove
 if joy0left  && !collision(player0,playfield) then player0x = player0x - 1 :  REFP0 = 8 : m = 2 : goto skipmove
  rem if joy0down  && !collision(player0,playfield) then player0y = player0y + 1  : m = 3 : goto skipmove
 if joy0right  && !collision(player0,playfield) then player0x = player0x + 1 :  m = 4 : REFP0 = 0 : goto skipmove

skipmove
 if player0x < player1x then REFP1 = 8
 if player0x > player1x then REFP1 = 0
 goto main


  rem fim do loop principal 


  rem configuracao de sons do jogo 

  rem som dos pontos ( quando o vilao morre)

pointsound
 AUDV0 = 15
 AUDC0 =8
 AUDF0 = 3 

  p = p + 1
 drawscreen
 rem tempo que o som toca 
 if p < 8 then pointsound
 p = 0
 AUDV0 = 0: AUDC0 = 0: AUDF0 = 0
 goto main

  rem som do tiro 

firesound
 AUDV0 = 15
 AUDC0 =8
 AUDF0 = 18

  rem som de fundo (fica mis facil configurar aqui no tiro) 

 AUDV1 = 10
 AUDC1 =  2
 AUDF1 = 31

    p = p + 1
 drawscreen
 rem tempo que o som toca
 if p < 5 then firesound
 p = 0
 AUDV0 = 0: AUDC0 = 0: AUDF0 = 0
 goto main

 rem Som do heroi morredo 
deadsound
 AUDV1 = 15
 AUDC1 = 8
 AUDF1 = 31
 p = p + 1
 drawscreen
 rem tempo que o som toca 
 if p < 30 then deadsound
 p = 0
 AUDV1 = 0: AUDC1 = 0: AUDF1 = 0
 if a = 0 then goto title 

 goto main

  rem fim do programa