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
1 registered members (AndrewAMD), 1,014 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
Hanky27, firatv, wandaluciaia, Mega_Rod, EternallyCurious
19051 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
speed problem #296903
11/03/09 19:45
11/03/09 19:45
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
Hello,
What I am trying to do, is when you press a key, lets say w, the
ship stars moving forward very slowly, every cycle the speed keep going faster. then when you press key s you start slowying slow down.
here my code:

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

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



ENTITY* player1;

var h_speed = 0;


function act_player1()
{
	while(!me){wait(1);}
	player1 = me;
	me.ambient = 10;
	while(me)
	{ 
	   	if (key_w)
	   	  h_speed = .01 + .01;
	         {c_move (me,vecto(h_speed,0,0),nullvector,GLIDE);}
		my.pan += 3 * (key_z-key_x) * 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, vector(player1.x, player1.y, player1.z + 25));
	   vec_set(camera.pan, player1.pan);
	
		wait(1);
	}
}




function main()
{
	level_load ("platform.wmb");
	wait(2);	// wait until the level is loaded
	ent_create("ship.mdl",vector(-900,0,150),act_player1);
	
	
	
	wait(2);	// wait until the level is loaded
}



I should be going up in speed when I press "w". But I am going the same speed all the time.

Thank you
renny


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

Re: speed problem [Re: sadsack] #296913
11/03/09 20:17
11/03/09 20:17
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
Hi,
The code that works very good is:


Code:
if (key_w)
	   	  h_speed = h_speed += 00.01;
	         {c_move (me,vector( h_speed,0,0),nullvector,GLIDE);}
	         
	      if (key_s)
	   	  h_speed = h_speed -= 00.01;
	         {c_move (me,vector( h_speed,0,0),nullvector,GLIDE);}



Very smooth speed up and speed down.

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