示例#1
0
void Marciano::actualizar(int movimiento){ //usa movimiento para saber a donde se tiene que mover
    if(movimiento==0)
        mover(0,-movimientoMarcianoY,margenPantalla);
    else
        mover(movimiento*movimientoMarcianoX,0, margenPantalla);

    if(defTextura)
        defTextura=false;
    else
        defTextura=true;
}
示例#2
0
bool Misil::update(float dt)
{
	if(!mundo->puedeActualizar()) //Si es cliente
	{
		//Para saber a quien asesino
		std::list<int>::iterator it;
		for(it = mundo->id_quitar.begin(); it != mundo->id_quitar.end(); ++it)
		{
			if((*it) == SubID)
			{
				mundo->id_quitar.remove(SubID);
				explotar(); //Explota este misil
				break;
			}
			/*
			else if ((*it) < SubID-10) //si es menor para borrar posibles casos no tomados
			{
				mundo->id_quitar.remove(SubID);
			}*/
		}
	}

	sprite->update((int)(dt*1000));

	if(explotando)
	{
		return false;
	}
	else
	{
		mover(velocidad*dt);
		
		int idcol = mundo->revisarColision(collisionMisil, dueño);
		
		if(idcol >= 0)
		{
		
			if(idcol < 10)
			{
				Tanque *temp = mundo->getTanqueID(idcol);

				temp->modSalud(getDanio());
				
				if(temp->estaMuerto())
				{
					mundo->getTanqueID(dueño->getID())->subirScore();
			//		temp->Matar(CL_System::get_time(),5000);
					mundo->matarTanque(temp->getID(),5000);
				}
			
					mundo->actualiza_saludyscore(); 
			}
			
			mundo->matarMisil(SubID);
			explotar();
		}
	}

	return !(Posicion.x < -100 || Posicion.y < -100 || Posicion.x > mundo->get_gc().get_width() + 100 || Posicion.y > mundo->get_gc().get_height() + 100);
}
示例#3
0
int main(int ac, char **str)
{
  struct s_list *stru;
  char move;
  int x;
  int y;
  x = 0;
  y = 0;
  int grille[10][10] =
{
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,0,0,0,0,0,0,0},

};
    while (grille[9][9] == 0)
    {
      make_tab(grille);
      move = getch();
      mover(move, grille, &x, &y);
      system("clear");
    }

  return(0);
}
示例#4
0
void Sparkman::update(float tiempo, Mapa *mapa){
  tiempo_pasado += tiempo;
  mover(tiempo, mapa);
  if (tiempo_pasado < TIEMPO_ACCION){
    return;
  }
  //atacar
}
/**
 *  Advances the simulation by the provided time step. For this assignment,
 *  you may assume that the first registered object is a "sun" and its
 *  position should not be affected by any of the other objects.
 */
void Universe::stepSimulation(double seconds) {
    std::vector<Object*> tmp;
    MoverVisitor mover(seconds);
    for (size_t i = 0; i < objects_.size(); ++i) {
        objects_[i]->accept(mover);
        tmp.push_back(mover.getObject());
    }
    swap(tmp);
}
void MyThread::run(){
    stop = true;

    while(stop){
        mover();
        emit updateGUI(ID, x,y);
        usleep(sono);
    }
}
示例#7
0
/* Note: Hide the unit in its current location,
 * but don't actually remove it until the move is done,
 * so that while the unit is moving status etc.
 * will still display the correct number of units.
 */
void move_unit(const std::vector<map_location>& path, unit_ptr u,
               bool animate, map_location::DIRECTION dir,
               bool force_scroll)
{
	unit_mover mover(path, animate, force_scroll);

	mover.start(u);
	mover.proceed_to(u, path.size());
	mover.finish(u, dir);
}
示例#8
0
int main(void)
{

  crearMatriz();
  if(mover(1,2,2))
    printf("Aca ta");
  else
    printf("deadlock jaja");
  mostrar();
  return 0;
}
示例#9
0
void mover(int * tablero, int i,int j, int cont) {

    caminos[cont] = i+","+j;
    if (x>N || y>N) {
        printf("Ya llegue a mi destino");
        kill(tid,SIGUSR1);

    }
    else {

        if(tablero[i][j+1]==0) {
            printf("Avanazo el camnino hacia la derecha");
            mover(tablero,i,j+1,++cont);
        }
        if(tablero[i+1][j]==0) {
            printf("Avanzo el camnino hacia abajo");
            mover(tablero,i+1,j,++cont);
        }
    }

}
示例#10
0
//interpretacao e execucao de comando
//forma <pilha_origem>,<posicao_origem>,<pilha_destino>, em numero
int YUKON_CLI::interpretar(string cmd, string &msg){
	
	if (cmd == "")
		return 2;
	if (cmd=="fechar"||cmd=="exit")
		return 3;
	if (cmd=="novojogo"||cmd=="reset")
		return 4;
	
	int origemp;	//pilha de origem
	int origemc;	//carta de origem
	int destino;	//pilha de destino
	
	unsigned int posvirg1 = cmd.find(",");	//posicao da 1a virgula
	unsigned int posvirg2 = cmd.rfind(",");	//posicao da 2a (ultima) virgula
	if ((posvirg1 != string::npos)&&(posvirg2 != string::npos)){	//se foi obtido posicao das duas virgulas, faca:
		origemp = atoi((cmd.substr(0,posvirg1)).data());
		origemc = atoi((cmd.substr(posvirg1+1,posvirg2-posvirg1)).data());
		destino = atoi((cmd.substr(posvirg2+1,cmd.size()-posvirg2)).data());
		
	}
	else{
		cout << "formato de comando incorreto!" << endl;
		return 1;
	}
	
	if(destino==8)
		cout <<"Movendo carta "<<origemc<<" da pilha "<<origemp<<" para a fundamento " << endl;
	else
		cout <<"Movendo carta "<<origemc<<" da pilha "<<origemp<<" para a pilha "<<destino << endl;
	
	if (origemp>7||origemp<0||destino>8||destino<0) {
		cout << "origem ou destino e incorreto!" << endl;
		return 1;
	}
	if (getMonteTam(origemp)<0)
		cout << "monte nao possui nenhuma carta!" << endl;
	if(origemp == destino)
		cout<< "Coluna de origem igual coluna de destino" << endl;
	else
		if (destino==8){
			if(!moverParaFundacao(origemp, origemc))
				cout << "Esse movimento não é possível." <<  endl;
		} else {
			if (!mover(origemp, origemc, destino))
				cout << "Esse movimento nao é possivel."<<endl;
		}
		
		/*cout << "pos1=" << posvirg1 << endl;
		 * cout << "pos2=" << posvirg2 << endl;*/
		return 0;
}
示例#11
0
int movimentar(Pilha * pino1, Pilha * pino2, Pilha * pino3){    
    char movimento[3] = {0,0,'\0'};
    printf("Digite o proximo movimento: \n");
    fflush(stdin);
    scanf("%c%c", movimento, movimento + 1);
    switch(movimento[0]){
        case 'A':
            switch(movimento[1]){
                case 'B':
                    if(mover(pino1, pino2) == 0)
                        return 4;
                    break;
                case 'C':
                    if(mover(pino1, pino3) == 0)
                        return 4;
                    break;
                default:
                    printf("Movimento invalido!\n");
                        return 4;
            }
            break;
        case 'B':
            switch(movimento[1]){
                case 'A':
                    if(mover(pino2, pino1) == 0)
                        return 4;
                    break;
                case 'C':
                    if(mover(pino2, pino3) == 0)
                        return 4;
                    break;
                default:
                    printf("Movimento invalido!\n");
                    return 4;
            }
            break;
        case 'C':
            switch(movimento[1]){
                case 'A':
                    if(mover(pino3, pino1) == 0)
                        return 4;
                    break;
                case 'B':
                    if(mover(pino3, pino2) == 0)
                        return 4;
                    break;
                default:
                    printf("Movimento invalido!\n");
                    return 4;
                }
                break;
        default:
            printf("Movimento invalido!\n");
            return 4;
            break;         
    }
    return 5;
}
示例#12
0
int main(int argc, char *argv[]){

    Serpiente serpiente;
    serpiente.longitud = L0;
    struct TCoordenada movimiento = {0, -1};
    int user_input;

    srand(time(NULL));

    rellena(&serpiente);

    initscr();             // Crea una matriz para pintar
    halfdelay(3);          // Hace que getch espere 3 decimas de segundo
    keypad(stdscr, TRUE);  // Vale para leer las flechas
    noecho();              // Para que no se vea el caracter pulsado.
    curs_set(0);           // No se ve el cursor.
    while((user_input = getch()) != ESC){

        switch(tolower(user_input)){
            case 'q':
            case KEY_UP:
                movimiento.x = 0;
                movimiento.y = -1;
                break;
            case 'a':
            case KEY_DOWN:
                movimiento.x = 0;
                movimiento.y = 1;
                break;
            case 'o':
            case KEY_LEFT:
                movimiento.x = -1;
                movimiento.y = 0;
                break;
            case 'p':
            case KEY_RIGHT:
                movimiento.x = 1;
                movimiento.y = 0;
                break;

        }
        mover( movimiento, &serpiente);
        muestra(&serpiente);
    }
    endwin();              // Libera la matriz.

    return EXIT_SUCCESS;
}
示例#13
0
文件: funcoes.c 项目: booom/Confeitos
//L� AS COORDENADAS E VERIFICA SE � VALIDO
int leitura (void)
{
    scan = verifica();
    //PAR�METROS PARA SER V�LIDO
    if(scan!=3 || x<=0 || y<=0)
    {

        msg(1);
    }
    else
    {
        mover(x, y, sentido);
    }

    return 0;
}
static void
move_cb (SortFlowState *state,
	 gboolean (*mover) (GtkTreeModel *, GtkTreeIter *))
{
	GtkTreeIter iter, this_iter;

	if (!gtk_tree_selection_get_selected (state->selection, NULL,
					      &this_iter))
		return;

	iter = this_iter;
	if (!mover (GTK_TREE_MODEL(state->model), &iter))
		return;

	gtk_list_store_swap (state->model, &this_iter, &iter);
	cb_sort_selection_changed (state);
}
示例#15
0
int main(int argc, char **argv)
{
    // We use the GLUT utility to initialize the window, to handle the input and to interact with the windows system
    glutInit(&argc, argv);
    glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
    glutInitWindowSize(screen_width,screen_height);
    glutInitWindowPosition(0,0);
    glutCreateWindow("SpaceJump");
    glutFullScreen();
    glutDisplayFunc(display);
    glutReshapeFunc (resize);
    glutKeyboardFunc (keyboard);
    glutSpecialFunc (keyboard_s);
    mover(1);
    sky[0] = LoadTexBMP("planetcropped_scaled_trans.bmp");
    texture[0] = LoadTexBMP("floor2.bmp");
    texture[1] = LoadTexBMP("over.bmp");
    texture[2] = LoadTexBMP("spacejump_start.bmp");
    texture[3] = LoadTexBMP("brickwall.bmp");

    //  Initialize audio
    if (Mix_OpenAudio(44100,AUDIO_S16SYS,2,4096)) Fatal("Cannot initialize audio\n");

    blt = Mix_LoadMUS("bullet.ogg");

    if (!blt) Fatal("Cannot load bullet.ogg\n");

    eng = Mix_LoadMUS("engine.ogg");

    if (!eng) Fatal("Cannot load engine.ogg\n");

    blast = Mix_LoadMUS("explosion.ogg");

    if (!blast) Fatal("Cannot load explosion.ogg\n");

    Init_star();
    init();


    width =  glutGet(GLUT_WINDOW_WIDTH);
    height = glutGet(GLUT_WINDOW_HEIGHT);

    glutMainLoop();

    return(0);
}
示例#16
0
文件: sa.c 项目: cloooska/BACP
pSol SA(pSol inicial,malla m,pCurso cursos)
{
	limpiarGreedy(cursos);
	int MaxCrSol=maxCreditosSolucion(inicial);
	int T=MaxCrSol,t=1;
	srand(time(NULL));
	int cantPer = getCantPeriodos(m);
	pSol nueva=duplicarSol(inicial);
	pSol mejor=duplicarSol(inicial);
	pSol actual=duplicarSol(inicial);
	double deltaEval,prob;
	while(maxCreditosSolucion(mejor) > mediaCreditos(cursos,m) && exp(-deltaEval/T)!=1)
	{
		while(t%100!=0)
		{
			//printf("t= %d\n", t%100);
			prob = rand()%1000000;
			prob=prob/1000000;
			nueva=mover(nueva,cantPer,cursos);
			//mostrar(nueva);
			deltaEval=maxCreditosSolucion(nueva) - maxCreditosSolucion(actual);
			if(deltaEval<0)
			{
				printf("entre a mejor\n");
				mejor=duplicarSol(nueva);
				mostrar(mejor);
			}
			else
			{
				
				if(exp(-deltaEval/T) <= prob)
				{
					actual=nueva;
					//printf("entre a peor %f < %f\n",exp(-deltaEval/T),prob);
				}
			}
			t++;
		}
		//printf("T= %d\n", T);
		t=1;
		T++;
	}
	return mejor;
}
示例#17
0
void keyboard (unsigned char key, int x, int y)
{
    switch (key)
    {
        case 27:
            exit(0);
            break;

        case 13:
            if(bullet)
            break;
            Mix_PlayMusic(blt,0);
            bullet = 1;
            bx = px;
            by = py-20;
            bz = pz-100;
            break;
            break;
        case 'x':
        case 'X':
            enter = 0;
            break;

        case 'r':
        case 'R':
            score = 0;
            over = 0;
            enemy = 1;
            space = 1;
            px = 0;
            py = -10;
            break;

        case ' ':
            if(jump)
                    break;
            jump = 1;
            break;
    }

    th %= 360;
    ph %= 360;
    mover(-1);
}
示例#18
0
static int mover(int n,int x,int y)
{
  int i,u,v;
  tablero_virtual[x][y]=n;
  if(n==(CELDAS*CELDAS))
      return CIERTO;
  else {
    for(i=0;i<N_SALTOS;i++) {
      u=x+dx[i];
      v=y+dy[i];
      if(tablero_virtual[u][v]==0) {
        if(mover(n+1,u,v))
          return CIERTO;
      }
   }
  }
  tablero_virtual[x][y]=0;
  return FALSO;
}
示例#19
0
Cod_Error actualizarInfo(Info * laInfoActual, Info * laInfoRespaldo, char jugada)
{
	if (jugada == UNDO)
	{
		copiarInfo(laInfoActual, laInfoRespaldo);
		laInfoActual->undos -= 1;
		laInfoActual->undoPosible = FALSE;
		return OK;
	}
	else
	{
		Cod_Error hubo_error;
		copiarInfo(laInfoRespaldo, laInfoActual);
		mover(laInfoActual, jugada);
		hubo_error = ponerFicha(laInfoActual, jugada);
		laInfoActual->undoPosible = TRUE;
		return hubo_error;
	}
}
示例#20
0
int process_move() {
	system("cls");
	if ((x == 0) && (move == 'a')) {
		printf("왼쪽으로 더 이상 움직일 수 없습니다.\n");
	}
	else if ((x == N1 - 1) && (move == 'd')) {
		printf("오른쪽으로 더 이상 움직일 수 없습니다.\n");
	}
	else if ((y == 0) && (move == 'w')) {
		printf("위로 더 이상 움직일 수 없습니다.\n");
	}
	else if ((y == N2 - 1) && (move == 's')) {
		printf("아래로 더 이상 움직일 수 없습니다.\n");
	}
	else {
		printf("\n");
		mover();
	}

}
示例#21
0
int main(){
	srand((unsigned) time(NULL)); //para alterar o preenchimento da matriz
	matriz *m = iniciaMatriz();
	setor *jogador = iniciaSetor();
	pilha *p = iniciaPilha();
	preencheMatrizCom01(m);
	imprimeMatriz(m);
	comecaJogo(jogador);
	printf("Posição do jogador : x = %d y = %d\n", getXJogador(jogador), getYJogador(jogador));
	while(!fimDeJogo(jogador)){
		mover(jogador, m, p);
	}
	if(getXJogador(jogador) == 9&& getYJogador(jogador) == 9)	//jogo bem sucedido
		imprimeMatriz(m);
	//imprime o caminho
	free(m);
	free(jogador);
	free(p);
	return 0;
}
示例#22
0
void CManageVariableDlg::OnBnClickedMovedown()
{
	POSITION listpos = m_List.GetFirstSelectedItemPosition();
	int sel = m_List.GetNextSelectedItem(listpos);

	if (sel == -1 || sel >= m_List.GetItemCount() - 1) return;

	PrivateValue temp = pType->m_PrivateValues[sel];
	pType->m_PrivateValues.erase(pType->m_PrivateValues.begin() + sel);
	pType->m_PrivateValues.insert(pType->m_PrivateValues.begin() + (sel + 1), temp);

	PrivateVariableMover mover(sel, false);	// down
	ForEachObjectInstance(pType, application, mover);
	
	RefreshVariablesList();

	if (sel < m_List.GetItemCount() - 1) sel++;

	m_List.SetItemState(sel, LVIS_SELECTED, LVIS_SELECTED);
}
示例#23
0
文件: RESTAUM.C 项目: rhagni/ololo
int main(int argc, char *argv[])
{
	unsigned short int c;
	inicia();
	imprime();
	while(1)
	{
		if(kbhit())
		{
			c = getch();
			mover(c);
		}
		if(z % 4681 == 0)
		{
			print(x, y, ((z % 9362 == 0) ? (s ? blink : unblink) : m[t[x][y]]));
		}
		z++;
	}
	getch();
	return 1;
}
示例#24
0
int main(int argc, char *argv[]){

    struct Coordenadas jugador = {1, 1}; //posicion inicial del jugador
    char tablero[FILAS][COL];
    int user_input;

    initscr();
    halfdelay(1);
    keypad(stdscr, TRUE);
    noecho();
    curs_set(0);
    mapa(tablero);
    inicializar(tablero);
    while ((user_input = getch()) != ESC){	
	mover(user_input, &jugador, tablero);
	pintar_mapa(tablero, jugador);
    }
    endwin();
    return EXIT_SUCCESS;

}
示例#25
0
void hacerMovimiento(t_personaje *personaje) {
	if(!tieneRecursoActual(personaje)) {
		leerSiguienteRecurso(personaje);
		if(!personaje->nivel_actual) {
			return;
		}
	}

	log_info(logger, "Posicion del recurso: (%d, %d), mi posicion: (%d, %d).", personaje->recursoActual->pos->x, personaje->recursoActual->pos->y, personaje->pos->x, personaje->pos->y);

	char* recursoBloqueante = "";

	mover(personaje);
	if(samePoint(personaje->pos, personaje->recursoActual->pos)) {
		recursoBloqueante = pedirRecurso(personaje);
		log_debug(logger, string_equals_ignore_case(recursoBloqueante, "0") ? "Recurso otorgado" : "Bloqueado! Recurso no otorgado");
	}

	t_mensaje* requestMovimiento = mensaje_create(MOVER, pointAsString(*personaje->pos));
	socketSend(personaje->connNivel, requestMovimiento, handleConnectionError);
	pedirSiguienteTurno(personaje, recursoBloqueante);
}
示例#26
0
void Game::update(int a)
{
	if (a == 1){
		preparar();
	}
	else{
		if(asteroides.size() >= 0){
			for (int i = 0; i < asteroides.size(); i++){
				if (!asteroides[i].estaDentro())
				{
					asteroides.erase(asteroides.begin() + i);	
					addAsteroide();
					addAsteroide();
				}
			}
		}
		hayCollision();
		mover();
	}

	
}
int compactar() {

	log_info(logger ,"[COMPACTACIÓN].");

	while(hayFragmentacion()){

		// 1) busco primer posicion libre en bitmap
		int posLibre = buscarPosLibreEnBitMap();
		if(posLibre == ERROR) return ERROR; // no hay pagina libre

		// 2) busco primer posicion ocupada desde la libre en bitmap
		int arrancaProceso = buscarPosOcupadaDesdeLaUltimaLibreEnTablaDeBitMap(posLibre);
		if(arrancaProceso == ERROR) return ERROR; // no hay pagina ocupada desde la libre

		// 3) cuento la cantidad de paginas del proceso del bitmap ocupado
		int cantidadDePaginasDelProceso = cuantasPaginasTieneElProceso(arrancaProceso);

		// 4) muevo todas las paginas del proceso
	    mover(posLibre, arrancaProceso, cantidadDePaginasDelProceso);
	}

	return TRUE;
}
示例#28
0
int main(int argc, const char * argv[]) {

    int myid, numprocs, nh, tid;
    int tablero[N][N];
    char hostname[MPI_MAX_PROCESSOR_NAME];
    int  longitud;


    srand(time(NULL));

    for(i=0; i<N; ++i) {
        for(j=0; j<N; ++j) {
            tablero[i][j]= rand() % 2;
        }
    }

    MPI_Init(&argc,&argv);
    MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
    MPI_Comm_rank(MPI_COMM_WORLD,&myid);
    MPI_Get_processor_name(hostname, &longitud);


    MPI_Bcast(tablero, n, MPI_INT, 0, MPI_COMM_WORLD);
    #pragma omp parallel private(tid)
    {

        #pragma omp for
        for(i=0; i<5; ++i)[ {
            mover(tablero,0,i,0);
        }

        signal(SIGUSR1, manejador);
    }

    MPI_Finalize();
    return 0;
}
示例#29
0
void
ObjectGridRespawnMover::Move(GridType &grid)
{
    TypeContainerVisitor<ObjectGridRespawnMover, GridTypeMapContainer > mover(*this);
    grid.Visit(mover);
}
示例#30
0
 void HotSpotDriver::Update(double dt)
 {
    AttachmentMover mover( *mModel );
    std::for_each( mHotSpots.begin(), mHotSpots.end(), mover);
 }