Ir ao conteúdo
  • Cadastre-se

xxnikobellicxx

Membro Júnior
  • Posts

    8
  • Cadastrado em

  • Última visita

Reputação

7

1 Seguidor

  1. O que eu estava dizendo é que quando você disse sobre usar um if, em poucas palavras sim, use o if para quando o usuario digitar um valor que você nao deseja, ele armazena no vetor b, e você exclui uma posição do tamanho do A, entendeu?
  2. A sua lógica está próxima do correto, falta pensar um pouco. Primeiramente se você pretende trabalhar com 2 vetores de 100, é necessário que o seu código receba este tanto de posição para os 2 vetores int tamA = 0; int tamB = 0; printf("Entre com o tamanho do vetor A \n"); scanf("%d", &tamA); printf("Entre com o tamanho do vetor B \n"); scanf("%d", &tamB); Entenda que o método de inserção é uma operação com uma taxa de custo alta. Mas de qualquer forma, o que você precisa fazer para alcançar o seu objetivo aqui é o seguinte, pergunte ao usuário onde ele deseja acessar por exemplo usando seu código eu fiz: for(i = 0; i<tamA; i++){ printf("Qual pos da array você quer acessar amigo"); scanf("%d", &tamA); printf("voce acessou a posicao %d", i); } /*tag code só me deixa usar HTML lol*/ Acima indicamos ao usuário o lugar que ele pretende acessar para excluir esta posição, mas antes você precisa fazer um if para jogar direto pro vetor B qualquer valor menor que 0 e igual a 0 desta forma printf("Entre com os valores do vetor!\n"); for(i=0;i<tamA;i++){ printf("Vetor [%d]: ", i); scanf("%d", &veta[i]); if(veta[i] == 0 || veta[i] < 0){ vetb[i] = veta[i]; printf("o valor %d foi passado para o vetor B", i); } e por ultimo é o passo mais fácil, para que eu nao resolva o exercicio e faça com que a resposta seja deletada, observe que após você acessar a posição onde foi retirado do vetor a e passado para o vetor b, este ficara em 0, para que isso seja contornado é necessario a exclusão daquele espaço de memória. Para poder excluir, voce precisa acessar a proxima posição da array e colocar na posição anterior desta forma: "veta = veta[i + 1]; utilizando um for para percorrer o vetor. Após isso imediamente fora do loop você tem que obrigatóriamente reduzir o tamanho do vetor e pronto! OBS: só tenha certeza de que quando você percorrer as posições do vetores e manipula-los tenha certeza de que o valor da posição a ser excluida nunca é igual a tam = tam+1 nem que seja menor que 0.
  3. Bom dia amigo, para conseguir resolver este exercício é necessário conhecimento prévio em números amigáveis, números perfeitos, e operações matemáticas básicas em pelo menos 1 qualquer linguagem de programação, para que você consiga desenvolvê-lo com facilidade. A ajuda esta aqui, de forma matemática vamos escrever a equação para que você possa seguir a lógica em programação: 1-) Za*+ = {Za ∈ R│Za > 1}: = (0, 1, 2, 3, 4, ...) = Za. Digamos que Z é o dividendo da sua questão, portanto este deve ser positivo e maior que divisor, o que implica numa lógica if, para ter certeza que o dividendo é maior. 2-) Temos os membros da divisão Za / Zb = Zc portanto Z*+. Ou seja, Dividindo Za que representa o dividendo que é um inteiro positivo maior que 1, por Zb que é menor que Za que é representado por Zb*+ = {Zb C Za│x > 1}: = (0, 1, 2, 3, 4, ...), certificamos que o número é divisivel para só então podermos dividir, portanto é necessário chegar tanto o valor do dividendo como do divisor. 3-)Cria-se 2 vetores de tamanho N e 2 variáveis inteiras, para armazenar a sequência dos quocientes, e depois basta soma-los. 4-)Então executamos a soma de cada posição do vetor A e passamos o valor para uma variável A. 5-)Novamente repetimos o passo 4 desta vez para o vetor B, somamos o valor armazenado dos quocientes da segunda operação e armazenamos em B. Lembrando que as váriaveis da divisão são Za1/Zb1 = Zc1 e Za2/Zb2 = Zc2 para a segunda divisão 6-) Comparamos se A = B, que seria a soma dos quocientes, para que isto seja verdade, é necessário que a soma do vetor A seja armazenado em B, e depois a divisão seja praticada novamente em B e comparamos se B é igual Za1. 7-) Caso seja verdade retorna true, caso nao, retorna false. Caso a explicação esteja muito complexa: Passo 1-) Certificar que divisor e dividendo são int, e que são inteiros e não são primos. Passo 2-) Listar todos os quocientes utilizados na divisão até chegar em 1, e armazenar a soma deles Passo 3-) Pegar a soma deles que você obteve na etapa anterior e repetir o processo do passo 1. Passo 4-) Você obterá um valor maior que o DIVISOR da primeira equação, portanto após repetir o passo 1, você deve comparar se a soma do quociente do resultado é igual ao divisor da primeira operação.
  4. a lógica disso é simples, existe n maneiras de resolver isso, a maneira mais decente é a seguinte: um vetor para armazenamento, um loop for para percorrer o vetor e uma condição que se algum dos valores de dentro do vetor for acima de 1500 ele informa a posição.
  5. Gostaria que alguem excluisse/deletar este tópico, motivo sendo caso ele passe um spider pra detectar plágio, ele vai vir neste tópico e por causa do código ele vai me pegar falando dele xD. Por favor?
  6. Perfeitamente amigo. Aproximei junto ao professor após a ultima aula dele na faculdade e conversei com o mesmo, resumindo a história foi exatamente o que você disse, ao mesmo tempo foi o que o T1000_2015 também disse. Moral da história ou arrisco entregar este, ou faço outro. kkkkkkkkk
  7. Obrigado pela resposta amigo, é que o meu pensamento é o seguinte, eu não tenho certeza se é plágio por ser tutorial, por envolver questões acadêmicas e tudo mais, no caso isso é um vídeo, não necessariamente um código postado. Inclusive tentei falar com o mesmo por whatsapp, porque eu não estava presente no momento que os colegas do meu grupo apresentaram o código, só vou vê-lo novamente no dia da prova agora, ou seja é vai ou racha. Como eu disse, o código possui uma lógica similar mas o produto final em si, é outro. Não tenho propriedade para dizer se o meu código é plágio, ou não.
  8. Bom dia pessoal, vim aqui para buscar mais opinião sobre o assunto conforme o tópico. Atualmente curso engenharia da computação, e especificamente na matéria de computação gráfica e processamento de imagens, o professor passou um trabalho para desenvolver uma aplicação podendo ser desde exercícios em sala de aula, até um jogo. O que ocorre é o seguinte, eu achei um tutorial de como fazer um jogo, no qual eu segui passo a passo para desenvolve-lo. Porém, eu fui muito mais além do que o tutorial, criei tela de menu, mais opções de jogo, passar de fase, créditos, adicionei cheats, e alguma outras coisas. Porém ao mostrar ao professor, este disse que é plágio, fiquei em dúvida, será que este é o caso? Para melhor análise da situação vou disponibilizar ambos os códigos para que haja comparação. /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package nilprowjeqt; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import javax.swing.JPanel; import javax.swing.Timer; import java.util.Random; /** * * @author puelon */ public class Gameplay extends JPanel implements KeyListener, ActionListener { private boolean play = false; private boolean venceu = false; private int score = 0; private int level = 0; private int faliceu = 0; private boolean pause = false; private int totalBricks = 21; private Timer time; private int delay = 10; private int playerX = 310; private int bolaX = 350; private int bolaY = 350; private int bolaXd = -1; private int bolaYd = -2; private MapGenerator map; public int winGame(int lvl) { getLevel(lvl); return getLevel(lvl) + 1; } public int getLevel(int lvl) { lvl = level; return lvl; } public int getBolaX(int posx) { posx = bolaX; return posx; } public int getBolaY(int posy) { posy = bolaY; return posy; } public int setBolaX(int posx) { getBolaX(posx); return getBolaX(posx); } public int setBolaY(int posy) { getBolaY(posy); return getBolaY(posy); } public static int rndRangeX(int start, int finish) { Random rnd = new Random(); int rndInt = rnd.nextInt(finish + 1 - start) + start; return rndInt; } public static int rndRangeY(int start, int finish) { Random rnd = new Random(); int rndInt = rnd.nextInt(finish + 1 - start) + start; return rndInt; } public Gameplay() { map = new MapGenerator(3, 7); addKeyListener(this); setFocusable(true); setFocusTraversalKeysEnabled(false); time = new Timer(delay, this); time.start(); repaint(); } @Override public void paint(Graphics g) { // fundo g.setColor(Color.black); g.fillRect(1, 1, 692, 592); // drawing map map.draw((Graphics2D) g); // borda g.setColor(Color.yellow); g.fillRect(0, 0, 3, 592); g.fillRect(0, 0, 692, 3); g.fillRect(691, 0, 3, 592); //pontuação g.setColor(Color.white); g.setFont(new Font("serif", Font.BOLD, 25)); g.drawString("" + score, 598, 30); // level g.setColor(Color.white); g.setFont(new Font("serif", Font.BOLD, 25)); g.drawString("Level: " + level, 150, 30); //the paddle g.setColor(Color.blue); g.fillRect(playerX, 550, 100, 8); //the ball g.setColor(Color.white); g.fillOval(bolaX, bolaY, 20, 20); if (pause == true) { g.setColor(Color.red); g.setFont(new Font("serif", Font.BOLD, 30)); g.drawString("Jogo Pausado!", 270, 300); } if (totalBricks <= 0) { play = false; venceu = true; bolaYd = 0; bolaXd = 0; g.setColor(Color.red); g.setFont(new Font("serif", Font.BOLD, 30)); g.drawString("voce joga demais amigo, passou de nivel!", 90, 300); g.setFont(new Font("serif", Font.BOLD, 30)); g.drawString("Pressione ENTER para prosseguir.", 190, 350); } if (bolaY > 570 && faliceu != 3) { play = false; bolaYd = 0; bolaXd = 0; g.setColor(Color.red); g.setFont(new Font("serif", Font.BOLD, 30)); g.drawString("FALICEU, SEU PONTO FOI:" + score, 90, 300); g.setFont(new Font("serif", Font.BOLD, 30)); g.drawString("Pressione ENTER para jogar novamente", 150, 350); level = 0; delay = 8; } if (bolaY > 570 && faliceu == 3) { play = false; bolaYd = 0; bolaXd = 0; g.setColor(Color.red); g.setFont(new Font("serif", Font.BOLD, 30)); g.drawString("MOISES NAO CONSEGUE NE, PONTUAÇAO:" + score, 90, 300); g.setFont(new Font("serif", Font.BOLD, 30)); g.drawString("Pressione ENTER para jogar novamente", 150, 350); level = 0; delay = 8; } } @Override public void keyTyped(KeyEvent ke) { } @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_D) { if (playerX >= 600) { playerX = 600; } else { moveRight(); } } if (e.getKeyCode() == KeyEvent.VK_A) { if (playerX < 10) { playerX = 10; } else { moveLeft(); } } if (e.getKeyCode() == KeyEvent.VK_ENTER && venceu == false) { if (!play) { play = true; venceu = false; bolaX = rndRangeX(270, 530); bolaY = rndRangeY(350, 670); bolaXd = -1; bolaYd = -2; playerX = 310; score = 0; totalBricks = 21; faliceu++; map = new MapGenerator(3, 7); repaint(); } } if (e.getKeyCode() == KeyEvent.VK_ENTER && venceu == true) { if (!play) { play = true; venceu = false; bolaX = rndRangeX(270, 530); bolaY = rndRangeY(350, 670); bolaXd = -1; bolaYd = -2; playerX = 310; score = 0; level++; delay--; totalBricks = 21; map = new MapGenerator(3, 7); repaint(); } } if (e.getKeyCode() == KeyEvent.VK_ESCAPE) { if (pause == false) { pause = true; int x = bolaX; int y = bolaY; setBolaY(y); setBolaX(x); } else { pause = false; } } } public void moveRight() { play = true; playerX += 20; } public void moveLeft() { play = true; playerX -= 20; } @Override public void keyReleased(KeyEvent ke) { } @Override public void actionPerformed(ActionEvent e) { time.start(); repaint(); if (play) { if (new Rectangle(bolaX, bolaY, 20, 20).intersects(new Rectangle(playerX, 550, 100, 8))) { bolaYd = -bolaYd; } A: for (int i = 0; i < map.map.length; i++) { for (int j = 0; j < map.map[0].length; j++) { if (map.map[i][j] > 0) { int brickX = j * map.brickWidth + 80; int brickY = i * map.brickHeight + 50; int brickWidth = map.brickWidth; int brickHeight = map.brickHeight; Rectangle rect = new Rectangle(brickX, brickY, brickWidth, brickHeight); Rectangle ballRect = new Rectangle(bolaX, bolaY, 20, 20); Rectangle brickRect = rect; if (ballRect.intersects(brickRect)) { map.setBrickValue(0, i, j); totalBricks--; score += 1; if (bolaX + 19 <= brickRect.x || bolaX + 1 >= brickRect.x + brickRect.width) { bolaXd = -bolaXd; } else { bolaYd = -bolaYd; } break A; } } } } if (pause == false) { bolaX += bolaXd; bolaY += bolaYd; } if (bolaX < 0) { bolaXd = -bolaXd; } if (bolaY < 0) { bolaYd = -bolaYd; } if (bolaX > 670) { bolaXd = -bolaXd; } } repaint(); } Eu não tenho uma versão mais antiga do que essa, mas de qualquer forma, um exemplo da versão final esta aqui: /* * To change this license header, choose License Headers in Project Properties. * To change this template file, choose Tools | Templates * and open the template in the editor. */ package nilprowjeqt; import java.awt.Color; import java.awt.Font; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import javax.swing.JPanel; import javax.swing.Timer; import java.util.Random; import java.util.TimerTask; /** * * @author puelon */ public class Gameplay extends JPanel implements KeyListener, ActionListener { private boolean play = false; private boolean venceu = false; private boolean morto = false; private boolean scored = false; private boolean ascored = false; private boolean bscored = false; private boolean cheat = false; private boolean airbreak = false; private boolean skiplevel = false; private int score = 0; private int ascore = 0; private int bscore = 0; private double points = 0; private int level = 1; private int faliceu = 1; private boolean pause = false; private int totalBricks = 21; private String ranks; private Menu menu; private creditos credits; public enum STATE { MENU, GAME, COMP, MP, creditos }; public static STATE State = STATE.MENU; private Timer time; private int delay = 10; private int playerX = 310; private int playerY = 550; private int player2 = 310; private int bolaX = 350; private int bolaY = 350; private int bolaXd = -1; private int bolaYd = -2; private MapGenerator map; public boolean toggleCheat(boolean enabled) { enabled = cheat; if (cheat) { cheat = false; } if (!cheat) { cheat = true; } return enabled; } public int getPlayerPos(int y) { y = playerY; return y; } public String getRank(String rank) { String player = ranks; return player; } public String setRank(String player) { String rank = ""; rank = getRank(rank); /* rank = pontuação * (fase)/ morte */ return rank; } public int winGame(int lvl) { getLevel(lvl); return getLevel(lvl) + 1; } public int getLevel(int lvl) { lvl = level; return lvl; } public int getBolaX(int posx) { posx = bolaX; return posx; } public int getBolaY(int posy) { posy = bolaY; return posy; } public int setBolaX(int posx) { getBolaX(posx); return getBolaX(posx); } public int setBolaY(int posy) { getBolaY(posy); return getBolaY(posy); } public static int rndRangeX(int start, int finish) { Random rnd = new Random(); int rndInt = rnd.nextInt(finish + 1 - start) + start; return rndInt; } public static int rndRangeY(int start, int finish) { Random rnd = new Random(); int rndInt = rnd.nextInt(finish + 1 - start) + start; return rndInt; } public Gameplay() { menu = new Menu(); map = new MapGenerator(3, 7); addKeyListener(this); this.addMouseListener(new MouseInput()); setFocusable(true); setFocusTraversalKeysEnabled(false); time = new Timer(delay, this); time.start(); repaint(); } @Override public void paint(Graphics g) { morto = false; if (State == STATE.GAME || State == STATE.COMP) { // fundo g.setColor(Color.black); g.fillRect(1, 1, 692, 592); // drawing map map.draw((Graphics2D) g); // borda g.setColor(Color.yellow); g.fillRect(0, 0, 3, 592); g.fillRect(0, 0, 692, 3); g.fillRect(691, 0, 3, 592); //pontuação g.setColor(Color.white); g.setFont(new Font("serif", Font.BOLD, 25)); g.drawString("" + score, 598, 30); // level g.setColor(Color.white); g.setFont(new Font("serif", Font.BOLD, 25)); g.drawString("Level: " + level, 50, 30); // rank if (State == STATE.COMP) { g.setColor(Color.white); g.setFont(new Font("serif", Font.BOLD, 25)); g.drawString("Rank: " + ranks, 280, 30); } //the paddle g.setColor(Color.blue); g.fillRect(playerX, playerY, 100, 8); //the ball g.setColor(Color.white); g.fillOval(bolaX, bolaY, 20, 20); if (pause == true) { g.setColor(Color.red); g.setFont(new Font("serif", Font.BOLD, 30)); g.drawString("Jogo Pausado!", 270, 300); } if (cheat && airbreak) { g.setColor(Color.green); g.setFont(new Font("arial", Font.BOLD, 11)); g.drawString("(CHEAT):airbreak ativado com sucesso!", 10, 50); } if (cheat == true && skiplevel == true) { play = false; venceu = true; morto = false; bolaYd = 0; bolaXd = 0; g.setColor(Color.red); g.setFont(new Font("serif", Font.BOLD, 30)); g.drawString("voce joga demais amigo, passou de nivel!", 90, 300); g.setFont(new Font("serif", Font.BOLD, 30)); g.drawString("Pressione ENTER para prosseguir.", 190, 350); g.setColor(Color.green); g.setFont(new Font("arial", Font.BOLD, 11)); g.drawString("(CHEAT):skiplevel ativado com sucesso!", 10, 50); if (level > 10) { State = STATE.creditos; level = 10; g.setColor(Color.black); g.fillRect(1, 1, 692, 592); Font fnt = new Font("arial", Font.BOLD, 50); g.setFont(fnt); g.setColor(Color.white); g.drawString("FIM DE JOGO!", 190, 100); Font fnt1 = new Font("arial", Font.BOLD, 35); g.setFont(fnt1); g.setColor(Color.white); g.drawString("Créditos", 290, 200); Font fnt2 = new Font("arial", Font.ITALIC, 20); g.setFont(fnt2); g.setColor(Color.white); g.drawString("AGRADECIMENTOS", 270, 250); Font fnt3 = new Font("arial", Font.ITALIC, 20); g.setFont(fnt3); g.setColor(Color.white); g.drawString("Alex de Jesus Santos", 100, 300); g.setColor(Color.white); g.drawString("Gabriel 'Moises' Carvalho", 100, 330); g.setColor(Color.white); g.drawString("Jean Vitor Albertini", 100, 360); g.setColor(Color.white); g.drawString("Luiz B.P Alcantara", 100, 390); g.setColor(Color.white); g.drawString("Publio Elon", 100, 420); Font fnt4 = new Font("arial", Font.BOLD, 25); g.setFont(fnt4); g.setColor(Color.white); g.drawString("Turma: Engenharia da Computaçao 9º SEMESTRE", 15, 500); Font fnt5 = new Font("arial", Font.BOLD, 25); g.setFont(fnt5); g.setColor(Color.white); g.drawString("Ainda bem, até um outro dia", 150, 550); } } else if (State == STATE.creditos) { credits.render(g); } if (totalBricks <= 0 && morto == false) { play = false; venceu = true; morto = false; bolaYd = 0; bolaXd = 0; g.setColor(Color.red); g.setFont(new Font("serif", Font.BOLD, 30)); g.drawString("voce joga demais amigo, passou de nivel!", 90, 300); g.setFont(new Font("serif", Font.BOLD, 30)); g.drawString("Pressione ENTER para prosseguir.", 190, 350); } if (bolaY > 570 && faliceu != 3) { play = false; bolaYd = 0; bolaXd = 0; morto = true; double defeat; defeat = points * 0.10; defeat = points - defeat; g.setColor(Color.red); g.setFont(new Font("serif", Font.BOLD, 30)); g.drawString("FALICEU, SEU PONTO FOI:" + score, 90, 300); g.setFont(new Font("serif", Font.BOLD, 30)); g.drawString("Pressione ENTER para jogar novamente", 150, 350); level = 0; delay = 8; } if (bolaY > 570 && faliceu == 3) { play = false; bolaYd = 0; bolaXd = 0; g.setColor(Color.red); g.setFont(new Font("serif", Font.BOLD, 30)); g.drawString("MOISES NAO CONSEGUE NE, PONTUAÇAO:" + score, 90, 300); g.setFont(new Font("serif", Font.BOLD, 30)); g.drawString("Pressione ENTER para jogar novamente", 150, 350); level = 0; delay = 8; } } else if (State == STATE.MENU) { menu.render(g); } else if (State == STATE.MP) { delay = 4; // fundo g.setColor(Color.black); g.fillRect(1, 1, 692, 592); // drawing map // borda g.setColor(Color.yellow); g.fillRect(0, 0, 3, 592); // 692 é o valor do Y topo g.fillRect(0, 0, 692, 3); g.fillRect(691, 0, 3, 592); //pontuação player A g.setColor(Color.white); g.setFont(new Font("serif", Font.BOLD, 25)); g.drawString("" + ascore, 598, 30); g.setColor(Color.white); g.setFont(new Font("serif", Font.BOLD, 25)); g.drawString("" + bscore, 598, 550); /* PLAYER A */ g.setColor(Color.blue); g.fillRect(player2, 20, 100, 8); g.setColor(Color.blue); g.fillRect(playerX, 550, 100, 8); // bola g.setColor(Color.white); g.fillOval(bolaX, bolaY, 20, 20); if (bolaY > 570 && State == STATE.MP) { scored = true; play = false; bolaYd = 310; bolaXd = 0; ascored = true; g.setColor(Color.green); g.setFont(new Font("arial", Font.BOLD, 30)); g.drawString("Ponto do Jogador A", 10, 50); } if (bolaY < 0 && State == STATE.MP) { scored = true; play = false; bolaYd = 0; bolaXd = 0; bscored = true; g.setColor(Color.green); g.setFont(new Font("arial", Font.BOLD, 30)); g.drawString("Ponto do Jogador B", 10, 560); } if (State == STATE.MP && scored == true) { bolaYd = 310; bolaXd = 100; } } } @Override public void keyTyped(KeyEvent ke) { } @Override public void keyPressed(KeyEvent e) { if (e.getKeyCode() == KeyEvent.VK_UP && State == STATE.GAME && playerY > 20) { moveUp(); } else if (playerY < 20) { playerY = 20; } if (e.getKeyCode() == KeyEvent.VK_DOWN && State == STATE.GAME && playerY < 550) { moveDown(); } else if (playerY < 20) { playerY = 550; } if (State == STATE.GAME || State == STATE.COMP || State == STATE.MP) { if (e.getKeyCode() == KeyEvent.VK_D) { if (playerX >= 600) { playerX = 600; } else { if (pause == false && airbreak == false && cheat == false) { moveRight(); } if (pause == true && airbreak == true && cheat == true) { moveRight(); } } } } if (State == STATE.GAME || State == STATE.COMP || State == STATE.MP) { if (e.getKeyCode() == KeyEvent.VK_A) { if (playerX < 10) { playerX = 10; } else { if (pause == false) { moveLeft(); } if (pause == true && airbreak == true && cheat == true) { moveLeft(); } } } } if (State == STATE.GAME || State == STATE.COMP || State == STATE.MP) { if (e.getKeyCode() == KeyEvent.VK_RIGHT) { if (player2 >= 600) { player2 = 600; } else { if (pause == false) { moveRight2(); } } } } if (State == STATE.GAME || State == STATE.COMP || State == STATE.MP) { if (e.getKeyCode() == KeyEvent.VK_LEFT) { if (player2 < 10) { player2 = 10; } else { if (pause == false) { moveLeft2(); } } } } if (e.getKeyCode() == KeyEvent.VK_ENTER && venceu == false && State != STATE.MP) { if (!play) { play = true; venceu = false; bolaX = rndRangeX(270, 530); bolaY = rndRangeY(450, 500); bolaXd = -1; bolaYd = -2; playerX = 310; totalBricks = 21; faliceu++; map = new MapGenerator(3, 7); repaint(); } } if (e.getKeyCode() == KeyEvent.VK_ENTER && ascored == true && State == STATE.MP) { if (ascored) { ascore++; scored = false; ascored = false; } if (!play) { play = true; scored = false; bolaX = rndRangeX(270, 530); bolaY = 350; bolaXd = -1; bolaYd = -2; playerX = 310; player2 = 310; repaint(); } } if (e.getKeyCode() == KeyEvent.VK_ENTER && bscored == true && State == STATE.MP) { if (bscored) { bscore++; scored = false; bscored = false; } if (!play) { play = true; scored = false; bolaX = rndRangeX(270, 530); bolaY = 350; bolaXd = -1; bolaYd = -2; playerX = 310; player2 = 310; repaint(); } } if (e.getKeyCode() == KeyEvent.VK_ENTER && venceu == true && State != STATE.MP) { if (!play) { play = true; venceu = false; bolaX = rndRangeX(270, 530); bolaY = rndRangeY(450, 500); bolaXd = -1; bolaYd = -2; playerX = 310; totalBricks = 21; level++; delay--; map = new MapGenerator(3, 7); repaint(); } } if (e.getKeyCode() == KeyEvent.VK_ESCAPE && State != STATE.MP) { if (pause == false) { pause = true; int x = bolaX; int y = bolaY; setBolaY(y); setBolaX(x); } else { pause = false; } } if (e.getKeyCode() == KeyEvent.VK_ADD && cheat == false && airbreak == false) { if (State == STATE.GAME) { { cheat = true; airbreak = true; } } else if (e.getKeyCode() == KeyEvent.VK_ADD && cheat == true && airbreak == true) { if (State == STATE.GAME) { cheat = false; airbreak = false; } } } if (e.getKeyCode() == KeyEvent.VK_SUBTRACT && cheat == false && skiplevel == false) { if (State == STATE.GAME) { { cheat = true; skiplevel = true; } } else if (e.getKeyCode() == KeyEvent.VK_SUBTRACT && cheat == true && skiplevel == true) { if (State == STATE.GAME) { cheat = false; skiplevel = false; } } } } /* if(e.getKeyCode() == KeyEvent.VK_CONTROL && e.getKeyCode() == KeyEvent.VK_C && State == STATE.GAME) { toggleCheat(cheat); if(toggleCheat(cheat) == true){ if(e.getKeyCode() == KeyEvent.VK_UP){ moveUp(); } } }*/ // função do cheat public void moveUp() { if (cheat && airbreak) { play = true; playerY -= 30; } } // função do cheat2 public void moveDown() { if (cheat && airbreak) { play = true; playerY += 30; } } public void moveRight() { play = true; playerX += 20; } public void moveLeft() { play = true; playerX -= 20; } public void moveRight2() { play = true; player2 += 20; } public void moveLeft2() { play = true; player2 -= 20; } @Override public void keyReleased(KeyEvent ke) { } @Override public void actionPerformed(ActionEvent e) { time.start(); repaint(); if (play) { if (new Rectangle(bolaX, bolaY, 20, 20).intersects(new Rectangle(playerX, 550, 100, 8))) { bolaYd = -bolaYd; } if (play && State == STATE.GAME && cheat == true && airbreak == true) { if (new Rectangle(bolaX, bolaY, 20, 20).intersects(new Rectangle(playerX, getPlayerPos(playerY), 100, 8))) { bolaYd = -bolaYd; } } if (play && State == STATE.MP) { if (new Rectangle(bolaX, bolaY, 20, 20).intersects(new Rectangle(playerX, 549, 100, 8))) { bolaYd = -bolaYd; } } if (play && State == STATE.MP) { if (new Rectangle(bolaX, bolaY, 20, 20).intersects(new Rectangle(player2, 20, 100, 8))) { bolaYd = -bolaYd; } } A: for (int i = 0; i < map.map.length; i++) { for (int j = 0; j < map.map[0].length; j++) { if (map.map[i][j] > 0) { int brickX = j * map.brickWidth + 80; int brickY = i * map.brickHeight + 50; int brickWidth = map.brickWidth; int brickHeight = map.brickHeight; Rectangle rect = new Rectangle(brickX, brickY, brickWidth, brickHeight); Rectangle ballRect = new Rectangle(bolaX, bolaY, 20, 20); Rectangle brickRect = rect; Rectangle paddleRect = new Rectangle(playerX, getPlayerPos(playerY - 22), 50, 8 + 1); if (ballRect.intersects(brickRect) && State != STATE.MP) { map.setBrickValue(0, i, j); totalBricks--; score += 1; /* rank = pontuação * (fase)/ morte */ points = score * level / faliceu; if (points >= 0 && points <= 21 && State == STATE.COMP) { ranks = "iniciante"; } if (points >= 22 && points <= 43 && State == STATE.COMP) { ranks = "Aprendiz"; } if (points >= 44 && points <= 88 && State == STATE.COMP) { ranks = "Amador"; } if (points >= 89 && points <= 200 && State == STATE.COMP) { ranks = "Jogador"; } if (points >= 201 && points <= 403 && State == STATE.COMP) { ranks = "Veterano"; } if (points >= 404 && points <= 808 && State == STATE.COMP) { ranks = "Viciado"; } if (points >= 404 && points <= 808 && State == STATE.COMP) { ranks = "Viciado"; } if (bolaX + 19 <= brickRect.x || bolaX + 1 >= brickRect.x + brickRect.width) { bolaXd = -bolaXd; } else { bolaYd = -bolaYd; } break A; } if (paddleRect.intersects(brickRect) && State == STATE.GAME) { map.setBrickValue(0, i, j); totalBricks--; score += 1; } } } } if (pause == false) { bolaX += bolaXd; bolaY += bolaYd; } if (bolaX < 0) { bolaXd = -bolaXd; } if (bolaY < 0 && State != STATE.MP) { bolaYd = -bolaYd; } if (bolaX > 670) { bolaXd = -bolaXd; } } repaint(); } }

Sobre o Clube do Hardware

No ar desde 1996, o Clube do Hardware é uma das maiores, mais antigas e mais respeitadas comunidades sobre tecnologia do Brasil. Leia mais

Direitos autorais

Não permitimos a cópia ou reprodução do conteúdo do nosso site, fórum, newsletters e redes sociais, mesmo citando-se a fonte. Leia mais

×
×
  • Criar novo...

Ebook grátis: Aprenda a ler resistores e capacitores!

EBOOK GRÁTIS!

CLIQUE AQUI E BAIXE AGORA MESMO!