Exemplo n.º 1
0
void
page_up(void)
{
	int i;

	if (y <= 23)
	{
		y = 1;
		line = text;
		cursor_position();
		changed_pos = 1;
		return;
	}
	for (i = 0; i < 23; ++i)
	{
		up_common();
	}
	cursor_position();
}
Exemplo n.º 2
0
void
delete_line(void)
{
	if (!(*line))
	{
		return;
	}
	memmove(line, line + cxend + 1, (text + end) - (line + cxend) + 1);
	changed_lines = 1;
	if (y < yend) --yend;
	end -= cxend;
	cursor_position();
}
Exemplo n.º 3
0
void
page_down(void)
{
	int maks = yend - y;
	int count = maks < 23 ? maks : 23;
	int i;

	for (i = 0; i < count; ++i)
	{
		down_common();
	}
	cursor_position();
}
void BattleCommanderStateDirection::CheckPointingActor(void){
	Cursor3D* cursor3d(_accessor->GetCursor3D());
	if(!cursor3d->GetVisible()){
		_pointing_actor = nullptr;
		return;
	}

	D3DXVECTOR3 cursor_position(cursor3d->GetPosition());
	HitSphere cursor_hit(nullptr, cursor_position, 5.0f);
	
	//敵と味方を全部辿って、当たっている奴の中で一番近いやつを指す
	_pointing_actor = nullptr;
	float min_length(1000.0f);

	int player_count(_accessor->GetPlayerCount());
	for(int i=0; i<player_count; i++){
		BattleActor* player(_accessor->GetPlayer(i));
		Hit* player_hit(player->GetCursorHit());

		bool hit(player_hit->HitCheck(&cursor_hit));
		if(hit){
			D3DXVECTOR3 player_position(player->GetPosition());
			D3DXVECTOR3 v(player_position - cursor_position);
			float length(D3DXVec3Length(&v));
			if(min_length > length){
				min_length = length;
				_pointing_actor = player;
			}
		}
	}

	int enemy_count(_accessor->GetEnemyCount());
	for(int i=0; i<enemy_count; i++){
		BattleActor* enemy(_accessor->GetEnemy(i));
		Hit* enemy_hit(enemy->GetCursorHit());

		bool hit(enemy_hit->HitCheck(&cursor_hit));
		if(hit){
			D3DXVECTOR3 enemy_position(enemy->GetPosition());
			D3DXVECTOR3 v(enemy_position - cursor_position);
			float length(D3DXVec3Length(&v));
			if(min_length > length){
				min_length = length;
				_pointing_actor = enemy;
			}
		}
	}
}
Exemplo n.º 5
0
void drawGun ()
{
	aiVector2D xy;
	float x,y;
	xy=cursor_position();

	//coordinate in pixel con origine nel centro della finestra
	x=xy.x-100.0;
	y=xy.y-100.0;
	glPushMatrix();
	glScalef(0.05,0.05,0.05); //la rimpiccioliamo perche' e' enorme
	glTranslatef(0.f, -7.f, -17.2);
	pistola.applyGlMatrixTransformations(); //applico l'animazione
	glRotatef(-y*0.2, 1.0f, 0.0f, 0.f);
	glRotatef(-x*0.4, 0.0f, 1.0f, 0.f);
	glTranslatef(0.f, 0.f, -6.0f);
	glRotatef(90.0,0.0,1.0,0.0);
	recursive_render(gun0.pistola.scene,gun0.pistola.scene->mRootNode, 1.0);

	glPopMatrix();

}
Exemplo n.º 6
0
void GLUTMouse(int button, int state, int x, int y)
{
  // Invert y coordinate
  y = GLUTwindow_height - y;
  
  // Process mouse button event
  if ((button == GLUT_LEFT_BUTTON) && (state == GLUT_DOWN)) {
    // Check for double click
    static RNTime click_time;
    const RNScalar max_double_click_elapsed = 0.5;
    RNBoolean double_click = (click_time.Elapsed() < max_double_click_elapsed);
    click_time.Read();

    // Select closest point to cursor
    if (double_click) {
      selected_point = NULL;
      RNLength closest_distance = 10;
      R2Point cursor_position(x, y);
      for (int i = 0; i < all_points.NEntries(); i++) {
        TestPoint *point = all_points[i];
        const R3Point& world_position = point->position;
        R2Point screen_position = viewer->ViewportPoint(world_position);
        RNLength distance = R2Distance(screen_position, cursor_position);
        if (distance < closest_distance) {
          selected_point = point;
          closest_distance = distance;
        }
      }

      // Find closest points
      closest_point = NULL;
      nearby_points.Empty();
      if (selected_point) {
        if (max_nearby_points > 0) {
          kdtree->FindClosest(selected_point, min_nearby_distance, max_nearby_distance, max_nearby_points, nearby_points);
          closest_point = (nearby_points.NEntries() > 0) ? nearby_points.Head() : NULL;
          if (print_debug) printf("Found %d points\n", nearby_points.NEntries());
        }
        else {
          kdtree->FindAll(selected_point, min_nearby_distance, max_nearby_distance, nearby_points);
          closest_point = kdtree->FindClosest(selected_point);
          if (print_debug) printf("Found %d points\n", nearby_points.NEntries());
        }
      }
    }
  }

  // Remember button state 
  int b = (button == GLUT_LEFT_BUTTON) ? 0 : ((button == GLUT_MIDDLE_BUTTON) ? 1 : 2);
  GLUTbutton[b] = (state == GLUT_DOWN) ? 1 : 0;

  // Remember modifiers 
  GLUTmodifiers = glutGetModifiers();

  // Remember mouse position 
  GLUTmouse[0] = x;
  GLUTmouse[1] = y;

  // Redraw
  glutPostRedisplay();
}
Exemplo n.º 7
0
/**
 * Push one byte through the VT52 emulator.
 *
 * @param from_modem one byte from the remote side.
 * @param to_screen if the return is Q_EMUL_FSM_ONE_CHAR or
 * Q_EMUL_FSM_MANY_CHARS, then to_screen will have a character to display on
 * the screen.
 * @return one of the Q_EMULATION_STATUS constants.  See emulation.h.
 */
Q_EMULATION_STATUS vt52(const unsigned char from_modem, wchar_t * to_screen) {
    static unsigned char *count;
    static attr_t attributes;
    int new_row;
    int new_col;
    unsigned char from_modem2;

    /*
     * The VT52 spec only supports 7-bit ASCII. Strip the high bit off every
     * character.
     */
    from_modem2 = from_modem & 0x7F;

    DLOG(("STATE: %d CHAR: 0x%02x '%c'\n", scan_state, from_modem2,
          from_modem2));

vt52_start:

    switch (scan_state) {

    case SCAN_NONE:
        /*
         * ESC
         */
        if (from_modem2 == C_ESC) {
            save_char(from_modem2, to_screen);
            scan_state = SCAN_ESC;
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        /*
         * Only a few control chars to handle here.  CR and LF are in
         * emulation.c .
         */
        if (from_modem2 == 0x05) {

            DLOG(("Enquire\n"));

            /*
             * ENQ - transmit the answerback message.
             */
            qodem_write(q_child_tty_fd, get_option(Q_OPTION_ENQ_ANSWERBACK),
                        strlen(get_option(Q_OPTION_ENQ_ANSWERBACK)), Q_TRUE);
            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == 0x08) {

            DLOG(("Backspace\n"));

            /*
             * Backspace.
             */
            cursor_left(1, Q_FALSE);
            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == 0x09) {

            DLOG(("Tab\n"));

            /*
             * Tab.
             */
            while (q_status.cursor_x < 80) {
                cursor_right(1, Q_FALSE);
                if (q_status.cursor_x % 8 == 0) {
                    break;
                }
            }

            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == 0x7F) {

            DLOG(("Del\n"));

            /*
             * Del - consume but do nothing.
             */
            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        /*
         * Any other control characters.
         */
        if (iscntrl(from_modem2)) {
            /*
             * Consume but do nothing.
             */
            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        /*
         * This is a printable character.
         */
        *to_screen = map_character(from_modem2);
        return Q_EMUL_FSM_ONE_CHAR;

    case SCAN_Y_1:
        save_char(from_modem2, to_screen);
        scan_state = SCAN_Y_2;
        return Q_EMUL_FSM_NO_CHAR_YET;

    case SCAN_Y_2:
        /*
         * q_emul_buffer[0] = ESC
         * q_emul_buffer[1] = 'Y'
         */
        new_row = q_emul_buffer[2] - 32;
        new_col = from_modem2 - 32;
        if (new_row < 0) {
            new_row = 0;
        }
        if (new_col < 0) {
            new_col = 0;
        }

        DLOG(("Cursor position: %d %d\n", new_row, new_col));

        cursor_position(new_row, new_col);
        clear_state(to_screen);
        return Q_EMUL_FSM_NO_CHAR_YET;

    case SCAN_ESC:

        if (from_modem2 == 'A') {

            DLOG(("Cursor up\n"));

            cursor_up(1, Q_FALSE);
            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == 'B') {

            DLOG(("Cursor down\n"));

            cursor_down(1, Q_FALSE);
            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == 'C') {

            DLOG(("Cursor right\n"));

            cursor_right(1, Q_FALSE);
            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == 'D') {

            DLOG(("Cursor left\n"));

            cursor_left(1, Q_FALSE);
            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == 'E') {

            DLOG(("Erase entire screen\n"));

            /*
             * Cursor position to (0,0) and erase entire screen.
             */
            cursor_formfeed();
            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == 'F') {

            DLOG(("Graphics mode ON\n"));

            graphics_mode = Q_TRUE;
            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == 'G') {

            DLOG(("Graphics mode OFF\n"));

            graphics_mode = Q_FALSE;
            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == 'H') {

            DLOG(("Cursor home\n"));

            cursor_position(0, 0);
            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == 'I') {

            DLOG(("Reverse linefeed\n"));

            /*
             * Move up one column, inserting a line if already at the top.
             */
            if (q_status.cursor_y == 0) {
                scroll_down(1);
            } else {
                cursor_up(1, Q_FALSE);
            }

            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == 'J') {

            DLOG(("Erase to end of screen\n"));

            /*
             * Erase from here to end of screen.
             */
            erase_screen(q_status.cursor_y, q_status.cursor_x,
                         HEIGHT - STATUS_HEIGHT - 1, WIDTH - 1, Q_FALSE);

            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == 'K') {

            DLOG(("Erase to end of line\n"));

            /*
             * Erase from here to end of line.
             */
            erase_line(q_status.cursor_x, q_scrollback_current->length,
                       Q_FALSE);

            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == 'Y') {
            /*
             * Cursor position.
             */
            save_char(from_modem2, to_screen);
            scan_state = SCAN_Y_1;
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == 'Z') {

            DLOG(("DECID\n"));

            /*
             * Identify
             */

            /*
             * Note the VT100 and above will send <ESC>/Z, but the DECScope
             * manual claims the VT52 will send <ESC>/K if it does not have
             * an "integral electrolytic copier" (an internal printer that
             * used wet paper).
             */
            qodem_write(q_child_tty_fd, "\033/K", 3, Q_TRUE);

            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == '=') {

            DLOG(("Alternate keypad ON\n"));

            q_vt52_alternate_keypad_mode = Q_TRUE;
            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == '>') {

            DLOG(("Alternate keypad OFF\n"));

            q_vt52_alternate_keypad_mode = Q_FALSE;
            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == '[') {
            if (q_status.vt52_color == Q_TRUE) {
                /*
                 * Fall into SCAN_CSI only if VT52_COLOR is enabled.
                 */
                save_char(from_modem2, to_screen);
                scan_state = SCAN_CSI;
                return Q_EMUL_FSM_NO_CHAR_YET;
            }

            DLOG(("Hold screen mode ON\n"));

            q_status.hold_screen_mode = Q_TRUE;
            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == '\\') {

            DLOG(("Hold screen mode OFF\n"));

            q_status.hold_screen_mode = Q_FALSE;
            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        break;

    case SCAN_CSI:
        /*
         * We are only going to support CSI Pn [ ; Pn ... ] m a.k.a. ANSI
         * Select Graphics Rendition.  We can see only a digit or 'm'.
         */
        if (q_isdigit(from_modem2)) {
            /*
             * Save the position for the counter.
             */
            count = q_emul_buffer + q_emul_buffer_n;
            save_char(from_modem2, to_screen);
            scan_state = SCAN_CSI_PARAM;
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == 'm') {
            /*
             * ESC [ m mean ESC [ 0 m, all attributes off.
             */

            DLOG(("ANSI SGR: reset\n"));

            q_current_color =
                Q_A_NORMAL | scrollback_full_attr(Q_COLOR_CONSOLE_TEXT);

            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        /*
         * This means we entered HOLD SCREEN mode.
         */

        DLOG(("Hold screen mode ON\n"));

        q_status.hold_screen_mode = Q_TRUE;

        /*
         * Reprocess the character from the top.
         */
        clear_state(to_screen);
        goto vt52_start;

    case SCAN_CSI_PARAM:
        /*
         * Following through on the SGR code, we are now looking only for a
         * digit, semicolon, or 'm'
         *
         */
        if ((q_isdigit(from_modem2)) || (from_modem2 == ';')) {
            save_char(from_modem2, to_screen);
            scan_state = SCAN_CSI_PARAM;
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        if (from_modem2 == 'm') {

            DLOG(("ANSI SGR: change text attributes\n"));

            /*
             * Text attributes.
             */
            if (ansi_color(&attributes, &count) == Q_TRUE) {
                q_current_color = attributes;
            } else {
                break;
            }

            clear_state(to_screen);
            return Q_EMUL_FSM_NO_CHAR_YET;
        }

        break;
    }

    /*
     * This point means we got most, but not all, of a sequence.
     */
    q_emul_buffer[q_emul_buffer_n] = from_modem2;
    q_emul_buffer_n++;
    *to_screen = q_emul_buffer[q_emul_buffer_i];
    q_emul_buffer_i++;
    scan_state = SCAN_NONE;

    /*
     * Special case: one character returns Q_EMUL_FSM_ONE_CHAR.
     */
    if (q_emul_buffer_n == 1) {
        q_emul_buffer_i = 0;
        q_emul_buffer_n = 0;
        return Q_EMUL_FSM_ONE_CHAR;
    }

    return Q_EMUL_FSM_MANY_CHARS;
}
Exemplo n.º 8
0
void
down(void)
{
	down_common();
	cursor_position();
}
Exemplo n.º 9
0
void Render_Gioco(void){

	float tmp;
	
	pointer_pos=cursor_position();

	glutSetCursor(GLUT_CURSOR_NONE);
  
	glDisable(GL_FOG);

    drawSkybox();
	drawGun();
	drawBullet();
    drawScore();
	
    glPushMatrix();
    gluLookAt(0.f,0.f,3.f,0.f,0.f,-5.f,0.f,1.f,0.f);

	tmp = 0.0536414;
	glScalef(tmp, tmp, tmp);
    
	glTranslated(-xpos,0.0f,0.0f);
	
	//SPOSTAMENTO DELLA CAMERA:
	float xx=9,yy=0,zz=42;
	glTranslatef(xx,yy,zz);
	glRotatef(main_camera.getLocRot().y_rot,0.0f,1.0f,0.0f);

	glTranslatef(-xx,-yy,-zz);
	//translo la camera (in realta' translo tutto il resto)
	glTranslatef(main_camera.getLocRot().x, main_camera.getLocRot().y, main_camera.getLocRot().z);


	//Fog----------------------

	glFogi(GL_FOG_MODE, GL_LINEAR);					// Fog Mode
	GLfloat fogColor[4]= {0.6f, 0.5f, 0.3f, 1.0f};
	glFogfv(GL_FOG_COLOR, fogColor);				// Set Fog Color
	glFogf(GL_FOG_DENSITY, 0.45f);					// How Dense Will The Fog Be
	glHint(GL_FOG_HINT, GL_DONT_CARE);				// Fog Hint Value
	glFogf(GL_FOG_START, 3.5f);						// Fog Start Depth
	glFogf(GL_FOG_END, 6.0f);						// Fog End Depth
	glEnable(GL_FOG);								// Enables GL_FOG
	
	//-------------------------

	if(first == TRUE){
		scene_list_case=glGenLists(4);
		scene_list_target=glGenLists(10);
		lista_case(scene_list_case,level1_scene.scene,level2_scene.scene,level3_scene.scene,terreno_scene.scene);
		lista_target(scene_list_target,target_scene.scene);
		pos=scegli_pos(livello,livelli);
		first = FALSE;
	}

	if(m[pos].stato==2){
        m[pos]=reset_motion(m[pos]);
        pos=scegli_pos(livello,livelli);
    }
       
	ch=render_target(livello,scene_list_target,pos,livelli,m[pos],ch,t.v);
	render_case(livello,scene_list_case);

	if(!pause)t=count_time(t);

	m[pos]=scegli_mov(m[pos],livelli,pos,t.tempoi, t.v, ch_index,ch);
    
    glPopMatrix();

	drawPointer(pointer_pos);

	if(pause) DrawMenu(0,0,menuArray[5],true);

}