void updateScreen(AppState* App) { if(App->puck->posx == App->player1->posx) { if( App->puck->posy < App->player1->posy + App->player1->size/2 +1 && App->puck->posy > App->player1->posy - App->player1->size/2-1 ) { App->puck->vx = abs(App->puck->vx); App->puck->vy += App->player1->vy; } } if(App->puck->posx == App->player2->posx) { if( App->puck->posy < App->player2->posy + App->player2->size/2+1 && App->puck->posy > App->player2->posy - App->player2->size/2-1 ) { App->puck->vx = - abs(App->puck->vx); App->puck->vy+=App->player2->vy; } } //rprintf("pong: p1y %d p2y %d puckx %d pucky %d \n",App->player1->posy,App->player2->posy,App->puck->posx,App->puck->posy); moveActor(App,App->player1,cycle); moveActor(App,App->player2,cycle); moveActor(App,App->puck,puck); }
/** * Calls the moveActor function, but uses relative positions instead of absolute. */ void ActorManager::moveActorRel(actor::ActorBase * actor,const vec2 pos){ vec2 absPos = actor->getPosition(); absPos += pos; moveActor(actor,absPos); }
void walkActorPath(character *actor) { int nx, ny; if (TCOD_path_size(actor->path)) { TCOD_path_walk(actor->path, &nx, &ny, true); moveActor(actor, nx - actor->x, ny - actor->y); } }