예제 #1
0
파일: player.c 프로젝트: miton/taisei
void player_applymovement(Player* plr) {
	if(plr->deathtime < -1)
		return;
	
	plr->moving = False;
	
	int up		=	plr->moveflags & MOVEFLAG_UP,
		down	=	plr->moveflags & MOVEFLAG_DOWN,
		left	=	plr->moveflags & MOVEFLAG_LEFT,
		right	=	plr->moveflags & MOVEFLAG_RIGHT;
	
	if(left && !right) {
		plr->moving = True;
		plr->dir = 1;
	} else if(right && !left) {
		plr->moving = True;
		plr->dir = 0;
	}	
	
	complex direction = 0;
	
	if(up)		direction -= 1I;
	if(down)	direction += 1I;
	if(left)	direction -= 1;
	if(right)	direction += 1;
		
	if(cabs(direction))
		direction /= cabs(direction);
	
	if(direction)
		player_move(&global.plr, direction);
	
	// workaround
	if(global.replaymode == REPLAY_RECORD) {
		Uint8 *keys = SDL_GetKeyState(NULL);
		
		if(!keys[tconfig.intval[KEY_SHOT]] && plr->fire) {
			player_event(plr, EV_RELEASE, KEY_SHOT);
			replay_event(&global.replay, EV_RELEASE, KEY_SHOT);
		}
		
		if(!keys[tconfig.intval[KEY_FOCUS]] && plr->focus > 0) {
			player_event(plr, EV_RELEASE, KEY_FOCUS);
			replay_event(&global.replay, EV_RELEASE, KEY_FOCUS);
		}
	}
}
예제 #2
0
파일: player.c 프로젝트: piaopolar/taisei
void player_input_workaround(Player *plr) {
	if(!global.dialog) {
		int shot  = gamekeypressed(KEY_SHOT);
		int focus = gamekeypressed(KEY_FOCUS);
		
		if(!shot && plr->fire) {
			player_event(plr, EV_RELEASE, KEY_SHOT);
			replay_event(&global.replay, EV_RELEASE, KEY_SHOT);
		} else if(shot && !plr->fire) {
			player_event(plr, EV_PRESS, KEY_SHOT);
			replay_event(&global.replay, EV_PRESS, KEY_SHOT);
		}
		
		if(!focus && plr->focus > 0) {
			player_event(plr, EV_RELEASE, KEY_FOCUS);
			replay_event(&global.replay, EV_RELEASE, KEY_FOCUS);
		}
	}
}