player_t *player_create(void){ player_t *player = malloc(sizeof(player_t)); player->body = body_create(); player->sprite = sprite_create(); player->flashing = 0; player->body->rect->x = 205; player->body->rect->y = 128; player->body->rect->w = 30; player->body->rect->h = 38; player->fall_speed = 10.0; player->fall_accel = 0.35; player->ground_speed = 4.00; player->ground_accel = 0.25; player->ground_decel = 0.25; player->jump_force = -8.2; player->jump_brake = -3.0; player->face_dir = DIR_R; player->ctrl_dir = DIR_X; player->move_dir = DIR_X; return player; }
item_t *item_create(void){ item_t *item = malloc(sizeof(item_t)); item->type = 0; item->body = body_create(); item->sprite = sprite_create(); item->flags = 0; return item; }
ray_of_death_t *ray_of_death_ctor( vector_t *destination ) { ray_of_death_t *rod = malloc(sizeof(*rod)); hboolean collides; body_create((body_t*)rod, &Ray_of_death); rod->intensity = MAX_ROD_INTENSITY; vector_copy(rod->body.pos, hedgehog[local_hedgehog]->body.pos); vector_inc(rod->body.pos, &arm1_relative_pos); vector_sub(destination, rod->body.pos, &rod->direction); vector_mul(&rod->direction, 500/vector_len(&rod->direction), &rod->direction); collides = NULL != polygon_check_collision(map, rod->body.pos, &rod->direction, destination); vector_sub(destination, rod->body.pos, &rod->direction); if (!collides) { vector_mul(&rod->direction, 500/vector_len(&rod->direction), &rod->direction); } { int i; for(i = 0; i < 100; i++) { particle[i].pos.x = rod->body.pos->x + i * rod->direction.x / 100.0; particle[i].pos.y = rod->body.pos->y + i * rod->direction.y / 100.0; if (i % 2) { particle[i].color.red = 1; particle[i].color.green = 1; particle[i].color.blue = 1; } else { particle[i].color.red = 0; particle[i].color.green = 0; particle[i].color.blue = 1; } } } object_pool_push(&game_bodies, rod); return rod; }
RID PhysicsServerSW::space_create() { SpaceSW *space = memnew( SpaceSW ); RID id = space_owner.make_rid(space); space->set_self(id); RID area_id = area_create(); AreaSW *area = area_owner.get(area_id); ERR_FAIL_COND_V(!area,RID()); space->set_default_area(area); area->set_space(space); area->set_priority(-1); RID sgb = body_create(); body_set_space(sgb,id); body_set_mode(sgb,BODY_MODE_STATIC); space->set_static_global_body(sgb); return id; };