Пример #1
0
inline void Lattice::create_neighbours(int x, int y)
{ check_boundary(x,y);
  Site& s = get_site(x,y);

  int x1 = x+1;
  int y1 = y;
  check_boundary(x1,y1);
  Site& nb1 = get_site(x1, y1);
  s.add_neighbour(nb1);

  x1 = x;
  y1 = y+1;
  check_boundary(x1,y1);
  Site& nb2 = get_site(x1, y1);
  s.add_neighbour(nb2);

  x1 = x-1;
  y1 = y;
  check_boundary(x1,y1);
  Site& nb3 = get_site(x1, y1);
  s.add_neighbour(nb3);

  x1 = x;
  y1 = y-1;
  check_boundary(x1,y1);
  Site& nb4 = get_site(x1, y1);
  s.add_neighbour(nb4);

}
Пример #2
0
void role::execute_change() {
	RECT				_role_rect = roleUtil::get_instance()->get_role_rect();
	RECT				_role_limit_rect = MapUtil::get_instance()->get_role_limit_rect();

	switch (m_an_state)
	{
	case ROLE_ANIMATION_UP:
		if (!check_boundary(role::CHECK_MOVE_UP))
		{
			return;
		}
		if(_role_rect.top > _role_limit_rect.bottom ||   // check self  
														// check map boundary
		!(MapUtil::get_instance()->check_movable(MapUtil::CHECK_MOVE_UP))) {
			m_y -= MapConst::MAP_SPEED;
		}
		break;
	case ROLE_ANIMATION_DOWN:
		if (!check_boundary(role::CHECK_MOVE_DOWN))
		{
			return;
		}
		if(_role_rect.bottom < _role_limit_rect.top ||   // check self  
			// check map boundary
			!(MapUtil::get_instance()->check_movable(MapUtil::CHECK_MOVE_DOWN))) {
				m_y += MapConst::MAP_SPEED;
		}
		break;
	case ROLE_ANIMATION_LEFT:
		if (!check_boundary(role::CHECK_MOVE_LEFT))
		{
			return;
		}
		if(_role_rect.left > _role_limit_rect.right ||   // check self  
			// check map boundary
			!(MapUtil::get_instance()->check_movable(MapUtil::CHECK_MOVE_LEFT))) {
				m_x -= MapConst::MAP_SPEED;
		}
		break;
	case ROLE_ANIMATION_RIGHT:
		if (!check_boundary(role::CHECK_MOVE_RIGHT))
		{
			return;
		}
		if(_role_rect.right < _role_limit_rect.left ||   // check self  
			// check map boundary
			!(MapUtil::get_instance()->check_movable(MapUtil::CHECK_MOVE_RIGHT))) {
				m_x += MapConst::MAP_SPEED;
		}
		break;
	}
}
Пример #3
0
void game_state::check_boundaries( void )
{
    for( size_t i = tanks.size(); i > 0; --i )
    {
        if( check_boundary( tanks[ i - 1 ]->getPos() ) )
        {
            destroy_tank( i - 1 );
        }
    }

    for( size_t i = bullets.size(); i > 0; --i )
    {
        if( check_boundary( bullets[ i - 1 ]->getPos() ) )
        {
            bullets.erase( bullets.begin() + i - 1 );
        }
    }
}
Пример #4
0
void sum_is_x(int *arr, int p , int r, int sum)
{
	if(p<r)
	{
		int q = (p+r)/2;
		sum_is_x(arr,p,q,sum);
		sum_is_x(arr,q+1,r,sum);
		check_boundary(arr,p,q,r,sum);		
	}
}
Пример #5
0
static int _touch(struct device_info *dev, unsigned int x, unsigned y, int pts)
{
	char cmd[50] = {0};
	int i, retval;

	retval = check_boundary(dev, x, y);

	if(!retval){
		if(dev->dev_flag == INPUT_TOUCH_DEV_CLASS_MT_SYNC){
			exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_TOUCH_MAJOR, 100);
			exec_sendevent(dev->dev_touch, EV_ABS, ABS_PRESSURE, 100);
			exec_sendevent(dev->dev_touch, EV_KEY, BTN_TOUCH, DOWN);
		}else if(dev->dev_flag == INPUT_TOUCH_DEV_CLASS_MT){
			exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_TRACKING_ID, 0);
		}else if(dev->dev_flag == INPUT_TOUCH_DEV_CLASS_ST){
			;
		}

		for( i=0; i < pts; i++){
			if(i == 0 && dev->dev_flag == INPUT_TOUCH_DEV_CLASS_MT_SYNC)
				exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_TOUCH_MAJOR, 64);

			exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_POSITION_X, x);
			exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_POSITION_Y, y);
			event_end(dev->dev_touch, dev->dev_flag);
			usleep(dev->delay_us);
		}

		if(dev->dev_flag == INPUT_TOUCH_DEV_CLASS_MT_SYNC){
			exec_sendevent(dev->dev_touch, EV_KEY, BTN_TOUCH ,UP);
			exec_sendevent(dev->dev_touch, EV_ABS, ABS_PRESSURE, 0);
			event_end(dev->dev_touch, dev->dev_flag);
			event_end(dev->dev_touch, dev->dev_flag);
			event_end(dev->dev_touch, dev->dev_flag);
		}else if(dev->dev_flag == INPUT_TOUCH_DEV_CLASS_MT){
			exec_sendevent(dev->dev_touch, EV_ABS, ABS_MT_TRACKING_ID, 0xffffffff);
			event_end(dev->dev_touch, dev->dev_flag);
		}else if(dev->dev_flag == INPUT_TOUCH_DEV_CLASS_ST){
			;
		}
	}else{
		printf("Error: Position is out of range\n");
	}

	return retval;
}
Пример #6
0
void NX_PumpEvents (_THIS)
{
    GR_EVENT         event ;
    static GR_BUTTON last_button_down = 0 ;

    GrCheckNextEvent (& event) ;
    while (event.type != GR_EVENT_TYPE_NONE) {

        // dispatch event
        switch (event.type) {
            case GR_EVENT_TYPE_MOUSE_ENTER :
            {
                Dprintf ("mouse enter\n") ;
                SDL_PrivateAppActive (1, SDL_APPMOUSEFOCUS) ;
                break ;
            }

            case GR_EVENT_TYPE_MOUSE_EXIT :
            {
                Dprintf ("mouse exit\n") ;
                SDL_PrivateAppActive (0, SDL_APPMOUSEFOCUS) ;
                break ;
            }

            case GR_EVENT_TYPE_FOCUS_IN :
            {
                Dprintf ("focus in\n") ;
                SDL_PrivateAppActive (1, SDL_APPINPUTFOCUS) ;
                break ;
            }

            case GR_EVENT_TYPE_FOCUS_OUT :
            {
                Dprintf ("focus out\n") ;
                SDL_PrivateAppActive (0, SDL_APPINPUTFOCUS) ;
                break ;
            }

            case GR_EVENT_TYPE_MOUSE_MOTION :
            {               
                Dprintf ("mouse motion\n") ;

                if (SDL_VideoSurface) {
                    if (currently_fullscreen) {
                        if (check_boundary (this, event.button.x, event.button.y)) {
                            SDL_PrivateMouseMotion (0, 0, event.button.x - OffsetX, 
                                event.button.y - OffsetY) ;
                        }
                    } else {
                        SDL_PrivateMouseMotion (0, 0, event.button.x, event.button.y) ;
                    }
                }
                break ;
            }

            case GR_EVENT_TYPE_BUTTON_DOWN :
            {
                int button = event.button.buttons ;
                
                Dprintf ("button down\n") ;

                switch (button) {
                    case MWBUTTON_L :
                        button = 1 ;
                        break ;
                    case MWBUTTON_M :
                        button = 2 ;
                        break ;
                    case MWBUTTON_R :
                        button = 3 ;
                        break ;
                    default :
                        button = 0 ;
                }
                last_button_down = button ;
                
                if (currently_fullscreen) {
                    if (check_boundary (this, event.button.x, event.button.y)) {
                        SDL_PrivateMouseButton (SDL_PRESSED, button, 
                            event.button.x - OffsetX, event.button.y - OffsetY) ;
                    }
                } else {
                    SDL_PrivateMouseButton (SDL_PRESSED, button, 
                        event.button.x, event.button.y) ;
                }
                break ;
            }

            // do not konw which button is released
            case GR_EVENT_TYPE_BUTTON_UP :
            {   
                Dprintf ("button up\n") ;

                if (currently_fullscreen) {
                    if (check_boundary (this, event.button.x, event.button.y)) {
                        SDL_PrivateMouseButton (SDL_RELEASED, last_button_down, 
                            event.button.x - OffsetX, event.button.y - OffsetY) ;
                    }
                } else {
                    SDL_PrivateMouseButton (SDL_RELEASED, last_button_down, 
                        event.button.x, event.button.y) ;
                }
                last_button_down = 0 ;
                break ;
            }

            case GR_EVENT_TYPE_KEY_DOWN :
            {
                SDL_keysym keysym ;

                Dprintf ("key down\n") ;
                SDL_PrivateKeyboard (SDL_PRESSED,
                    NX_TranslateKey (& event.keystroke, & keysym)) ;
                break ;
            }

            case GR_EVENT_TYPE_KEY_UP :
            {
                SDL_keysym keysym ;

                Dprintf ("key up\n") ;
                SDL_PrivateKeyboard (SDL_RELEASED,
                    NX_TranslateKey (& event.keystroke, & keysym)) ;
                break ;
            }

            case GR_EVENT_TYPE_CLOSE_REQ :
            {
                Dprintf ("close require\n") ;
                SDL_PrivateQuit () ;
                break ;
            }

            case GR_EVENT_TYPE_EXPOSURE :
            {
                Dprintf ("event_type_exposure\n") ;
                if (SDL_VideoSurface) {
                    NX_RefreshDisplay (this) ;//, & event.exposure) ;
                }
                break ;
            }

            case GR_EVENT_TYPE_UPDATE :
            {
                switch (event.update.utype) {
                    case GR_UPDATE_MAP :
                    {
                        Dprintf ("GR_UPDATE_MAP\n") ;
                        // If we're not active, make ourselves active
                        if (!(SDL_GetAppState () & SDL_APPACTIVE)) {
                            // Send an internal activate event
                            SDL_PrivateAppActive (1, SDL_APPACTIVE) ;
                        }
                        if (SDL_VideoSurface) {
                            NX_RefreshDisplay (this) ;
                        }
                        break ;
                    }
                    
                    case GR_UPDATE_UNMAP :
                    case GR_UPDATE_UNMAPTEMP :
                    {
                        Dprintf ("GR_UPDATE_UNMAP or GR_UPDATE_UNMAPTEMP\n") ;
                        // If we're active, make ourselves inactive
                        if (SDL_GetAppState () & SDL_APPACTIVE) {
                            // Send an internal deactivate event
                            SDL_PrivateAppActive (0, SDL_APPACTIVE | SDL_APPINPUTFOCUS) ;
                        }
                        break ; 
                    }
                    
                    case GR_UPDATE_SIZE :
                    {
                        Dprintf ("GR_UPDATE_SIZE\n") ;
                        SDL_PrivateResize (event.update.width, event.update.height) ;
                        break ; 
                    }

                    case GR_UPDATE_MOVE :
		    case GR_UPDATE_REPARENT :
                    {
                        Dprintf ("GR_UPDATE_MOVE or GR_UPDATE_REPARENT\n") ;
#ifdef ENABLE_NANOX_DIRECT_FB
			if (Clientfb) {
			    /* Get current window position and fb pointer*/
			    if (currently_fullscreen) 
				GrGetWindowFBInfo(FSwindow, &fbinfo);
			    else
				GrGetWindowFBInfo(SDL_Window, &fbinfo);
			}
#endif
                        break ; 
                    }
                    
                    default :
                        Dprintf ("unknown GR_EVENT_TYPE_UPDATE\n") ;
                        break ; 
                }
                break ; 
            }
                
            default :
            {
                Dprintf ("pump event default\n") ;
            }
        }

        GrCheckNextEvent (& event) ;
    }
}
Пример #7
0
void Note::set_pan_r( float pan )
{
	__pan_r = check_boundary( pan, PAN_MIN, PAN_MAX );
}
Пример #8
0
void Note::set_lead_lag( float lead_lag )
{
	__lead_lag = check_boundary( lead_lag, LEAD_LAG_MIN, LEAD_LAG_MAX );
}
Пример #9
0
void Note::set_velocity( float velocity )
{
	__velocity = check_boundary( velocity, VELOCITY_MIN, VELOCITY_MAX );
}
Пример #10
0
inline Site* Lattice::get_site_pointer(int x, int y)
{ Array2D<Site*>& as =  *this;
  check_boundary(x,y);
  return as(x,y);
}
Пример #11
0
inline void Lattice::set_site_pointer(int x, int y, Site* sp)
{ check_boundary(x,y);
  (*this)(x,y) = sp;
}
Пример #12
0
inline void Lattice::check_boundary(Site::Orientation& ort)
{ check_boundary(ort[0],ort[1]);}
Пример #13
0
	const target < dim - 1, index + 1, T > operator[](int x) const {
		int i = index + 1;
		check_boundary(x, x0[i], x1[i], b0[i], b1[i]);
		return target < dim - 1, index + 1, T > (data + (x - s0[i]) * sx[i], s0, sx, x0, x1, b0, b1);
	}
Пример #14
0
	const T& operator[](int x) const {
		int i = index + 1;
		check_boundary(x, x0[i], x1[i], b0[i], b1[i]);
		return *(data + (x - s0[i]) * sx[i]);
	}