KittenManager *
load_kittens(Entity * player, Level world, TimeTracker * time, EntitySet * others)
{
	KittenManager * litter = (KittenManager *) zone(sizeof(KittenManager));

	Kitten * kitty = (Kitten *) zone(sizeof(Kitten));

	Entity * mother = load_entity(KITTEN_PATH, kitty, &kitten_move, &kitten_destructor);

	kitty->body = mother;
	kitty->player = player;
	kitty->world = world;
	kitty->time = time;
	kitty->others = others;
	kitty->count_ptr = &litter->kitten_count;
	kitty->claw = Mix_LoadWAV(CLAW_PATH);

	litter->mother = mother;
	litter->child = kitty;
	litter->kitten_count = 0;
	litter->spawn_timer = new_expirer(SPAWN_FREQUENCY);

	entity_set_speed(mother, 6);

	return litter;
}
Exemplo n.º 2
0
ret_state _bridge_modloader_require(void ** addrp, const char * mod_name) {
    typedef ret_state (* getter)(void **);
    std::string& dylib_path = * local_dylib_path(mod_name);
    void * entity = entities->get(mod_name);
    void * dylib  = dylibs->get(dylib_path);
    if (dylib == nullptr) {
        dylib = load_dylib(dylib_path.c_str());
        dylibs->set(dylib_path, dylib);
    }
    if (entity == nullptr) {
        entity = load_entity(dylib);
        entities->set(mod_name, entity);
    }
    CALL_MODULE_INITIALIZER(entity);
    *addrp = entity;
    return ES_NORMAL;
}
Exemplo n.º 3
0
//second parameter is ignored
void* load_level(PACKFILE *file,int size) {
     int i;
     LEVEL *data;
     data = calloc(1,sizeof(LEVEL));
     //read small stuff and malloc things
     data->sizey = pack_igetw(file);
     data->sizex = pack_igetw(file);
     data->length = data->sizex * data->sizey;
     printf("sizex=%d, sizey=%d, length=%d", data->sizex, data->sizey, data->length);
     data->map = calloc(data->length,1);
     data->bgtype = pack_getc(file);
     if (data->bgtype == 1) for(i = 0;i < 600;i++) data->lines[i] = makecol24(pack_getc(file),pack_getc(file),pack_getc(file));
     data->entitycnt = pack_igetw(file);
     data->entities = calloc(data->entitycnt,sizeof(ENTITY));
     //do serios file magic
     pack_fread(data->map,data->length,file);
     for (i = 0;i < data->entitycnt;i++)
     {
         load_entity(file,&data->entities[i]);
     }
     return data;
}
Player *
new_player(EntitySet * others, Camera * cam, InputState * is, Level world, Control * halter)
{
	Player * player = (Player *) zone(sizeof(Player));
	Entity * body = load_entity(PLAYER_PATH, player, &player_user_input_response, &player_destructor);

	player->body = body;
	player->others = others;
	player->cam = cam;
	player->is = is;
	player->world = world;
	player->health = 100;
	player->halter = halter;
	player->score = 0;
	player->fire = Mix_LoadWAV(FIRE_PATH);
	player->attack_timer = new_expirer(PLAYER_ATTACK_FREQUENCY);

	entity_set_speed(body, 3);
	entity_set_direction(body, 0, 0);
	register_entity(others, body);

	return player;
}