Example #1
0
Snake::Snake(const SnakeBody& head, int tamanho) : head(head) {
    const sf::Vector2f headPosition = this->head.getPosition();
    for (int i = 1; i < tamanho; i++) {
        corpo.emplace_back(SnakeBody(headPosition - sf::Vector2f(16.f * i, 0.f), false));
        corpo.back().setRotation(head);
    }
}
Example #2
0
int main(void)
{
		DDRA = 0xF0; PORTA = 0x0F;
		DDRB = 0x00;  PORTB = 0xFF;
		DDRC = 0xFF; PORTC = 0x00;
		DDRD = 0xFF; PORTD = 0x00;
		gameSelector = 0xFF;
		LINE_init();
	    TimerSet(1);
	    TimerOn();
	    srand(0);
	    InitADC();
		initUSART(1);
		
    while (1) 
    {
		if(SandM_period >= 10)
		{
			if(USART_HasReceived(1)){
				gameSelector = receiveData(1);
			}
			SandM_period = 0;
		}
		++SandM_period;
		
		if(gameSelector == 0x02)
		{
			if(TRLINES_period >= 9)
			{	       
				TRLINES_period = 0;
			}
			if(TRuser_period >= 80)
			{
				TunRun_ChkLoss();
				TunRun_JoyStk();
				TUNRUN_LINES();
				TunRun_Input();
				TRuser_period = 0;
			}
				displayMatrix();
				++TRLINES_period;
				++TRuser_period;
		}
		if(gameSelector == 0x04)
		{
			if(arrows_period >= 750)
			{
				DDR_arrows();
				if((arrow == 0) || (arrow == 2))
				{
					ADMUX = 0x40;
				}
				else
				{
					ADMUX = 0x41;
				}
				arrows_period = 0;
			}
			if(arrows_inputP >= 20)
			{
				DDR_Input();
				DDR_JoyStk();
				arrows_inputP = 0;
			}
			if(arrowsPeriod >= 250)
			{
				DDR_ChkLoss();
				arrowsPeriod = 0;
			}
			displayMatrix();
			++arrows_inputP;
			++arrows_period;
			++arrowsPeriod;
		}
		if(gameSelector == 0x03)
		{
			if(snakeJoystick > 30)
			{
				Snake_JoyStk();
				Snake_Input();
				snakeJoystick = 0;
			}
			if(body > body_period)
			{
				SnakeBody();
				Snake_Movement();
				body = 0;
			}
			++snakeJoystick;
			++joystick;
			++body;
			displayMatrix();
		}
		while(!TimerFlag);
		TimerFlag = 0;
    }
}
Example #3
0
void Snake::aumentarCorpo() {
    corpo.emplace_back(SnakeBody(corpo.back().getPosition(), false));
    corpo.back().setRotation(corpo[corpo.size() - 2]);
}