Posted By: zeusk
apply physics on click problem - 05/16/11 16:58
hello guys im having a small problem with my code that i think you can help with.
im currently working on a minecraft/RTS game called slumbus, and i need help with the physics.
is there any way for me to apply physics only to the slumbus models and not anything else without loosing the function pointer it already has?
heres the code:
Any help is greatly appreciated
im currently working on a minecraft/RTS game called slumbus, and i need help with the physics.
is there any way for me to apply physics only to the slumbus models and not anything else without loosing the function pointer it already has?
heres the code:
Code:
#define HEALTH skill10 #include <acknex.h> #include <default.c> ENTITY* er; ENTITY* a; STRING* message_str = "#50"; // this string can store up to 50 characters //SOUND* hurt = "fire.wav"; //SOUND* run = "kung fu run.wav"; //SOUND* muzik = "kung fu loop.wav"; //SOUND* walk = "14metala1.wav"; var speed_down = 0; // downward speed by gravity var anim_percent = 0; // animation percentage VECTOR vFeet; vec_for_min(vFeet,er); // vFeet.z = distance from player origin to lowest vertex function delete() // this function runs when the bullet collides with something { wait (1); // wait a frame to be sure (don't trigger engine warnings) ent_remove (my); // and then remove the bullet } function mouse_startup() { // allow the player to switch the characters even if they are 10,000 quants away from each other mouse_range = 10000; mouse_mode = 1; while (1) { vec_set(mouse_pos, mouse_cursor); wait(1); } } function phys() { // Now let's set the ball's physical properties. phent_settype(my,PH_RIGID,PH_BOX); phent_setmass(my,1,PH_SPHERE); phent_setfriction(my,90); phent_setelasticity(my,75,100); phent_setdamping(my,30,5); // We add a small speed to give it a little sidewards kick. phent_addvelcentral(my,vector(10,10,0)); my.emask |= ENABLE_FRICTION; } function move_player() { var anim_percentage; while (player == my) { camera.x = my.x - 500 * cos(my.pan); // place the camera 200 quants behind the player camera.y = my.y - 200 * sin(my.pan); camera.z = my.z + 100; // and 300 quants above its origin c_setminmax(my); camera.pan = my.pan; camera.tilt = -15; // look down at the player // move the player using the "W", "S", "A" and "D" keys; "10" = movement speed, "6" = rotation speed c_move (my, vector(50 * (key_w - key_s) * time_step, 0, 0), nullvector, GLIDE); my.pan += 6 * (key_a - key_d) * time_step; my.z += 22 * (key_q - key_e) * time_step; camera.ambient += 20 * (key_z - key_x) * time_step; if (key_w || key_s) // the player is walking? { ent_animate(my, "walk", anim_percentage, ANM_CYCLE); anim_percentage += 8 * time_step; // "8" controls the "walk" animation speed } else // the player is standing still? { ent_animate(my, "stand", anim_percentage, ANM_CYCLE); anim_percentage += 0.5 * time_step; // "0.5" controls the "stand" animation speed } wait (1); } } function switch_players() { if (player == my) {return;} // don't make the switch if the actual player is clicked again player = my; camera.pan = my.pan; // start with a proper camera orientation move_player(); } action set_player() { player = my; move_player(); my.emask |= ENABLE_CLICK; my.event = switch_players; } function delete() { my.emask |= ENABLE_CLICK; my.event = delete; } function spawn() { ent_create("slumbus.mdl",vector(0,0,100),set_player); } function main() { level_load("boxin{.mdl");//load this premade matrix for now video_mode = 7; video_screen = 1; camera.ambient = 100; //**********************REMEMBER TO ADD SCI-FI ROOM FOR THE INTERIOR OF THE SPACE CAPSULE IN LEVEL 2***************************************** er = ent_create("",vector(0,0,100),set_player);// loads joe c = ent_create("blank.mdl",vector(0,0,100),spawn);// loads joe er.pan = 0; b = ent_create("slumbus.mdl",vector(1990,780,100),set_player); a = ent_create("",vector(1190,40,180),NULL); b.pan = 180; er.min_z *= 0.5; var speed_down = 0; // downward speed by gravity var anim_percent = 0; // animation percentage VECTOR vFeet; vec_for_min(vFeet,er); // vFeet.z = distance from player origin to lowest vertex er.push = 3; str_cpy(message_str, "Grace system beta:move with wasd keys tilt with hj keys, and roll with kl keys."); c_setminmax(er); // adds a bigger collision box to model c_setminmax(b); ph_setgravity(vector(0,0,-500)); on_space = spawn; while (1) { d3d_fogcolor1.red = 255;d3d_fogcolor1.green = 255; d3d_fogcolor1.blue = 255; // black fog //fog_color = 1; wait(1); } }
Any help is greatly appreciated