Пример #1
0
void Update(uint32_t tick) {
	snes_button_state_t state = GetControllerState1();
	
	if (state.buttons.Up)
	{
		if ((katze.ypos > 100) && (katze.ypos <= 200-34))
		{
			katze.ypos--;/* code */
		}
	}
	if (state.buttons.Down)
	{
		if ((katze.ypos >= 100) && (katze.ypos < 200-34))
		{
			katze.ypos++;/* code */
		}
	}
	if (state.buttons.Left)
	{
		if ((katze.xpos > 0) && (katze.xpos <= 320-51))
		{
			katze.xpos--;/* code */
		}
	}
	if (state.buttons.Right)
	{
		if ((katze.xpos >= 0) && (katze.xpos < 320-51))
		{
			katze.xpos++;/* code */
		}
	}
	katze.animation+= (SysTickCounter%10 == 0);
	katze.animation = katze.animation % 6;
}
Пример #2
0
int buttonPressedCountStuff(int controller, int count){
    snes_button_state_t controller_state;
    // get controller state
    if(controller==0){
        controller_state = GetControllerState1();
    }else{
        controller_state = GetControllerState2();
    }
    // if no button is pressed, reset counter
    if(controller_state.raw == 0){
        buttonTimes[controller]=0;
    // otherwise update counter
    }else{
        buttonTimes[controller]++;
    }

    // if counter has reached the given number, reset counter and return true value
    if(buttonTimes[controller]==count){
        buttonTimes[controller]=0;
        return 1;
    // otherwise just return false value
    }else{
        return 0;
    }
}
Пример #3
0
void Update(uint32_t delta)
{
	state1 = GetControllerState1();
  state2 = GetControllerState2();

  if(state1.buttons.Up)
    EnableRumble();
  else
    DisableRumble();
}
Пример #4
0
void Storyboard_Update(void* storyboard)
{
    Storyboard* this = storyboard;

    snes_button_state_t controller1 = GetControllerState1();
    snes_button_state_t controller2 = GetControllerState2();

    if (this->buttonDown) {
        if (!controller1.buttons.A && !controller2.buttons.A) {
            this->entity->destroyed = true;
            this->buttonDown = false;
        }
    } else {
        if (controller1.buttons.A || controller2.buttons.A) {
            this->buttonDown = true;
        }
    }
}
Пример #5
0
void Update(uint32_t a)
{
    snes_button_state_t controller_state = GetControllerState1();

    if(controller_state.buttons.Select){
        init_glider(A);
        run=0;
    }
    if(controller_state.buttons.Y){
        init_simple_row(A);
        run=0;
    }
    if(controller_state.buttons.X){
        init_empty_field(A);
        run=0;
    }

    if(run==1){
    	if(roundcount % speed == 0) update_Array(A);
        roundcount++;
        if(buttonPressedCountStuff(0,10)){
            if(controller_state.buttons.L) if(speed<20) speed++;
            if(controller_state.buttons.R) if(speed>1) speed--;
            if(controller_state.buttons.Start){
                run=0;
                roundcount=0;
            }
        }
    }else{
        if(controller_state.buttons.A) A[curx][cury]=1;
        if(controller_state.buttons.B) A[curx][cury]=0;

        if(buttonPressedCountStuff(0,10)){
            if(controller_state.buttons.Start){
                run=1;
            }

            if(controller_state.buttons.Left) curx--;
            if(controller_state.buttons.Right) curx++;
            if(controller_state.buttons.Up) cury--;
            if(controller_state.buttons.Down) cury++;
        }
    }
}
Пример #6
0
void Menu_Update(uint32_t a){

	if (SysTickCounter-lastMenuUpdated > menuTickSpeed){
		if (GetControllerState1().buttons.Up){
			if(menuSelectedItem > 0) menuSelectedItem--;
			lastMenuUpdated = SysTickCounter;
		}
		if (GetControllerState1().buttons.Down){
			if(menuSelectedItem < itemCount) menuSelectedItem++;
			lastMenuUpdated = SysTickCounter;
		}
		//Return to Game
		if (GetControllerState1().buttons.Start){
			ExitState();
			lastMenuUpdated = SysTickCounter;
		}
		//Sell Item
		if (GetControllerState1().buttons.B){
			itemSell(&p1, (Item*)itemList[menuSelectedItem]);
			lastMenuUpdated = SysTickCounter;
		}
		//Buy Item
		if (GetControllerState1().buttons.A){
			itemBuy(&p1, (Item*)itemList[menuSelectedItem]);
			lastMenuUpdated = SysTickCounter;
		}
		if (GetControllerState1().buttons.X){
			sellAllMinerals(&p1);
			lastMenuUpdated = SysTickCounter;
		}
		if (GetControllerState1().buttons.Y){
			mineralPickup(&p1, MIN_DIAMOND);
			lastMenuUpdated = SysTickCounter;
		}
	}

}
Пример #7
0
void Red_Update(uint32_t delta)
{
	snes_button_state_t state = GetControllerState1();
	if (state.buttons.Down)
		ExitState();
}
Пример #8
0
void Update(uint32_t delta)
{
	snes_button_state_t state = GetControllerState1();
	pushbutton_button_state_t anotherState = GetPushbuttonState();
	myframe++;
}
Пример #9
0
void Update(uint32_t delta) {
	int32_t old_pos_x = pos_x;
	int32_t old_pos_y = pos_y;

	#ifdef ACCELEROMETER
		/*if (UserButtonState()) {
			ReadRawAccelerometerData(zero);
		}*/


		int8_t components[3];
		ReadCalibratedAccelerometerData(components);
		int32_t dx = components[1];
		int32_t dy = components[0];

		dx = (dx / 10) * 10;
		dy = (dy / 10) * 10;

		pos_x -= (dx / 10) * delta;
		pos_y -= (dy / 10) * delta;
	#else
		if (GetControllerState1().buttons.Start && (SysTickCounter - lastMenuUpdate) > 40 )
		{
			lastMenuUpdate = SysTickCounter;
			pause_mode = pause_mode ? 0 : 1;
		}

		if (pause_mode)
		{
			return;
		}

		pos_x += GetControllerState1().buttons.Right * delta;
		pos_x -= GetControllerState1().buttons.Left * delta;
		pos_y -= GetControllerState1().buttons.Up *delta;
		pos_y += GetControllerState1().buttons.Down *delta;
	#endif

	dir = 0;

	if (old_pos_x < pos_x) {
		dir = 1;
	} else if (old_pos_x > pos_x) {
		dir = -1;
	}

	if (pos_x < 0) {
		pos_x = 0;
	}

	if (pos_x >= 320) {
		pos_x = 320;
	}

	if (pos_y >= 200) {
		pos_y = 200;
	}

	if (pos_y < 0) {
		pos_y = 0;
	}

}