Escolar Documentos
Profissional Documentos
Cultura Documentos
h>
#include <delays.h>
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
else
clock=1;
void main(void)
//IN_D1
int IN_1=0;
int IN_2=0;
//POSICIONAMENTO COMIDAS
char CCOMIDA_SNAKE=0;
char LCOMIDA_SNAKE=0;
//POSICIONAMENTO DA SNAKE
int L1_C=(0b00001000);
int L2_C=(0b00000100);
int L1_L=(0b00000010);
int L2_L=(0b00000010);
Delay100TCYx(10);
do
//INICIO SNAKE
PORTD=0;
atualiza_display(L1_C);
PORTD=(L1_L);
Delay100TCYx(10);
PORTD=0;
atualiza_display(L2_C);
PORTD=(L2_L);
Delay100TCYx(10);
//ACIONANDO COMIDA
PORTD=0;
atualiza_display(COMIDA_SNAKEC[CCOMIDA_SNAKE]);
PORTD=(COMIDA_SNAKEL[LCOMIDA_SNAKE]);
Delay100TCYx(10);
//ACIONAMENTO DISPLAY
if (CCOMIDA_SNAKE<20) {
PORTD=0;
Delay100TCYx(10);
if (CCOMIDA_SNAKE<20) {
PORTD=0;
Delay100TCYx(10);
if
(L2_C==COMIDA_SNAKEC[CCOMIDA_SNAKE]) {
if
(L2_L==COMIDA_SNAKEL[LCOMIDA_SNAKE]) {
(IN_1=IN_1+1); //variável de
IN_D1
atualiza_display(COMIDA_SNAKEC[CCOMIDA_SNAKE]);
PORTD=(COMIDA_SNAKEL[LCOMIDA_SNAKE]);
Delay100TCYx(10);
if (CCOMIDA_SNAKE==10) {
//comidas partem do ponto 1
CCOMIDA_SNAKE=0;
LCOMIDA_SNAKE=0;
if (IN_1==10){ //
recebe mais um no display da dezena
IN_2=IN_2+1;
if (IN_1==10){
// quando chega a nove na unidade volta no 0
IN_1=0;
if
(IN_2==9) { // quando chega no 9 no display dois reseta os dois
//LADO DIREITO
if (!DIREITA){
L1_C = L2_C;
L1_L = L2_L;
if (L2_C==64) {
L2_C=1;
else if (L2_C==8) {
L2_C=64;
else
L2_C=L2_C*2;
while(!DIREITA)
{Delay100TCYx(10);}
}
//LADO ESQUERDO
if (!ESQUERDA) {
L1_C = L2_C;
L1_L = L2_L;
if (L2_C==1) {
(L2_C=64);
else if (L2_C==64) {
(L2_C=8);
else {
L2_C=(L2_C/2);
while (!ESQUERDA)
{Delay100TCYx(10);}
//DESCE
if (!DESCE) {
L1_C = L2_C;
L1_L = L2_L;
if (L2_L == 1) {
L2_L=128;
else {
L2_L = L2_L/2;
while (!DESCE)
{Delay100TCYx(10);}
//SOBE
if (!SOBE) {
L1_C = L2_C;
L1_L = L2_L;
if (L2_L==128) {
(L2_L = 1);
else {
L2_L = (L2_L*2);
while (!SOBE)
{Delay100TCYx(10);}
}while(1);