3
I’m trying to develop a game within the curricular unit of microprocessors, so the game consists of a dummy that has to dodge bombs, so I have to create the dummy, the bombs and get them moving. I already have a good piece of code, but I think it gets stuck in a while loop, and I don’t understand why. Will exposing here a piece of my code are able to help me??
void main (void)
{
unsigned char i,counter=1;
start=0;
end=0;
IE=0b10000101;
En=1;
LCD_init ();
while(start!=0);
while(end==1);
Inicio();
CriarBonecoBomba();
x=0;
y=0;
score=0;
for(i=0;i<16;i++)
{
var[0][i]=' ';
var[1][i]=' ';
}
while(end==0) // salta da 1a interrupção la ao fundo para aqui e não sai daqui
{
while (start==1)
{
MovBoneco();
desloca_esq();
if((counter+3)%6==0)
cria_bomba(1);
else
if(counter%6==0)
cria_bomba(2);
else
cria_bomba(0);
if(var[y][x]==1|| 1==var[y][x-1])
{
LCD_comando(0b10000000);
LCD_date(' ');
LCD_date(' ');
LCD_date(' ');
LCD_date('G');
LCD_date('A');
LCD_date('M');
LCD_date('E');
LCD_date(' ');
LCD_date('O');
LCD_date('V');
LCD_date('E');
LCD_date('R');
while(1);
}
MovBoneco();
AtualizarLCD();
counter++;
if(var[0][0]==1||var[1][0]==1)
score=score+5;
display7segmentos();
}
}
}
void RSIEXT0(void)__interrupt (0)
{
start=1;
}
void RSIEXT1(void)__interrupt (2)
{
end==1;
}
Which compiler are you using? Where do you detect the collision with the pump? You are resetting the variable value start when the bomb hits the dummy?
– Avelino
Missing includes in your code so you can at least try to compile your script
– Guilherme Nascimento
I don’t think that question should be suspended as unclear. The following sentence says it all: "I already have a good piece of code but I think it gets stuck in a while loop and I don’t understand why".
– Luiz Vieira
I have the includes in my code, and it compiles correctly, the problem is that I’ve done everything and something else and I can’t get it to start at all. the complilaqdor I am using is the MCU 8051 IDE.
– Ana Costa
In which of
while
's it gets stuck?– Vinícius Gobbo A. de Oliveira
Just in the first while, while(start!= 0).
– Ana Costa