I am getting close.........

Posted By: sadsack

I am getting close......... - 08/25/08 21:39

I am getting close to being moving my ship. I think if I can get over this one problem I will have it made. here is the error I am getting.




I been looking all over trying how to do this, but I am at a lose.
here is all of my code
Code:

//////////////////////////////
#include <acknex.h>
#include <default.c>

function main()
{
	level_load ("");
	wait(2);	// wait until the level is loaded
	vec_set(camera.x, vector(-500, 0, -10));
	ent_create("ship.mdl", vector(0, 0, 0),NULL);
	ent_create("land.mdl", vector(-900,2000, -400),NULL);
}	

 action move_ship()
	
{
	
	
	


	while (1)
	
    {

              
             // move the player using the "W", "S", "A" and "D" keys; "10" = movement speed, "6" = strafing speed

               c_move (ship, vector(10 * (key_w - key_s) * time_step, 6 * (key_a - key_d) * time_step, 0), nullvector, GLIDE);

    }

}

	   wait (1);
	   
	   



I hope some one can help. It has been two days now, I been working on this. manual said it was easy, most likely so if you know it already.
Thank You
renny
Posted By: crumply

Re: I am getting close......... - 08/25/08 21:41

ent_create("ship.mdl", vector(0, 0, 0),move_ship);

also, put the action move_ship above main.
Posted By: sadsack

Re: I am getting close......... - 08/25/08 22:06

Well crumply, that got me very close. see photo




I don't know what syntax error, but I did mot get it on till I put action move_ship above main.
here is the code

Code:

//////////////////////////////
#include <acknex.h>
#include <default.c>

action move_ship()

function main()
{
	level_load ("");
	wait(2);	// wait until the level is loaded
	vec_set(camera.x, vector(-500, 0, -10));
	ent_create("ship.mdl", vector(0, 0, 0),move_ship);
	ent_create("land.mdl", vector(-900,2000, -400),NULL);
}	

 
	
{
	
	
	


	while (1)
	
    {

              
             // move the player using the "W", "S", "A" and "D" keys; "10" = movement speed, "6" = strafing speed

               c_move (ship, vector(10 * (key_w - key_s) * time_step, 6 * (key_a - key_d) * time_step, 0), nullvector, GLIDE);

    }

}

	   wait (1);
	   
	   



I think if we can get this fixed it will work.
thank you
renny
Posted By: Blade280891

Re: I am getting close......... - 08/25/08 22:15

Why are you double posting?
Posted By: crumply

Re: I am getting close......... - 08/25/08 22:29

I said ent_create("ship.mdl", vector(0, 0, 0),move_ship);

not

ent_create("ship.mdl", vector(0, 0, 0),move_ship());
Posted By: sadsack

Re: I am getting close......... - 08/25/08 22:56

Yes crumply, I did see that and changed it so it was right.
but still have the same error. What can be wrong with the main function.

Blade,
I did not know I was.
Thank you
renny
Posted By: testDummy

Re: I am getting close......... - 08/25/08 23:22

Code:
//////////////////////////////
#include <acknex.h>
#include <default.c>
var mv_v1[3];
function move_ship() {
	while(1) {
		mv_v1.x = 10 * (key_w - key_s) * time_step;
		mv_v1.y = 6 * (key_a - key_d) * time_step;
		mv_v1.z = 0;
		 // move the player using the "W", "S", "A" and "D" keys; "10" = movement speed, "6" = strafing speed
		 c_move (ME, mv_v1, nullvector, GLIDE);
		 wait(1);
	}
}
function main() {
	level_load ("");
	wait(2);	// wait until the level is loaded
	vec_set(camera.x, vector(-500, 0, -10));
	ent_create("ship.mdl", vector(0, 0, 0),move_ship);
	ent_create("land.mdl", vector(-900,2000, -400),NULL);
}	

Posted By: sadsack

Re: I am getting close......... - 08/25/08 23:37

I can see this is a hard thing to learn. For two days I been working on this with some help from all of you who have took your time to help. well, test Dummy, You code came close,but still an error. I don't know what they are talking about with this one.





This is something, to go through all of this just to make a ship move.
Well, that is how life goes
renny
Posted By: sadsack

Re: I am getting close......... - 08/26/08 00:19

Blade, I am sorry, you are right I deleted it, But it only some it. I did not know that it was still there on till you said some thing about.
I hope you can forgive me foe being so dumb.
renny
Posted By: Anonymous

Re: I am getting close......... - 08/26/08 02:37

hey sadsack
and others here too... wink

why not try this?
I just used the x component of the vector.
As well as excluded the time_step system variable.
You can place it in to multiply.
And I used the Red Dragon model too.

Code:
//////////////////////////////
#include <acknex.h>
#include <default.c>
VECTOR* mv[3];





function move_ship() {
	
	mv.x=0;
	mv.y=0;
	mv.z=0;
	
	
	while(1) {
		
		  if (key_w) vec_add(my.x,vector(7,0,0));
		  if (key_s) vec_add(my.x, vector(-7,0,0));
		  
		  
	 //	mv_v1.x = 7 *time_step;
	//	mv_v1.y = 6 * time_step;
	//	mv_v1.z = 0;
		 // move the player using the "W", "S", "A" and "D" keys; "10" = movement speed, "6" = strafing speed
		 
		 
		 
		 c_move (me, nullvector,  vector( mv.x, mv.y, mv.z), GLIDE);
		 wait(1);
	}
}




function main() {
	level_load ("");
	wait(2);	// wait until the level is loaded
	vec_set(camera.x, vector(-500, 0, -10));
	ent_create("RED_DRAGON.mdl", vector(0, 0, 0),move_ship);
	//ent_create("land.mdl", vector(-900,2000, -400),NULL);
}	
 



and the proof is in the pudding.

on start up of the program



after I pressed the w key once




cheers

Posted By: Anonymous

Re: I am getting close......... - 08/26/08 07:36

hmmmmmm......
Just wondering and trying to figure it out.
But I commented out the vector component assignments in the move_ship function.
The mv.x=...; mv.y=...; and mv.z=...;

and reassigned the ent_create command-function
in the function main() to

ent_create("RED_DRAGON.mdl", vector(-310, 0,-100),move_ship);

and it seems these intial vector component values are placed in the VECTOR* mv[3] mv.x,mv.y,mv.z automatically.
Where I don't have to make the assignments. Cause using the key_w and key_s functions work properly at the new vector assignments
given in the ent_create command-function.

new start up positions at run time....





Posted By: sadsack

Re: I am getting close......... - 08/26/08 19:06

cemetarycat you are a cat. The code works fine, that will get me going. Thank you and all the other people that helped me.
I am sorry about the two posting. I will make sure that never happen again. So I think this part of my learnning of c-lite is over with.
renny
Posted By: Anonymous

Re: I am getting close......... - 08/26/08 22:35


its cool if you double post.
And also if you need or want to put emphasis
on something or clarify something.

I don't get worked up over those kinds of things.
I have cat scratch fever and get worked up on learning and using 3d Game Studio. wink

cheers,


Posted By: sadsack

Re: I am getting close......... - 08/26/08 23:25

hey, cat
I know, 20 years in the army and 17 years working for the govt., I went through some very bad times, so I don't sweet the small stuff. But as you age there more things that you worry about, other that what other people are doing.
I sent you a few things. I hope it will help you.
renny
Posted By: Blade280891

Re: I am getting close......... - 08/26/08 23:29

soz to say cat, ure wrong it does matter if he double posts. What if every member double posts , or just every newbie , the forum will be flooded. And those that try and help will have to read through double posts.
Posted By: Anonymous

Re: I am getting close......... - 08/27/08 00:19


haha
and LoL! smile
rather read the doubly posts to get back on track and for further clarification.
But if the forums do get flooded...
I'll be building the new Noahs' Ark.
And you're invited too..two by two.


and sadsack, thanks for the emails sent.
especially on the 2d tutorials.

and get to get back on topic....
I added more code for the controls for the other 2 vector componets. The y and z vector components as well. Even added my babylon pic and change the Red Dragons' starting position too.





cheers to both


Posted By: testDummy

Re: I am getting close......... - 08/27/08 00:21

Quoting Blade28081991.
Quote:
soz to say cat, ure wrong it does matter if he double posts.

Albeit, flaming between A7 users in the "Lite-C Programming" forum category may not be a bad thing, be wary of misinterpretations (or don't).
Quoting cemetarycat.
Quote:
its cool if you double post.

That probably just means, that the user cemetarycat, that entity alone, is not severely irritated or concerned about the one specific instance of 'double posting' in scope.
However, as Blade280281991 might have suggested, 'double posting' is and / or should be 'frowned upon' as a bad practice, and new users, are and / or should be notified about the perception of the practice.

Potentially, 'double posting' does produce clutter.

Of course, these forums seem to have a nearly unacceptable level of fault, for memory and posts, and 'much' may seem 'lost' anyway.

Posted By: Anonymous

Re: I am getting close......... - 08/27/08 00:30


haha smile


I'll let the mods worry and take care of it.
But posts and things do get lost in the memory. wink
Posted By: testDummy

Re: I am getting close......... - 08/27/08 01:01

Quoting cemetarycat.
Quote:
I'll let the mods worry and take care of it.

That's probably a good stance, and it is likely a stance that many others take.

However, the mods are not paid, and some have 'variable levels of activity', so others users might offer helpful, polite indications, when unfavorable practices are encountered.
In fact, users which tactfully offer indications, might be seen as performing some form of service.
But that might rarely be the case.


In reference to the code posted by THIS and how vectors are declared in Lite-C
VECTOR* mv_v1;
as opposed to how they are declared in C-Script:
var mv_v1[3];
'I' claim fault for posting erroneous code.

The fault itself was seemingly brought to light, after examining a sample provided by cemetarycat (above).
Moreover, relevant information is found in some manuals.

This post is a sample of 'clutter'.
Posted By: Anonymous

Re: I am getting close......... - 08/27/08 01:31

first, to claim fault for posting erroneous code.
Its okay and cool. We all learn by trial and error.
Don't worry about it.

but to double post...to re-emphasize what I said and to clarify. Its cool by me. And also I'm not really that concerned with people who think and act like they are moderators and admistrators. When in fact they are not. And I don't like pushy or bossy people. In the end, we are all members and users in this forum.
Again, I let the mods and the adminstrator(s) worry about it and take care of it.

You and others can have the final say but I stand by what I think and share.

and to quote a very good friend of mine:

"Different is hard. Different is lonely. Different is trouble for you only. Different is heartache. Different is pain. Be true to yourself. I'd rather be different than be the same.
And the fip side of the coin:

Should you find yourself the victim of other people's bitterness, ignorance, smallness or insecurities; remember, things could be worse. You could be one of them! "


and oh my!
I forgot this, everybody.....

Halo Flame Shields On! smile
haha and true.
















Posted By: Blade280891

Re: I am getting close......... - 08/27/08 01:36

cemetarycat ,you are blowing this way out of proportion , and i wasnt acting like a mod or being pushy.
Posted By: Anonymous

Re: I am getting close......... - 08/27/08 01:43


haha. smile

Halo Regenerative Flame Shields On to Max.
Posted By: sadsack

Re: I am getting close......... - 08/27/08 18:58

here some code I found to movement of a object.

It may be in A6, seeing I am not up tp par yet with this program.
renny

Code:

ok, letīs see

what do we need to script a player-script?
- c_rotate (to rotate the player)
- c_move (to move the player)
- the WASD-keys (or other - a control for the user)
- ent_cycle (to animate our model): optional
- gravity
- a jump code



how to calculate the movement
Code:
--------------------------------------------------------------------------------

(key_w-key_s)*speed_factor*time+joy_force.y*time;
--------------------------------------------------------------------------------

if w or s is pressed calculate the speed. speed_factor can be rise if the player is to slow. the "time"-factor 

make it suitable for different FPS (because the player would be slower or faster on different PCs). store the 

calculated var in an temporary array (i.e. movement.x)
do the same with the sided movement (a and d)


how to rotate
do it like above to calculate the rotation (pan) of the player and store it in an array (i.e. rotation.x)


how to animate
if the movement is > 0 the player should "walk". so check the var where you have stored the calculated 

movement if itīs greater than zero. if yes play the animation:
Code:
--------------------------------------------------------------------------------

if(movement.x>0)&&(!player.flag1) //if flag1 is activated the animation would not be 

played.{ent_cycle("walk", player.animation);player.animation -= 8*time;player.animation %=100;}
--------------------------------------------------------------------------------

donīt forget to create an animation for standing too (if the movement == 0)


how to add gravity
at first you have to trace down (to check if the player is not on the bottom). so create an array, copy the 

player position (vec_set), but substract 1000 or more quants from the array. now trace (with c_trace) down
Code:
--------------------------------------------------------------------------------

c_trace(player.x, temp,ignore_me  + use_box + ignore_passable);
--------------------------------------------------------------------------------
and store the result in a var (i.e. grddist). then check if the var is greater than 1. if yes, the player isnīt on 

the bottom, so he has to fall. so substract from the movement.z a value (the greater, the faster the player 

fall) and multiply with time
if the player is already on the floor, set the movement.z to 0!! otherwise he would not stop to fall


how to jump
the player have to move up with an excreasing (the oposite of increasing  ) value.
Code:
--------------------------------------------------------------------------------

while (jump > -1)	{		movement.z = 18 * time * jump;		jump -= 0.09 * time; 

		if( grddist < 5){jump = 1;break;}		wait (1);	}jump=1;
--------------------------------------------------------------------------------
the player moves with an excreasing speed up. the value turn to a negative var till -1 or the bottom is 

reached. then the player stop to "fall" and the var will be resetted.
to make it independend from the player-code write it in another function


how to structure a player-script
itīs really simple. at first you have to calculate the needed vars. then, if you want, the jump-code, and at 

least the executing. note: we have just CALCULATED all required values. but the player wonīt move if we 

donīt execute it. this can we do with c_move and c_rotate. c_move has a collision-system, so we canīt go 

through walls. and so should (or can) your player code looks:

Code:
--------------------------------------------------------------------------------

action player{player=my;while(player==my){//calcutlaing movement//calculating rotation//calculating 

gravity//play animation//EXECUTE!if(key_space){jump();} //if space was hit, 

jump!c_rotate(player,your_angle_array,ignore_passable+glide); 

//rotate!c_move(player,movement.x,nullvector,ignore_passable+glide); //move!cam_pos(); //place the camera 

on itīs new position!wait(1);}}
--------------------------------------------------------------------------------









the camera
write a new function that places the camera (cam_pos() or so).

that the camera is turning around the player (in a circle!) if he rotate, you can calculate the position with 

sin() and cos(). so you can calculate the camera.x-position:
Code:
--------------------------------------------------------------------------------

camera.x = player.x - offset * cos(player.pan);
--------------------------------------------------------------------------------
offset is the radius between the player and the cam. calculate the camera.y too and define the height of 

the cam:Code:
--------------------------------------------------------------------------------

camera.z = player.z + cam_height;
--------------------------------------------------------------------------------
cam_height is the height-offset to the player-height and the camera-height.
but oh! the camera doesnīt look in the player-direction! change it by set the camera.pan with the 

player.pan equal 
note: the cam_pos will be executed every frame (in the playercode) so DONīT add in the cam_pos a while!


i hope it could help

Regards




I'd put the cam_pos(); after the c_move



© 2024 lite-C Forums