コード例 #1
0
ファイル: collisions.c プロジェクト: dmalves/cage
/* Collision detection
 * -------------------
 *
 * When updating a frame, we traverse the star pairs
 * graph and test for a bounding box intersection.
 * To detect pixel-level collisions, we us pixels_collide()
 * using the portion of intersection as a test area.
 * If we detect a collision, we swap the star pair
 * motion vectors to create a deflection effect.
 *
 * When done, we update and draw the stars.
 */
static void update_sample(void* data, float elapsed_ms)
{
    struct state* state = data;
    int visited[MAX_STARS][MAX_STARS] = { { 0 } };
    int i, j;
    for (i = 0; i < MAX_STARS; i++) {
        for (j = 0; j < MAX_STARS; j++) {
            if (i != j && visited[i][j] == 0 && visited[j][i] == 0) {
                bbox sub;
                struct star* a = &state->stars[i];
                struct star* b = &state->stars[j];
                if (bbox_intersect(a->star_bbox, b->star_bbox, &sub)) {
                    struct rectangle r1, r2;
                    r1 = rect_from_sub_bbox(a->star_bbox, sub);
                    r2 = rect_from_sub_bbox(b->star_bbox, sub);
                    if (pixels_collide(state->star_img, &r1, state->star_img,
                                       &r2))
                        swap_vecs(&a->star_vec, &b->star_vec);
                }
                visited[i][j] = 1;
            }
        }
    }
    screen_color(color_from_RGB(10, 20, 50));
    for (i = 0; i < MAX_STARS; i++) {
        update_star(&state->stars[i], elapsed_ms);
        draw_image(state->star_img, VEC_XY(state->stars[i].star_pos), NULL, 0);
    }
}
コード例 #2
0
ファイル: chipmunk.c プロジェクト: rlofc/cage
/* Updating each frame
 * -------------------
 *
 * Updating and drawing a frame takes stepping the Chipmunk2D
 * simulation by the 1/1000s fration of a second passed and
 * then drawing any active tile using its up-to-date
 * position.
 * We then delegate any mouse actions to apply_mouse_motion().
 */
static void update_sample(void* data, float elapsed_ms)
{
    struct state* state = data;
    cpFloat timeStep = elapsed_ms / 1000.0;
    cpSpaceStep(state->space, timeStep);
    screen_color(color_from_RGB(244, 244, 244));
    for (size_t i = 0; i < MAX_TILES; i++) {
        if (state->tiles[i].is_active) {
            cpVect pos = cpBodyGetPosition(state->tiles[i].body);
            draw_image(state->tile_img, pos.x - state->tile_img->width / 2,
                       pos.y - state->tile_img->height / 2, NULL, 0);
        }
    }
    apply_mouse_motion(state);
}
コード例 #3
0
ファイル: yb_uninstall.cpp プロジェクト: 510908220/setup
void InitDataReport(int argc, LPWSTR* argv)
{
  ygdata_report::GetMachineIdTimeout(10 * 1000);
  ygdata_report::AddEidDescList(kEidDescList);
	bool debug_string = CmdLineFindFlag(argc, argv, L"--data-report-debug-string") >= 0;
	//增加窗口
	debug_string = debug_string || IsDebugStringValue();

	ygdata_report::Init(L"http://stat.game.yy.com/data.do", "pas", "yyexplorer", 5 * 60 * 1000, NULL, L"", 0, debug_string);
	ygdata_report::Run();

	SessionInfo info;
	std::string screen_size("0.0");
	std::string screen_color("0");

	DEVMODEW dm;
	dm.dmSize = sizeof(dm);

	BOOL result = EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &dm);
	if (result)
	{
		char number[32];

		screen_size.clear();
		screen_size.append(_itoa(dm.dmPelsWidth, number, 10));
		screen_size.append(".");
		screen_size.append(_itoa(dm.dmPelsHeight, number, 10));

		screen_color.clear();
		screen_color.append(_itoa(dm.dmBitsPerPel, number, 10));
	}

	info.cha = "yeuninstall";
	info.rso = "from_yeuninstall";
	info.ive = STR_PRODUCT_VERSION"."STR_FILE_VERSION;
	info.uve = info.ive;
	info.os = ygdata_report::GetOsPlatformVersion();
	info.lla = "zh_cn";
	info.sre = screen_size;
	info.sco = screen_color;
	ygdata_report::PostSessionInfo(info);

	ygdata_report::SendEventWithSrc("yeuninstall", "StartUp");
}
コード例 #4
0
ファイル: wizard.c プロジェクト: dmalves/cage
/* The Game State Functions
 * ------------------------
 *
 * **create\_level()** is called by Cage before the game loop
 * starts to update frames. This is the place
 * to setup the level and its data.
 */
static void* create_level(void)
{
    void* data = create_level_data();
    screen_color(color_from_RGB(170, 210, 250));
    return data;
}
コード例 #5
0
ファイル: edit.c プロジェクト: MonteCarlos/anim64
static void show_cursor() {
    hidden_screen_char = screen_char();
    hidden_color = screen_color();
}