Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
Change chart colours
by 7th_zorro. 05/11/24 09:25
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (Akow, TipmyPip, tomaslolo), 788 guests, and 11 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19055 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 2 of 2 1 2
Re: Video Cut Scene [Re: mschoenhals] #452265
06/07/15 21:12
06/07/15 21:12

M
Malice
Unregistered
Malice
Unregistered
M



Originally Posted By: mschoenhals
It works fine without the intro video.


So this work s fine?
Code:
function main()
{
	vec_set(screen_size,vector(800,400,0));
	vec_set(screen_color,vector(50,1,1)); // dark blue
	vec_set(sky_color,vector(50,1,1)); // dark blue
	video_window(NULL,NULL,0,"My New Game");
	d3d_antialias = 1;
	shadow_stencil = 3;
	/////////////////////////////
	// Video section 
	//var vid_handle=0;  // create a local var to hold the media handle
	//vid_handle=media_play("testvid.wmv",NULL, 75); //play media and set var
	// loop only while var is valid 
	//while(vid_handle)
	//{
		//if(key_any) // check if any key was pressed
		//media_stop(vid_handle); // stop vid
		//wait(1); // required wait avoids endless looping
	//}
	///////////////////////////////////
	
	//camera.ambient = 100;
	camera.arc = 90; // set camera.arc to a proper value for shooter games
	fps_max = 75; // limit the frame rate to 75 fps (not really needed)
	video_screen = 1; // start the game in full screen mode
	video_mode = 8; // run at a 1024x768 pixels resolution on monitors with a 4/3 aspect ratio
	level_load ("shooter.wmb");
        vec_set(camera.x,vector(-250,0,50)); //back X250 up z50
        vec_set(camera.pan,vector(0,-15,0)); // TILTed down 15*
	wait (3); 
	media_loop("action.mp3", NULL, 70); // start the soundtrack
}



if so I recommend moving video_screen and video_mode to the top. As well as adding wait(2); before the level load.

Code:
function main()
{
	vec_set(screen_size,vector(800,400,0));
	vec_set(screen_color,vector(50,1,1)); // dark blue
	vec_set(sky_color,vector(50,1,1)); // dark blue
	video_window(NULL,NULL,0,"My New Game");
	d3d_antialias = 1;
	shadow_stencil = 3;
camera.arc = 90; // set camera.arc to a proper value for shooter games
	fps_max = 75; // limit the frame rate to 75 fps (not really needed)
	video_screen = 1; // start the game in full screen mode
	video_mode = 8; // run at a 1024x768 pixels resolution on monitors with a 4/3 aspect ratio
         wait(1);
	/////////////////////////////
	// Video section 
	var vid_handle=0;  // create a local var to hold the media handle
	vid_handle=media_play("testvid.wmv",NULL, 75); //play media and set var
	// loop only while var is valid 
	while(vid_handle)
	{
		if(key_any) // check if any key was pressed
                {
		media_stop(vid_handle); // stop vid
                 vid_handle=0;
                 }
		wait(1); // required wait avoids endless looping
	}
	///////////////////////////////////
	
	//camera.ambient = 100;
	wait(2);
	level_load ("shooter.wmb");
        vec_set(camera.x,vector(-250,0,50)); //back X250 up z50
        vec_set(camera.pan,vector(0,-15,0)); // TILTed down 15*
	wait (3); 
	media_loop("action.mp3", NULL, 70); // start the soundtrack
}



it is possible the vid_handle was not set to 0 in the stop action. Also vid_screen_and vid_mode are first frame actions to be take before the first wait(if I recall).

Last edited by Malice; 06/07/15 21:16.
Re: Video Cut Scene [Re: ] #452621
06/19/15 13:56
06/19/15 13:56
Joined: Aug 2013
Posts: 101
M
mschoenhals Offline OP
Member
mschoenhals  Offline OP
Member
M

Joined: Aug 2013
Posts: 101
The Camera is actually defined in the player script - although some of it is in the main script too. I'm using George Pirvu's template script right now. You can see in the player.c code that a function called shooter_camera is setup. Not sure why some of the parameters of the camera were initially set in the main script.

Code:
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Template shooter player code
// Written by George Pirvu - v1.2 July 2010
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#define PRAGMA_PATH "%EXE_DIR%\\templates\\sounds";

var t_player_speed = 25; // player's movement speed
var t_fwdbk_accel = 7; // player's forward / backward acceleration
var t_side_accel = 3; // player's sideway (strafe) acceleration
var t_friction = 1.5; // player's friction - this value should always be greater than 1
var t_fallspeed = 1; // player's fall down speed
var t_jump = 20; // player's jumping force
var t_resilience = 4; // pushes the player upwards a bit if it sinks too much in the floor
var t_disttoground = 64; // distance between the origin of player's model and the ground (used by the camera as well)
var t_camera_h = 12; // horizontal camera acceleration
var t_camera_h_frict = 0.95; // always use a value below 1 here
var t_camera_v = 8; // vertical camera acceleration
var t_camera_v_frict = 0.8; // always use a value below 1 here
var t_players_health = 100; // the player starts with 100 health points

var camera_h_speed = 0;
var camera_v_speed = 0;

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

// default player movement keys used by the shooter template: WSAD, space to jump and left shift to run
STRING* key_forward = "w";
STRING* key_backward = "s";
STRING* key_left = "a";
STRING* key_right = "d";
STRING* key_jump = "space";
STRING* key_run = "shiftl"; // left shift key

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

STRING* tjump_wav = "tjump.wav";

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

var jump_handle; //jump fix
function t_player_jump();
function shooter_camera();

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

action t_player()
{
	player = my;
	set (my, INVISIBLE); // using a 1st person player
	set (my, FLAG2); // will be used by enemies' c_scan instructions to detect the player
	var forward_on, backward_on, right_on, left_on, jump_on, run_on;
	var current_height = 0; //jump fix
//	var current_height = 0, jump_handle;
	VECTOR horizontal_speed, vertical_speed, temp;
	vec_set(horizontal_speed.x, nullvector); // initialize this vector
	vec_set(vertical_speed.x, nullvector); // initialize this vector
	while(t_players_health > 0)
	{
		// key input start
		forward_on = 0; // reset all the key values at the beginning of each frame
		backward_on = 0;
		right_on = 0;
		left_on = 0;
		jump_on = 0;
		run_on = 0;
		// set the proper variables if their corresponding keys are pressed
		if(key_pressed(key_for_str(key_forward)))
			forward_on = 1;
		if(key_pressed(key_for_str(key_backward)))
			backward_on = 1;  
		if(key_pressed(key_for_str(key_left)))
			left_on = 1;
		if(key_pressed(key_for_str(key_right)))
			right_on = 1;  
		if(key_pressed(key_for_str(key_jump)))
			jump_on = 1;     
		if(key_pressed(key_for_str(key_run)))
			run_on = 1;     
		// key input end

		shooter_camera(); // calls the shooter camera function

		// player movement start
		// player's horizontal speed (forward / backward / sideways) movement uses acceleration and friction as well
		horizontal_speed.x = (horizontal_speed.x > 0) * maxv(horizontal_speed.x - time_step * t_friction, 0) + (horizontal_speed.x < 0) * minv(horizontal_speed.x + time_step * t_friction, 0);
		if(forward_on)
		{
			horizontal_speed.x += time_step * t_fwdbk_accel;
			horizontal_speed.x = minv(horizontal_speed.x, time_step * t_player_speed  * (1 + run_on));
		}    
		if(backward_on)
		{
			horizontal_speed.x -= time_step * t_fwdbk_accel;
			horizontal_speed.x = maxv(horizontal_speed.x, -(time_step * t_player_speed * (1 + run_on)));
		}    
		horizontal_speed.y = (horizontal_speed.y > 0) * maxv(horizontal_speed.y - time_step * t_friction, 0) + (horizontal_speed.y < 0) * minv(horizontal_speed.y + time_step * t_friction, 0);
		if(left_on)
		{
			horizontal_speed.y += time_step * t_side_accel;
			horizontal_speed.y = minv(horizontal_speed.y, time_step * t_player_speed * (1 + run_on));
		}
		if(right_on)
		{
			horizontal_speed.y -= time_step * t_side_accel;
			horizontal_speed.y = maxv(horizontal_speed.y, -(time_step * t_player_speed * (1 + run_on)));
		}    	
		// disable the friction, allow smooth gliding along the surfaces
		move_friction = 0;
		vec_set(temp.x, my.x);
		temp.z -= 10000;
		current_height = c_trace(my.x, temp.x, IGNORE_ME | IGNORE_PASSABLE | USE_BOX | GLIDE); // compute the distance between player's origin and the floor below its feet 
		if(current_height < (t_disttoground * 0.97)) // if it is smaller than the default value (64 quants) push the player upwards a bit (resilience) - 0.97 gives the hysteresis
		{
			vertical_speed.z = t_resilience * time_step;
		}
		else
		{
			if(current_height > t_disttoground) // if it is bigger than the default value (64 quants), move the player downwards
			{
				vertical_speed.z -= t_fallspeed * time_step;
			}
			else // sitting properly on the floor?
			{
				vertical_speed.z = 0; // then don't do anything on the z axis
			}
		}    
		if((jump_on) && (current_height < t_disttoground)) // jumping while player's feet are placed on the floor?
		{
			if (!snd_playing (jump_handle)) // if no jumping sound is playing, play the jumping sound now
			{
				t_player_jump();
			}
			vertical_speed.z = t_jump * 0.25; // push the player upwards
		}
		// this c_move instruction does all the job, moving the player in the direction given by horizontal_speed (forward, backward, sideways) and vertical_speed (on the z axis)
		c_move (my, horizontal_speed.x , vertical_speed.x, IGNORE_PASSABLE | USE_BOX | GLIDE); 
		// player movement end
		wait(1);
	}
	camera.z -= 30; // bring the camera closer to the floor
	camera.roll = 40; // and rotate its view (the player is dead here)
}

function shooter_camera()
{
	vec_set(camera.x, my.x);
	// accelerate camera's pan and tilt angles depending on mouse_force.x and mouse_force.y in order to create a smooth camera
	camera.pan -= accelerate (camera_h_speed, t_camera_h * (mouse_force.x), t_camera_h_frict);
	camera.tilt += accelerate (camera_v_speed, t_camera_v * (mouse_force.y), t_camera_v_frict);
	camera.tilt = clamp(camera.tilt, -90, 90); // limit the tilt angle of the camera to -90... 90 degrees
	my.pan = camera.pan;
}

function t_player_jump()
{
	SND_CREATE_STATIC(shooter_jump, tjump_wav);
//	snd_play(shooter_jump, 70, 0);
jump_handle=snd_play (shooter_jump,70,0); //jump fix	
}


Re: Video Cut Scene [Re: mschoenhals] #452622
06/19/15 14:34
06/19/15 14:34

M
Malice
Unregistered
Malice
Unregistered
M



I solved this
Code:
/////////////////////////////
	// Video section 
	var vid_handle=0;  // create a local var to hold the media handle
	vid_handle=media_play("testvid.wmv",NULL, 75); //play media and set var
	// loop only while var is valid 
	while(vid_handle)
	{
		if(key_any) // check if any key was pressed
                {
		media_stop(vid_handle); // stop vid
                 vid_handle=0; //!!!!!!!!!!!!!!!
                 }
		wait(1); // required wait avoids endless looping
	}
	///////////////////////////////////



add vid_handle =0; after the media_stop

for further help with George's templete I would suggest asking in a new thread or the template section. I do not support template code.

Have a great day
Mal

EDIT - HERE is a alternative to using the handle in the while() loop
Code:
/////////////////////////////
	// Video section 
	var vid_handle=0;  // create a local var to hold the media handle
	vid_handle=media_play("testvid.wmv",NULL, 75); //play media and set var
	// loop only while var is valid 
	while(media_playing(vid_handle))
	{
		if(key_any) // check if any key was pressed
                {
		media_stop(vid_handle); // stop vid
                 //vid_handle=0; //!!!!!!!!!!!!!!!
                 }
		wait(1); // required wait avoids endless looping
	}
	///////////////////////////////////


Last edited by Malice; 06/19/15 14:44.
Page 2 of 2 1 2

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1