void Map::eat_egg(int x, int y) { // Only eat egg if its actually an egg! if (get_tile_type(x, y) != tile_egg && get_tile_type(x, y) != tile_powerup) return; set_tile_type(x, y, tile_empty); eggs_left--; }
void Map::eat_trail(int x, int y) { // Only eat trail if its a trail. if (get_tile_type(x, y) != tile_trail) return; set_tile_type(x, y, tile_empty); }
void Map::leave_trail(int x, int y) { // Only leave trail if tile doesn't contain something else. if (get_tile_type(x, y) != tile_empty) return; set_tile_type(x, y, tile_trail); }
void handle_collisions_thing(struct thing *t) { coord tmp; //tmp.x = TILE_SIZE / 2 + t->pos.x + t->vel.x + t->accel.x; //tmp.y = TILE_SIZE + t->pos.y + t->vel.y + t->accel.y; //TODO should check for grounding first /* if( t->vel.y >= 0 ){ //printf("Should fall\n"); //if( t->isjumping ){ if( t->isjumping && get_tile_type( &tmp ) > 0x00 ){ t->isjumping = false; t->vel.y = 0; t->accel.y = 0; //Should correct position coord *tmp2 = get_nearest_tile(&tmp); //t->pos.x = tmp2->x * TILE_SIZE; t->pos.y = tmp2->y * TILE_SIZE; }else{ if( !t->isjumping && get_tile_type( &tmp ) == 0x00){ printf("Should fall\n"); t->isjumping = true; t->vel.y = 0; t->accel.y = 1; } } }else{ if( !t->isjumping && get_tile_type( &tmp ) == 0x00 ){ t->isjumping = true; t->vel.y = 0; t->accel.y = 1; } }*/ tmp.x = (TILE_SIZE / 2) + t->pos.x + t->vel.x + t->accel.x; tmp.y = TILE_SIZE + t->pos.y + t->vel.y + t->accel.y; /* if( t->isjumping ){ if( get_tile_type( &tmp ) > 0x00 ){ t->isjumping = false; t->vel.y = 0; t->accel.y = 0; //Should correct position coord *tmp2 = get_nearest_tile(&tmp); //t->pos.x = tmp2->x * TILE_SIZE; t->pos.y = tmp2->y * TILE_SIZE; } }else{ if( get_tile_type( &tmp ) == 0x00 ){ printf("Should fall\n"); t->isjumping = true; t->vel.y = 0; t->accel.y = 1; } } */ if( t->vel.y > 0 ){ if( t->isjumping && get_tile_type( &tmp ) > 0x00 ){ t->isjumping = false; t->vel.y = 0; t->accel.y = 0; //Should correct position coord *tmp2 = get_nearest_tile(&tmp); //t->pos.x = tmp2->x * TILE_SIZE; t->pos.y = (tmp2->y * TILE_SIZE) + 1; } }else if( t->vel.y == 0 ){ tmp.x = (TILE_SIZE / 2) + t->pos.x + t->vel.x + t->accel.x; tmp.y = TILE_SIZE + t->pos.y + t->vel.y + t->accel.y; if( get_tile_type( &tmp ) == 0x00 ){ printf("Should fall\n"); t->isjumping = true; t->vel.y = 1; t->accel.y = 1; } }else{ tmp.x = (TILE_SIZE / 2) + t->pos.x + t->vel.x + t->accel.x; tmp.y = t->pos.y + t->vel.y + t->accel.y; //Top collision if( t->isjumping && get_tile_type( &tmp ) > 0x00 ){ t->isjumping = false; t->vel.y = 0; t->accel.y = 0; //Should correct position tmp.y = TILE_SIZE + t->pos.y + t->vel.y + t->accel.y; coord *tmp2 = get_nearest_tile(&tmp); //t->pos.x = tmp2->x * TILE_SIZE; t->pos.y = (tmp2->y * TILE_SIZE) + 1; } } //Top collisions //Left collisions //Right collisions //TODO collisions should be handled according to moving direction //tmp.x = TILE_SIZE + t->pos.x + t->vel.x + t->accel.x; //tmp.y = TILE_SIZE + t->pos.y + t->vel.y + t->accel.y; /* if( get_tile_type(&tmp) > 0x00 ){ t->vel.x = 0; t->accel.x = 0; t->vel.y = 0; t->accel.y = 0; } */ //Right movement if( t->vel.x > 0 ){ printf("Moving Right\n"); tmp.x = TILE_SIZE + t->pos.x + t->vel.x + t->accel.x; tmp.y = (TILE_SIZE / 2) + t->pos.y + t->vel.y + t->accel.y; if( get_tile_type(&tmp) > 0x00 ){ t->vel.x = 0; t->accel.x = 0; } }else if( t->vel.x < 0 ){ //Left movement printf("Moving Left\n"); tmp.x = t->pos.x + t->vel.x + t->accel.x; tmp.y = (TILE_SIZE / 2) + t->pos.y + t->vel.y + t->accel.y; if( get_tile_type(&tmp) > 0x00 ){ t->vel.x = 0; t->accel.x = 0; } } //Jump movement if( t->vel.y < 0 ){ }else if( t->vel.y < 0 ){ //Falling movement } }