Пример #1
0
int IA::setPositionIA(sf::Time elapsedTimeInSecond, Map map){

    const glm::vec3 directionInitiale = glm::vec3(0.f, 0.f, -1.f);


    glm::vec3 vecdirecteur= glm::normalize(glm::toMat3(orientation)*directionInitiale);
    float x= map.trajet[getCursor()].x-(this->getPosition()[0]);
    float y= map.trajet[getCursor()].y-(this->getPosition()[1]);
    float z= map.trajet[getCursor()].z-(this->getPosition()[2]);
    int nb_noeud=map.getNbPoints();



   glm::vec3 kartToCheckpoint=glm::vec3(x,y,z);


   glm::vec2 kartToCheckpoint2 = glm::vec2(kartToCheckpoint.x, kartToCheckpoint.z);
   float angle = glm::orientedAngle(glm::normalize(kartToCheckpoint2), glm::normalize(glm::vec2(0.0f,-1.0f)));


   angleDirection = angle;

    mettreAJour(elapsedTimeInSecond);
    if (fabs(this->getPosition()[0]-map.trajet[getCursor()].x)<4.f && fabs(this->getPosition()[2]-map.trajet[getCursor()].z)<4.f){
        incrementCursor();
        setFalseTargetCalculate();
        if(getCursor()==nb_noeud-1){
            stopAvancer();
            arived=true;
        }
    }else{
        avance();
    }

}
Пример #2
0
// Puts a character to stdout
void putC(char c) {
	if(!in_kernel()) {
		write(STDOUT,&c,1);
	} else if(current_video_mode->visible)	{
		if(c != 1) {
			char a[] = { c, defaultStyle };
			video_write(a,2);
			incrementCursor();
		}
	}
}
Пример #3
0
void video_write_c(char * data) {
	make_atomic();
	char a[] = { *data, defaultStyle };
	char c = *data;

	if (c == '\r') {
		backSpace();
	} else if (c == '\n') {
		newLine();
	} else if (c == 0x0f || c == '\t') {
		if (getCursorX() % 4 == 0) {
			int i = 0;
			for (i = 0; i < 4; ++i) {
				putChar(' ');
				*a = ' ';
				video_write(a, 2);
			}
		} else
			while (getCursorX() % 4 != 0) {
				putChar(' ');
				*a = ' ';
				video_write(a,2);
				incrementCursor();
			}
	} else if (c != 0) {
		putChar(c);
		if(current_video_mode->visible)	{
			video_write(a,2);
			incrementCursor();
		} else {
			setCursor(FALSE);
			incrementCursor();
			setCursor(TRUE);
		}
	}
	release_atomic();
}
Пример #4
0
/**
 * Delegates the key up event to the buttons that represent the options of the menu.
 * <p>
 * Internally:
 *  Enter - invokes the mouse up callback for the button that is the current cursor position
 *  Arrow Up - Move decrements the cursor
 *  Arrow Down - Increments the cursor
 * @param event
 */
void MenuView::onKeyUp(SDL_Event event) {
    // Enter activates the internal button
    if (event.key.keysym.sym == SDLK_RETURN) {
        buttons[getCursorIndex()]->onMouseUp(event);

    // Decrement the Cursor on UP
    } else if (event.key.keysym.sym == SDLK_UP) {
        decrementCursor();

    // Increment the Cursor on DOWN
    } else if (event.key.keysym.sym == SDLK_DOWN) {
        incrementCursor();
    }

    BaseView::onKeyUp(event);
}
Пример #5
0
void printf(const char * msg, ...)
{
	unsigned char *memory = (unsigned char *)VIDEO_MEMORY;
	unsigned short i = 0;
	char c = ' ';

	unsigned char *p = (char*)&msg + sizeof(char*);
	while(1)
	{
		c = *(msg+(i++));
		if(c == '%')
		{
			char specifier = *(msg+(i++));
			switch(specifier)
			{
				case 'c':
					c = (unsigned char)*((int*)p);
					p += sizeof(int);
				break;
				case 'u':
					printNumber((unsigned int)*((int*)p), 10);
					p += sizeof(int);
					continue;
				case 'x':
					printNumber((unsigned int)*((int*)p), 16);
					p += sizeof(int);
					continue;
				case 's':
					printString((const unsigned char*)*((int*)p));
					p += sizeof(int);
					continue;
				default:
				break;
			}
		}
		else if(c == '\n')
		{
			nextLine();
			continue;
		}
		if(c == 0)
			break;
		putch(c);
		incrementCursor();
	}
}
Пример #6
0
void mgsCooperSymbols::update(){
  if (bNeedRedrawFullScene) {
    frame.begin();
    ofClear(0);
    frame.end();
  }
  if(bNeedsRedraw){
    if(animated){
      drawScene();
      incrementCursor();
    } else {
      bNeedsRedraw = false;
    }
  }
  if (bNeedRedrawFullScene) {
    drawFullScene();
    bNeedRedrawFullScene = false;
  }
}
Пример #7
0
/**
 * Create the up and down arrays of the menu.
 */
void MenuView::createArrows() {
    const auto arrowHeight = 5;

    SDL_Rect upRect = {getX(), getY(), getWidth(), arrowHeight};
    upArrowView = new ImageView(nullptr, upRect, ANIMATION_TYPE_ARROW_UP);
    upArrowView->setColor(0x000000);
    upArrowView->setHorizontalAlignment(HorizontalAlignment::CENTER);
    upArrowView->setVerticalAlignment(VerticalAlignment::CENTER);
    upArrowView->setOnMouseUpCallback([this](SDL_Event event) {
        decrementCursor();
    });


    SDL_Rect downRect = {getX(), getY() + getHeight() - arrowHeight, getWidth(), arrowHeight};
    downArrowView = new ImageView(nullptr, downRect, ANIMATION_TYPE_ARROW_DOWN);
    downArrowView->setColor(0x000000);
    downArrowView->setHorizontalAlignment(HorizontalAlignment::CENTER);
    downArrowView->setVerticalAlignment(VerticalAlignment::CENTER);
    downArrowView->setOnMouseUpCallback([this](SDL_Event event) {
        incrementCursor();
    });
}
Пример #8
0
void putchar(char c)
{
	putch(c);
	incrementCursor();
}