Gamestudio Links
Zorro Links
Newest Posts
Change chart colours
by 7th_zorro. 05/11/24 09:25
Data from CSV not parsed correctly
by dr_panther. 05/06/24 18:50
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (AndrewAMD, degenerate_762, ozgur), 1,311 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
First time trying animation of an object,need some help #296241
10/30/09 14:36
10/30/09 14:36
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
I made a small room and i need to play my animation, where the door goes up. I can't even get the code to compile.
code:

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

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



ENTITY* player1;
ENTITY* elev_2;

VECTOR* object_pos = {x=0;y=0;z=0;}


PANEL* pnl_show_xyz = {
	digits(20,20,"Player Position X=%.0f",*,1,object_pos.x);
	digits(20,40,"Player Position Y=%.0f",*,1,object_pos.y);
	digits(20,60,"Player Position Z=%.0f",*,1,object_pos.z);
	flags = SHOW;
	layer = 1;
}

function act_player1()
{
	while(!me){wait(1);}
	player1 = me;
	me.ambient = 10;
	while(me)
	{
		my.pan += 3 * (key_z-key_x) * time_step;
		my.skill1 = 5 * (key_w-key_s) * time_step;
		my.skill2 = 5 * (key_a-key_d) * time_step;
		my.tilt += 3 * (key_c-key_v) * time_step;
		my.roll += 3 * (key_r-key_t) * time_step;
		c_move (me,my.skill1,nullvector,GLIDE);
		vec_set(camera.x, player1.x);
	   vec_set(camera.pan, player1.pan);
		vec_set(object_pos,player1.x);
		wait(1);
	}
}

action vertex_anim()
{
	elev_2 = my
   while() 
   {
      my.skill1 += 3*time_step;
      if (my.skill1 > 100) my.skill1 -= 100; 
      ent_animate(me,"door_open",my.skill1,ANM_CYCLE);
      wait(1);
   }
}


function main()
{
	level_load ("");
	wait(2);	// wait until the level is loaded
	ent_create("ball.mdl",vector(-500,0,0),act_player1);
	ent_create("elev_2.mdl",vector(0,0,0),vertex_anim);
	
	
	wait(2);	// wait until the level is loaded
}



It compiled fine untill I went to the manul and try to get some usefull info from it. I must not did a very good job of it. If any one can help that would be nice.

Thank You
renny


I have A7 Commercial .............. Now I just need to learn how to use it

Re: First time trying animation of an object,need some help [Re: sadsack] #296246
10/30/09 14:50
10/30/09 14:50
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
Never mind, I was doing something dumb.
renny


I have A7 Commercial .............. Now I just need to learn how to use it

Re: First time trying animation of an object,need some help [Re: sadsack] #296257
10/30/09 15:46
10/30/09 15:46
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
I'am back,

Ok, what I want is to open the door. The animation for doing that is from frame 1 to 20. Then from frame 21 to 40 is where the door comes down or close. here is some new code for opening the door.

Code:
action vertex_anim()
{

   
   {
      my.frame += .08*time_step; // gives 16/1.5 = 12 frames per second
      my.frame %= 20; // don't exceed the number of frames 
   	
     my.frame = 1; // set to start frame
while (1) { 
  my.frame += time_step; // 16 frames per second
  if (my.frame > 19) { my.next_frame = 20; } // interpolate to start frame
  else { my.next_frame =20; } // interpolate to FRAME+1
  if (my.frame >=20) { my.frame -= 20; } // if end frame reached, skip back
  wait(1); 
}



This runs to fram 20 then gos back to frame 0 and starts over again. I want it to start at frame 0 or 1 and go to frame 20 and stop the anim. there. How can i do that????
Thank you
renny


I have A7 Commercial .............. Now I just need to learn how to use it

Re: First time trying animation of an object,need some help [Re: sadsack] #296402
10/31/09 17:10
10/31/09 17:10
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
Here is some working code that will open and close the door, with animation.

Code:
action act_door()
{
   door = my;
	my.ambient = 10;
   
   {
      my.frame += .08*time_step; // gives 16/1.5 = 12 frames per second
      my.frame %= 20; // don't exceed the number of frames 
   	
     my.frame = 0; // set to start frame
while (1) { 
  my.frame += time_step; // 16 frames per second
  if(vec_dist(player1.x,my.x) < 325)//when the player get 225units from the doorit goes to c-move
  if (my.frame > 19) {my.frame = 20;}// interpolate to start frame
  else
  if (my.frame < 19) {my.frame = 0;}
  
  wait(1); 
} 
      
      
      
    
      	
      wait(2);
   }
}



renny


I have A7 Commercial .............. Now I just need to learn how to use it


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