3 registered members (NewbieZorro, TipmyPip, 1 invisible),
19,045
guests, and 8
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Re: HELP NEEDED URGENTLY
[Re: gameaddict]
#322777
05/09/10 13:49
05/09/10 13:49
|
Joined: Apr 2010
Posts: 59 Lagos, Nigeria
gameaddict
OP
Junior Member
|
OP
Junior Member
Joined: Apr 2010
Posts: 59
Lagos, Nigeria
|
Hi guys! new problem  I'm currently using the lite-c version to learn the code. I'm following both tutorials and I've gotten the player to move without animation. Problem is, after coding the animation.c and editing the player.c as required, The program won't run. In WED, it says error in MAIN line 13. There's nothing on line 13 and I've corrected all syntax errors I could find. Please help me. I'm posting all my code here: main.c:
#include <acknex.h>
#include <default.c>
#include "player.c"
#include "animation.c"
function main()
{
camera.clip_near = 0;
video_switch(7,0,1);
level_load("m2.wmb");
}
player.c:
//////////////////////////////////////////////////////////////////////
function handle_movement();
function handle_camera();
function handle_animation(var animation_speed);
#define nullframe -2
#define blend -1
#define stand 0
#define run 1
#define walk 2
#define jump 3
#define fall 4
#define attack_a 5
#define attack_b 6
#define attack_c 7
#define attack_d 8
#define attack_e 9
#define attack_f 10
#define move_x skill22 // movement skills
#define move_y skill23
#define move_z skill24
#define force_x skill25
#define force_y skill26
#define force_z skill27
#define velocity_x skill28
#define velocity_y skill29
#define velocity_z skill30
#define animate skill31 ///animation skills
#define animate2 skill32
#define animblend skill33
#define currentframe skill34
#define blendframe skill35
#define z_offset skill50 //gravity and jumping skills
#define jumping_mode skill51
#define gravity skill52
#define movement_mode skill53 //4 various movements, mainly combat
#define moving skill54
#define hit_by_player skill55
#define entity_type skill56
VECTOR* tempV = { x=0; y=0; z=0;}
VECTOR* tempV2= { x=0; y=0; z=0; }
ANGLE* tempA = { pan=0; tilt=0; roll=0; }
ANGLE* tempA2= { pan=0; tilt=0; roll=0; }
VECTOR* camera_move_to = { x=0; y=0; z=0; }
var temp;
var camera_distance = 200;
var camera_pan;
var camera_tilt;
action player_action()
{
set(my, SHADOW);
while(1) {
handle_movement();
handle_camera();
handle_animation(1);
wait(1);
}
}
function handle_movement()
{
tempV.x = -1000;
tempV.y = 0;
if(key_w == 1 && key_s == 0 && key_a == 0 && key_d == 0) {tempV.x = camera.pan;}
if(key_s == 1 && key_w == 0 && key_a == 0 && key_d == 0) {tempV.x = camera.pan + 180;}
if(key_a == 1 && key_s == 0 && key_w == 0 && key_d == 0) {tempV.x = camera.pan + 90;}
if(key_d == 1 && key_s == 0 && key_a == 0 && key_w == 0) {tempV.x = camera.pan - 90;}
if(key_w == 1 && key_a == 1 && key_d == 0 && key_s == 0) {tempV.x = camera.pan + 45; }
if(key_w == 1 && key_d == 1 && key_a == 0 && key_s == 0) {tempV.x = camera.pan - 45; }
if(key_s == 1 && key_a == 1 && key_d == 0 && key_w == 0) {tempV.x = camera.pan + 135;}
if(key_s == 1 && key_d == 1 && key_a == 0 && key_w == 0) {tempV.x = camera.pan - 135; }
if(tempV.x != -1000) {tempV.y = 15 * time_step;}
my.move_x = fcos(tempV.x, tempV.y);
my.move_y = fsin(tempV.x, tempV.y);
c_move(my, nullvector, my.move_x, USE_BOX | IGNORE_PASSABLE | GLIDE);
if(my.move_x != 0 || my.move_y != 0) { // if we are moving
if(my.animblend == stand) {
// if current animation is stand
if(key_shift == 1) { my.blendframe = walk; }
else {my.blendframe = run; }
}
if(my.animblend == run && key_shift == 1) { my.blendframe = walk; }
if(my.animblend == walk && key_shift == 0) { my.blendframe = run; }
} else {
if(my.animblend > stand) {
//if we aren't moving and our current animation
//is walk or run, blend and cycle the stand animation
my.blendframe = stand;
}
}
function handle_camera()
{
camera.pan -= mouse_force.x * 12 * time_step;
camera.tilt += mouse_force.y * 8 * time_step;
camera.tilt = clamp(camera.tilt, -30, 10);
temp = fcos(camera.tilt, -camera_distance);
vec_set(camera.x, vector(my.x + fcos(camera.pan, temp),my.y + fsin(camera.pan, temp),my.z + 20 + fsin(camera.tilt, -camera_distance)));
vec_diff(tempV.x, camera.x, my.x); //find the vector from the player to the camera
vec_normalize(tempV.x, 16); //get the magnitude of it's vector to 16 quants and store it in temp
vec_add(tempV.x, camera.x); //add the vector (from player to camera) of a magnitude of 16 quants and add it to the camera's position.
result = c_trace(my.x, tempV.x, IGNORE_ME|IGNORE_PASSABLE|IGNORE_MODELS); //trace from the player to 16 quants behind the camera.
if(result > 0)
{
vec_diff(tempV.x, my.x, target.x); //find the vector from the point the trace hit to the player
vec_normalize(tempV.x, 16); //get the magnitude of this vector to 16 quants and store in temp
vec_set(camera.x, target.x); //place the camera at the trace hit point
vec_add(camera.x, tempV.x); //move the camera away from the wall by the vector temp, 16 quants towards the player
}
}
animation.c:
function handle_animation(var animation_speed)
{
if(animation_speed <= 0) { animation_speed = 1;}
if(my.animblend != blend && my.blendframe != nullframe) {
my.animate2 = 0;
my.animblend = blend;
}
if(my.animblend == blend) {
if(my.currentframe == stand) {ent_animate(my, "stand", my.animate, ANM_CYCLE); }
if(my.currentframe == run) { ent_animate(my, "run", my.animate, ANM_CYCLE); }
if(my.currentframe == walk) { ent_animate(my, "walk", my.animate, ANM_CYCLE); }
if(my.blendframe == stand) { ent_blend("stand", 0, my.animate2); }
if(my.blendframe == run) { ent_blend("run", 0, my.animate2); }
if(my.blendframe == walk) { ent_blend("walk", 0, my.animate2); }
my.animate2 += 45 * time_step;
if(my.animate2 >= 100) {
my.animate = 0;
my.animblend = my.blendframe;
my.blendframe = nullframe;
}
}
if(my.animblend == stand) {
ent_animate(my, "stand", my.animate, ANM_CYCLE);
my.animate += 5 * animation_speed * time_step;
my.animate %= 100;
my.currentframe = stand;
}
if(my.animblend == run) {
ent_animate(my, "run", my.animate, ANM_CYCLE);
my.animate += 6.8 * animation_speed * time_step;
my.animate %= 100;
my.currentframe = run;
}
if(my.animblend == walk) {
ent_animate(my, "walk", my.animate, ANM_CYCLE);
my.animate += 8 * animation_speed * time_step;
my.animate %= 100;
my.currentframe = walk;
}
}
I know I can.
|
|
|
|