コード例 #1
0
ファイル: lsprite.c プロジェクト: LaoZhongGu/ejoy2d
static struct sprite *
newsprite(lua_State *L, struct sprite_pack *pack, int id) {
	if (id == ANCHOR_ID) {
		return newanchor(L);
	}
	int sz = sprite_size(pack, id);
	if (sz == 0) {
		return NULL;
	}
	struct sprite * s = (struct sprite *)lua_newuserdata(L, sz);
	sprite_init(s, pack, id, sz);
	int i;
	for (i=0;;i++) {
		int childid = sprite_component(s, i);
		if (childid < 0)
			break;
		if (i==0) {
			lua_newtable(L);
			lua_pushvalue(L,-1);
			lua_setuservalue(L, -3);	// set uservalue for sprite
		}
		struct sprite *c = newsprite(L, pack, childid);
		c->name = sprite_childname(s, i);
		sprite_mount(s, i, c);
		update_message(c, pack, id, i, s->frame);
		if (c) {
			lua_rawseti(L, -2, i+1);
		}
	}
	if (i>0) {
		lua_pop(L,1);
	}
	return s;
}
コード例 #2
0
ファイル: sprite.c プロジェクト: Super-Man/seal2d
struct sprite* sprite_new_container(struct rect* r) {
    struct sprite* s = STRUCT_NEW(sprite);
    s->type = SPRITE_TYPE_CONTAINER;
    
    sprite_init(s, r->width, r->height);
    sprite_set_glyph(s, r, NULL, 0);
    return s;
}
コード例 #3
0
ファイル: sprite.c プロジェクト: Super-Man/seal2d
struct sprite* sprite_new(struct sprite_frame* frame){
    struct sprite* s = STRUCT_NEW(sprite);
    s->type = SPRITE_TYPE_PIC;
    
    sprite_init(s, frame->source_rect.width, frame->source_rect.height);
    sprite_set_sprite_frame(s, frame);
    return s;
}
コード例 #4
0
ファイル: sprite.c プロジェクト: Super-Man/seal2d
struct sprite* sprite_new_clip(struct rect* r) {
    struct sprite* s = STRUCT_NEW(sprite);
    s->type = SPRITE_TYPE_CLIP;
    
    sprite_init(s, r->width, r->height);
    sprite_set_glyph(s, r, NULL, 0);
    
    s->x = r->x;
    s->y = r->y;
    return s;
}
コード例 #5
0
background_actor *background_actor_init(background_actor *bg)
{
    actor_init(&bg->a, background_render_handler, NULL);
    sprite_init(
            &bg->background_sprite, 
            800,
            600,
            &eng.sand_decal);
    bg->background_sprite.r[0] = 400;
    bg->background_sprite.r[1] = 300;
    return bg;
}
コード例 #6
0
ファイル: entities.c プロジェクト: nlasheras/gamba
Entity* entity_create(EntityType type, void* child)
{
    const int idx = entity_find_first_free_index();
    if (idx == -1)
        return NULL;

    Entity* e = &(sm_entities[idx]);
    e->enabled = true;
    e->type = type;
    e->child = child;

    sprite_init(&(e->sprite), DEFAULT_GFX_ID);

    return e;
}
コード例 #7
0
ファイル: main.c プロジェクト: bsurmanski/GGJ2012
void init(void)
{
    int i, j;
    SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO);
    scaled = SDL_SetVideoMode(SCREENX*2, SCREENY*2, 32, SDL_SWSURFACE);

    s = SDL_CreateRGBSurface(SDL_SWSURFACE,
            SCREENX,
            SCREENY,
            scaled->format->BitsPerPixel,
            scaled->format->Rmask,
            scaled->format->Gmask,
            scaled->format->Bmask,
            scaled->format->Amask
            );

    titlesurf = IMG_Load("res/title.png");


    srand(time(0));
    seed = rand();

    scale[0] = 0.025f;
    speed[0] = 0.005f;
    for(i = 1; i < ACTORS; i++){
        scale[i] = scale[i-1]/8.0f;
        speed[i] = speed[i-1]/4.0f;
    }

    radius = 1.0f / scale[0];

    sprite_init();
    player = actor_new(egg-1);
    particle_init();
    float pos[2] = {0.0f, 1.0f};
    float vel[2] = {0.0f, 0.0f};
}
コード例 #8
0
ファイル: main.c プロジェクト: Anz/ztg_old
int main(int argc, char* argv[]) {
    printf("hello combine\n");

    SDL_Surface* window;
    SDL_Event event;
    bool running = true;

    // create window
    int width =  480, height = 360;
    SDL_Init(SDL_INIT_VIDEO);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    window = SDL_SetVideoMode(width, height, 24, SDL_OPENGL | SDL_GL_DOUBLEBUFFER);

    // init render
    render_init();

    // load all textures
    void* textures = textures_load("img");

    // scene
    scene_t scene;
    scene_init(&scene);

    sprite_t draft;
    sprite_init(&draft, map_get(textures, "draft"));
    draft.layer = 60;

    sprite_t hud;
    sprite_init(&hud, map_get(textures, "draft"));
    hud.x = (hud.texture->width - width) / 2.0f;
    hud.y = (height - hud.texture->height) / 2.0f;

    // player
    player_t player;
    player_init(&player, &scene, textures, -50, -40);

    scene.space = array_add(scene.space, &draft);

    scene.hud = array_add(scene.hud, &hud);

    level_load(&scene, textures, "cave.lvl");

    float counter = 0;

    int speed = 0;

    // main
    while (running) {
        while (SDL_PollEvent(&event)) {
            switch (event.type) {
                case SDL_QUIT: running = false; break;
                case SDL_KEYUP:
                case SDL_KEYDOWN: {
                    switch(event.key.keysym.sym) {
                        case SDLK_a: { if (speed == -1) { speed = 0; } else { speed = -1; }  break; }
                        case SDLK_d: { if (speed == 1) { speed = 0; } else { speed = 1; } break; }
                        default: break;
                    }
                }
            }
        }

        player_move(&player, speed * 2);

        if (running) {
            render(&scene, &player.camera);
            SDL_GL_SwapBuffers();
        }
        draft.rotation += 0.5f;
        draft.transparency = sin(counter) / 2.0f + 0.5f;

        counter += 0.05f;
    }

    // clean up
    scene_release(&scene);
    textures_release(textures);
    SDL_Quit();

    return 0;
}
コード例 #9
0
ファイル: mame.cpp プロジェクト: AlanApter/steamlink-sdk
/***************************************************************************

  Run the emulation. Start the various subsystems and the CPU emulation.
  Returns non zero in case of error.

***************************************************************************/
int run_machine(void)
{
	int res = 1;


	if (vh_open() == 0)
	{
		tilemap_init();
		sprite_init();
		gfxobj_init();
		if (drv->vh_start == 0 || (*drv->vh_start)() == 0)      /* start the video hardware */
		{
			if (sound_start() == 0) /* start the audio hardware */
			{
				int	region;

				real_scrbitmap = artwork_overlay ? overlay_real_scrbitmap : Machine->scrbitmap;

				/* free memory regions allocated with REGIONFLAG_DISPOSE (typically gfx roms) */
				for (region = 0; region < MAX_MEMORY_REGIONS; region++)
				{
					if (Machine->memory_region_type[region] & REGIONFLAG_DISPOSE)
					{
						int i;

						/* invalidate contents to avoid subtle bugs */
						for (i = 0;i < memory_region_length(region);i++)
							memory_region(region)[i] = rand();
						free(Machine->memory_region[region]);
						Machine->memory_region[region] = 0;
					}
				}

				if (settingsloaded == 0)
				{
					/* if there is no saved config, it must be first time we run this game, */
					/* so show the disclaimer. */
//sq					if (showcopyright(real_scrbitmap)) goto userquit;
				}

//sq				if (showgamewarnings(real_scrbitmap) == 0)  /* show info about incorrect behaviour (wrong colors etc.) */
				{
					/* shut down the leds (work around Allegro hanging bug in the DOS port) */
					osd_led_w(0,1);
					osd_led_w(1,1);
					osd_led_w(2,1);
					osd_led_w(3,1);
					osd_led_w(0,0);
					osd_led_w(1,0);
					osd_led_w(2,0);
					osd_led_w(3,0);

					init_user_interface();

					/* disable cheat if no roms */
					if (!gamedrv->rom) options.cheat = 0;

					if (options.cheat) InitCheat();

					if (drv->nvram_handler)
					{
						void *f;

						f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_NVRAM,0);
						(*drv->nvram_handler)(f,0);
						if (f) osd_fclose(f);
					}

					cpu_run();      /* run the emulation! */

					if (drv->nvram_handler)
					{
						void *f;

						if ((f = osd_fopen(Machine->gamedrv->name,0,OSD_FILETYPE_NVRAM,1)) != 0)
						{
							(*drv->nvram_handler)(f,1);
							osd_fclose(f);
						}
					}

					if (options.cheat) StopCheat();

					/* save input ports settings */
					save_input_port_settings();
				}

userquit:
				/* the following MUST be done after hiscore_save() otherwise */
				/* some 68000 games will not work */
				sound_stop();
				if (drv->vh_stop) (*drv->vh_stop)();
				overlay_free();
				backdrop_free();

				res = 0;
			}
			else if (!bailing)
			{
				bailing = 1;
				printf("Unable to start audio emulation\n");
			}
		}
		else if (!bailing)
		{
			bailing = 1;
			printf("Unable to start video emulation\n");
		}

		gfxobj_close();
		sprite_close();
		tilemap_close();
		vh_close();
	}
	else if (!bailing)
	{
		bailing = 1;
		printf("Unable to start video emulation\n");
	}

	return res;
}
コード例 #10
0
ファイル: animated.cpp プロジェクト: mvallebr/fastship
void animated_init(animated *an) {
	sprite_init((sprite *)an);
	an->auxcount=0;
	an->auxvx=0;
	an->auxvy=0;
}