view paper_shooting/resources/title_combat.js @ 25:158b846e3874

paper
author <e085737>
date Mon, 14 Feb 2011 16:37:16 +0900
parents
children
line wrap: on
line source

title_plane = function(sgroot, w, h){
    var title_player = new sgroot.createSceneGraph3();
    title_player.set_move_collision(no_move_idle, no_collision_idle);


    var title_plane = new sgroot.createSceneGraph3()
    title_plane.xyz[0] = 45; 
    title_plane.xyz[1] = 65;
    title_plane.xyz[2] = 0;
    position_xyz[0] = title_plane.xyz[0];
    position_xyz[1] = title_plane.xyz[1]; 
    position_xyz[2] = title_plane.xyz[2];
    aim_xyz[0] = position_xyz[0]; 
    aim_xyz[1] = position_xyz[1];  
    aim_xyz[2] = position_xyz[2] + 1;
    cameraAngle_xyz[0] = 0;
    cameraAngle_xyz[1] = 0;
    cameraAngle_xyz[2] = 0;
    title_player.addChild(title_plane);


    title_plane.scale = 0.05
    title_plane.set_move_collision(Tplane_move, no_move_idle)



    var main = new sgroot.createSceneGraph1("chest_center_B")
    main.angle[0] = -90
    main.angle[1] = 200
    main.angle[2] = -90
    main.set_move_collision(Tmain_move, no_collision_idle) 
    main.id = null;
    position = 0;
    position_wide = 0;
    title_plane.addChild(main)



    var parts1  = new sgroot.createSceneGraph1("chest_center_B.001")
    var parts2  = new sgroot.createSceneGraph1("chest_center_B.002")
    var parts3  = new sgroot.createSceneGraph1("chest_center_B.003")
    var parts4  = new sgroot.createSceneGraph1("chest_center_B.004")
    var parts5  = new sgroot.createSceneGraph1("chest_center_B.005")
    var parts6  = new sgroot.createSceneGraph1("chest_center_B.006")
    var parts7  = new sgroot.createSceneGraph1("chest_center_B.007")
    var parts8  = new sgroot.createSceneGraph1("chest_center_B.008")
    var parts9  = new sgroot.createSceneGraph1("chest_center_B.009")
    var parts10 = new sgroot.createSceneGraph1("chest_center_B.010")
    var parts11 = new sgroot.createSceneGraph1("chest_center_B.011")
    var parts12 = new sgroot.createSceneGraph1("chest_center_B.012")
    var parts13 = new sgroot.createSceneGraph1("chest_center_B.013")
    var parts14 = new sgroot.createSceneGraph1("chest_center_B.014")
    var parts15 = new sgroot.createSceneGraph1("chest_center_B.015")
    var parts16 = new sgroot.createSceneGraph1("chest_center_B.016")
    var parts17 = new sgroot.createSceneGraph1("chest_center_B.017")
    var parts18 = new sgroot.createSceneGraph1("chest_center_B.018")
    var parts19 = new sgroot.createSceneGraph1("chest_center_B.019")
    var parts20 = new sgroot.createSceneGraph1("chest_center_B.020")
    var parts21 = new sgroot.createSceneGraph1("chest_center_B.021")
    var parts22 = new sgroot.createSceneGraph1("chest_center_B.022")
    var parts23 = new sgroot.createSceneGraph1("chest_center_B.023")
    var parts24 = new sgroot.createSceneGraph1("chest_center_B.024")
    var parts25 = new sgroot.createSceneGraph1("chest_center_B.025")
    var parts26 = new sgroot.createSceneGraph1("chest_center_B.026")
    var parts27 = new sgroot.createSceneGraph1("chest_center_B.027")
    var parts28 = new sgroot.createSceneGraph1("chest_center_B.028")
    var parts29 = new sgroot.createSceneGraph1("chest_center_B.029")
    var parts30 = new sgroot.createSceneGraph1("chest_center_B.030")
    var parts31 = new sgroot.createSceneGraph1("chest_center_B.031")
    var parts32 = new sgroot.createSceneGraph1("chest_center_B.032")
    var parts33 = new sgroot.createSceneGraph1("chest_center_B.033")
    var parts34 = new sgroot.createSceneGraph1("chest_center_B.034")
    var parts35 = new sgroot.createSceneGraph1("chest_center_B.035")
    var parts36 = new sgroot.createSceneGraph1("chest_center_B.036")
    var parts37 = new sgroot.createSceneGraph1("chest_center_B.037")
    var parts38 = new sgroot.createSceneGraph1("chest_center_B.038")
    var parts39 = new sgroot.createSceneGraph1("chest_center_B.039")
    var parts40 = new sgroot.createSceneGraph1("chest_center_B.040")
    var parts41 = new sgroot.createSceneGraph1("chest_center_B.041")
    var parts42 = new sgroot.createSceneGraph1("chest_center_B.042")
    var parts43 = new sgroot.createSceneGraph1("chest_center_B.043")
    var parts44 = new sgroot.createSceneGraph1("chest_center_B.044")
    var parts45 = new sgroot.createSceneGraph1("chest_center_B.045")
    var parts46 = new sgroot.createSceneGraph1("chest_center_B.046")
    var parts47 = new sgroot.createSceneGraph1("chest_center_B.047")
    var parts48 = new sgroot.createSceneGraph1("chest_center_B.048")
    var parts49 = new sgroot.createSceneGraph1("chest_center_B.049")
    var parts50 = new sgroot.createSceneGraph1("chest_center_B.050")
    var parts51 = new sgroot.createSceneGraph1("chest_center_B.051")
    var parts52 = new sgroot.createSceneGraph1("chest_center_B.052")
    var parts53 = new sgroot.createSceneGraph1("chest_center_B.053")
    var parts54 = new sgroot.createSceneGraph1("chest_center_B.054")
    var parts55 = new sgroot.createSceneGraph1("chest_center_B.055")
    var parts56 = new sgroot.createSceneGraph1("chest_center_B.056")
    var parts57 = new sgroot.createSceneGraph1("chest_center_B.057")
    var parts58 = new sgroot.createSceneGraph1("chest_center_B.058")
    var parts59 = new sgroot.createSceneGraph1("chest_center_B.059")
    var parts60 = new sgroot.createSceneGraph1("chest_center_B.060")
    var parts61 = new sgroot.createSceneGraph1("chest_center_B.061")
    var parts62 = new sgroot.createSceneGraph1("chest_center_B.062")
    var parts63 = new sgroot.createSceneGraph1("chest_center_B.063")
    var parts64 = new sgroot.createSceneGraph1("chest_center_B.064")
    var parts65 = new sgroot.createSceneGraph1("chest_center_B.065")
    var parts66 = new sgroot.createSceneGraph1("chest_center_B.066")
    var parts67 = new sgroot.createSceneGraph1("chest_center_B.067")
    var parts68 = new sgroot.createSceneGraph1("chest_center_B.068")
    var parts69 = new sgroot.createSceneGraph1("chest_center_B.069")
    var parts70 = new sgroot.createSceneGraph1("chest_center_B.070")
    var parts71 = new sgroot.createSceneGraph1("chest_center_B.071")
    var parts72 = new sgroot.createSceneGraph1("chest_center_B.072")
    var parts73 = new sgroot.createSceneGraph1("chest_center_B.073")
    var parts74 = new sgroot.createSceneGraph1("chest_center_B.074")
   

    main.addChild(parts1)
    main.addChild(parts2)
    main.addChild(parts3)
    main.addChild(parts4)
    main.addChild(parts5)
    main.addChild(parts6)
    main.addChild(parts7)
    main.addChild(parts8)
    main.addChild(parts9)
    main.addChild(parts10)
    main.addChild(parts11)
    main.addChild(parts12)
    main.addChild(parts13)
    main.addChild(parts14)
    main.addChild(parts15)
    main.addChild(parts16)
    main.addChild(parts17)
    main.addChild(parts18)
    main.addChild(parts19)
    main.addChild(parts20)
    main.addChild(parts21)
    main.addChild(parts22)
    main.addChild(parts23)
    main.addChild(parts24)
    main.addChild(parts25)
    main.addChild(parts26)
    main.addChild(parts27)
    main.addChild(parts28)
    main.addChild(parts29)
    main.addChild(parts30)
    main.addChild(parts31)
    main.addChild(parts32)
    main.addChild(parts33)
    main.addChild(parts34)
    main.addChild(parts35)
    main.addChild(parts36)
    main.addChild(parts37)
    main.addChild(parts38)
    main.addChild(parts39)
    main.addChild(parts40)
    main.addChild(parts41)
    main.addChild(parts42)
    main.addChild(parts43)
    main.addChild(parts44)
    main.addChild(parts45)
    main.addChild(parts46)
    main.addChild(parts47)
    main.addChild(parts48)
    main.addChild(parts49)
    main.addChild(parts50)
    main.addChild(parts51)
    main.addChild(parts52)
    main.addChild(parts53)
    main.addChild(parts54)
    main.addChild(parts55)
    main.addChild(parts56)
    main.addChild(parts57)
    main.addChild(parts58)
    main.addChild(parts59)
    main.addChild(parts60)
    main.addChild(parts61)
    main.addChild(parts62)
    main.addChild(parts63)
    main.addChild(parts64)
    main.addChild(parts65)
    main.addChild(parts66)
    main.addChild(parts67)
    main.addChild(parts68)
    main.addChild(parts69)
    main.addChild(parts70)
    main.addChild(parts71)
    main.addChild(parts72)
    main.addChild(parts73)
    main.addChild(parts74)


    return title_player    
    
}



Tplane_move = function(node, sgroot, w ,h){
	var move_eye = 1.0;
	var move_walk = 3.0;
	var PI = Math.PI;
	var pad = new sgroot.getController();


	if(pad.left_move_isHold()){

        node.xyz[0] -= move_walk;
        position += move_walk;
	}

	if(pad.right_move_isHold()){

        node.xyz[0] += move_walk;
        position -= move_walk;
	}

	if(pad.front_move_isHold()){

        node.xyz[1] -= move_walk;
	}

	if(pad.back_move_isHold()){

        node.xyz[1] += move_walk;
	}

	if(pad.right_isHold()){
		var bullet_speed = 200;
		var radian_xz  = ((theta_xz%360)/360) * 2 * PI;
		var radian_yz  = ((cameraAngle_xyz[1]%90)/90) * (PI / 2);
		var bullet = new sgroot.createSceneGraph1("yellow_3d");
		bullet.xyz[0] = node.xyz[0] - 200;
		bullet.xyz[1] = node.xyz[1];
		bullet.xyz[2] = node.xyz[2];
		bullet.dx = 0.0;
		bullet.dy = bullet_speed;
        bullet.dz = 0.0;
        bullet.angle[2] = -90;
		bullet.scale = 7.0;
		bullet.set_move_collision(bullet_move, no_collision_idle);
        node.addChild(bullet);
	}
}


Trplane_move = function(node, sgroot, w ,h){
	var move_eye = 1.0;
	var move_walk = 3.0;
	var PI = Math.PI;
	var pad = new sgroot.getController();
	var dx = position_xyz[0] - aim_xyz[0];
    var dy = position_xyz[1] - aim_xyz[1];
	var dz = position_xyz[2] - aim_xyz[2];
	var d = Math.sqrt(Math.pow(dx,2) + Math.pow(dy,2) + Math.pow(dz,2));


	if(pad.left_move_isHold()){
		var radian = (((theta_xz+90)%360) / 360) * 2 * PI;

		node.xyz[2] += move_walk;
        position_wide -= move_walk;
	}

	if(pad.right_move_isHold()){
		var radian = (((theta_xz+90)%360) / 360) * 2 * PI;

		node.xyz[2] -= move_walk;
        position_wide += move_walk;
          
	}

	if(pad.front_move_isHold()){
		var radian = ((theta_xz%360) / 360) * 2 * PI;

        node.xyz[1] -= move_walk;

	}

	if(pad.back_move_isHold()){
		var radian = ((theta_xz%360) / 360) * 2 * PI;

        node.xyz[1] += move_walk;

	}

	if(pad.right_isHold() && node.frame%2){
		var bullet_speed = 8;
		var bullet = new sgroot.createSceneGraph1("yellow_3d");
		bullet.xyz[0] = node.xyz[0];
		bullet.xyz[1] = node.xyz[1];
		bullet.xyz[2] = node.xyz[2];
		bullet.dx = bullet_speed;
		bullet.dy = 0.0;
		bullet.dz = 0.0;
		bullet.scale = 0.3;
		bullet.set_move_collision(bullet_move, no_collision_idle);
        node.addChild(bullet);
	}
}

Tmain_move = function(node, sgroot, w, h){
	var move_eye = 3.0;
	var PI = Math.PI;
	var pad = new sgroot.getController();
	var dx = node.parents.xyz[0] - position_xyz[0];
    var dy = node.parents.xyz[1] - position_xyz[1];
	var dz = node.parents.xyz[2] - position_xyz[2];
	var d = 170 
	var radian_xz = ((theta_xz%360) / 360) * 2 * PI;
    var radian_yz = ((theta_yz%360) / 360) * 2 * PI;

	if(!node.flag_rotate && theta_xz <= 90){
		theta_xz += move_eye*2;

		var mv_x = d * Math.cos(radian_xz);
		var mv_z = d * Math.sin(radian_xz);
                
		position_xyz[0] = node.parents.xyz[0] - mv_x + position;
		position_xyz[2] = node.parents.xyz[2] - mv_z;
		aim_xyz[0] = position_xyz[0];
		aim_xyz[2] = position_xyz[2] + 1;
        console.log(position_xyz[0]);
        
        cameraAngle_xyz[1] -= move_eye*2;
	}

	if(node.flag_rotate && theta_xz >= 0){
		theta_xz -= move_eye*2;

		var mv_x = d * Math.cos(radian_xz);
		var mv_z = d * Math.sin(radian_xz);

		position_xyz[0] = node.parents.xyz[0] - mv_x;
		position_xyz[2] = node.parents.xyz[2] - mv_z + position_wide;
		aim_xyz[0] = position_xyz[0];
		aim_xyz[2] = position_xyz[2] + 1;
        
		cameraAngle_xyz[1] += move_eye*2;
	}


    if(-6 < theta_xz && theta_xz < 96){
        sgroot.move_now = true;
    }else{
        sgroot.move_now = false;
    }

	if(pad.space_isHold() && !node.flag_reverse){
        if(node.flag_rotate == false){
            node.parents.set_move_collision(Trplane_move, no_collision_idle);
        }else{
            node.parents.xyz[2] = 0;
            position_wide = 0;
            node.parents.set_move_collision(Tplane_move, no_collision_idle);
        }
        node.flag_rotate = !node.flag_rotate;
        node.flag_reverse = true;
	}
    if(pad.space_isRelease()){
        node.flag_reverse = false;
    }
}