Gamestudio Links
Zorro Links
Newest Posts
Executing Trades on Next Bar Open
by Zheka. 06/20/24 14:26
Lapsa's very own thread
by rki. 06/19/24 11:27
A simple game ...
by VoroneTZ. 06/18/24 10:50
Face player all the time ...
by bbn1982. 06/18/24 10:25
Zorro Beta 2.61: PyTorch
by jcl. 06/10/24 14:42
New FXCM FIX Plugin
by flink. 06/04/24 07:30
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (RealSerious3D, rvl), 1,187 guests, and 7 spiders.
Key: Admin, Global Mod, Mod
Newest Members
squik, AemStones, LucasJoshua, Baklazhan, Hanky27
19060 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
action player #385739
10/23/11 02:13
10/23/11 02:13
Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
F
Funeral Offline OP
Junior Member
Funeral  Offline OP
Junior Member
F

Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
hi, i wanna know how to make the player to perform an action for a certain time. for insteance, i press the key space and it walks for 3 seconds and then stops.

Re: action player [Re: Funeral] #385740
10/23/11 02:24
10/23/11 02:24
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
var counter = 48; // 16ticks * 3 = 3 seconds
while(counter > 0)
{
walk
counter -= time_step;
wait(1);
}


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: action player [Re: Superku] #385743
10/23/11 05:47
10/23/11 05:47
Joined: Oct 2008
Posts: 513
Carlos3DGS Offline
User
Carlos3DGS  Offline
User

Joined: Oct 2008
Posts: 513
EDIT: nevermind...

Last edited by Carlos3DGS; 10/23/11 05:48.

"The more you know, the more you realize how little you know..."

I <3 HORUS
http://www.opserver.de/ubb7/ubbthreads.php?ubb=showflat&Number=401929&page=1
Re: action player [Re: Carlos3DGS] #385850
10/25/11 02:24
10/25/11 02:24
Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
F
Funeral Offline OP
Junior Member
Funeral  Offline OP
Junior Member
F

Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
it works fine except for one prob: it only allows me to do it once. i press space and it does what i want, but then if i press the key again it doesnt do the movement anymore

Re: action player [Re: Funeral] #385852
10/25/11 08:12
10/25/11 08:12
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
Code:
action a_player(){
  while(me){
    if(key_space){
      //Superku's code here
    }
    wait(1);
  }
}



Re: action player [Re: MrGuest] #385950
10/26/11 00:16
10/26/11 00:16
Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
F
Funeral Offline OP
Junior Member
Funeral  Offline OP
Junior Member
F

Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
Originally Posted By: MrGuest
Code:
action a_player(){
  while(me){
    if(key_space){
      //Superku's code here
    }
    wait(1);
  }
}



yeah that's exactly what i have but after doing the action once it just doesnt wanna do it again when i press the key again

CODE

if(key_space)
{
while(counter > 0)
{

c_move(me,vector(10*time_step, 0, 0),vector(0, 0, 0), GLIDE);
counter -= time_step;
wait(1);
}
}

Re: action player [Re: Funeral] #385951
10/26/11 00:26
10/26/11 00:26
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
Originally Posted By: Funeral
Originally Posted By: MrGuest
Code:
action a_player(){
  while(me){
    if(key_space){
      //Superku's code here
    }
    wait(1);
  }
}



yeah that's exactly what i have but after doing the action once it just doesnt wanna do it again when i press the key again

CODE

if(key_space)
{
while(counter > 0)
{

c_move(me,vector(10*time_step, 0, 0),vector(0, 0, 0), GLIDE);
counter -= time_step;
wait(1);
}
}
That's obviously not exactly what you have otherwise it'd be working
Code:
#include <acknex.h>
#include <default.c>

action a_player(){
	
	my.pan = 45;
	while(me){
		
		if(key_space){
			
			//Superku's code here
			var counter = 48; // 16ticks * 3 = 3 seconds
			while(counter > 0){
				c_move(me, vector(10*time_step, 0, 0), nullvector, NULL);
				counter -= time_step;
				wait(1);
			}
		}
		wait(1);
	}
}

void main(){

	level_load(NULL);
	ent_create(CUBE_MDL, vector(250, -150, 0), a_player);
}

Where's while(me)?

Re: action player [Re: MrGuest] #385952
10/26/11 00:42
10/26/11 00:42
Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
F
Funeral Offline OP
Junior Member
Funeral  Offline OP
Junior Member
F

Joined: Dec 2008
Posts: 83
Buenos Aires, Argentina
while its on top of the player code but its "while(1)" ahyway i changed it by (me) but its the same. the whole its long becaus eit has a some other movements is this

var floor;
var gm_percentage;
var stand_percentage;
var jump = 0;
var SJ = 0;
var Q = 0;
var J = 0;
var js = 0;
var rt = 0;
var s = 0;
var z = 0;
var counter = 10;
var peeking = 0;
var air = 0;




function main()
{
level_load("prog.wmb");
}
function still()
{
c_move(me,nullvector,vector(0, 0, 0), GLIDE);
}

action player_script()
{
player = my;
var distance, angle;

VECTOR temp;
distance = 100;
angle =0;
while(me)
{
if(player)
{
camera.x = player.x-distance*cos(angle);
camera.y = player.y-distance*sin(angle);
camera.z = player.z+20;

vec_set(temp,player.x);
vec_sub(temp,camera.x);
vec_to_angle(camera.pan,temp);

angle -= (joy_5-joy_6)*4*time_step;
angle %= 360;

ent_animate(me,"stand",stand_percentage, ANM_CYCLE); // "walk" animation loop
stand_percentage += 4* time_step;

if(joy_force.x)
ent_animate(me,"gm",gm_percentage, ANM_CYCLE); // "walk" animation loop
gm_percentage += 10* time_step;
if(joy_force.y)
ent_animate(me,"gm",gm_percentage, ANM_CYCLE); // "walk" animation loop
gm_percentage += 10* time_step;



c_move(me,vector(0, 0, 0),vector(0, 0, -0.7), GLIDE);




vec_set(temp.x, my.x);
temp.z -= 10000;
floor = c_trace(my.x, temp.x, IGNORE_ME | IGNORE_PASSABLE | USE_BOX | GLIDE); // compute the distance between player's origin and the floor below its feet


if(joy_4 && floor < 30 && jump == 0 && J == 0)
{
jump = 1;
}
if(jump == 1)
{

c_move(me,vector(0, 0, 20*time_step), nullvector, GLIDE);
J = 1;
}
if(floor > 30)
{
jump = 2;
}
if(floor < 1 && !joy_4)
{
jump = 0;
J = 0;
}

////////////////////////////////////////////
if(joy_7 && floor < 1)
{
still();
}
else
{
c_move(me, nullvector, vector(joy_force.y * 3 * time_step, -joy_force.x * 3 * time_step, 0), GLIDE);
}
//////////////////////////////////////////////////////

vec_to_angle(my.pan, vector(sign(joy_force.x),sign(joy_force.y),0));
my.pan -= 0;

/////////////////////////////////////////
if(!joy_4 && joy_7)
{
z = 1;
}



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

if(z == 1 && joy_4 && floor < 60 && SJ == 0 && js == 0)
{

SJ = 1;

}
if(SJ == 1)
{

c_move(me,vector(0, 0, 10*time_step), nullvector, GLIDE);
js = 1;
}
if(floor > 60)
{
SJ = 2;
}
if(floor < 1 && !joy_7)
{
SJ = 0;
js = 0;
z = 0;
}
///////////////////////////////////////////////////////////////////////////
if(!joy_7 && floor > 1)
{
s = 1;
}
if(s == 1 && floor > 1 && joy_7)
{
c_move(me,vector(0, 0, -20*time_step), nullvector, GLIDE);
}
if(floor < 1)
{
s = 0;
}
////////////////////////////////
if(!joy_4 && floor > 1)
{
air = 1;
}
if(air == 1 && floor > 1 && joy_4)
{
c_move(me,vector(0, 0, 2*time_step), nullvector, GLIDE);
}
if(floor < 1)
{
air = 0;
}

/////////////////////////////////////////////////
if(key_space)
{
while(counter > 0)
{

c_move(me,vector(10*time_step, 0, 0),vector(0, 0, 0), GLIDE);
counter -= time_step;
wait(1);
}

}





}

wait(1);

}
}

Re: action player [Re: Funeral] #385954
10/26/11 01:20
10/26/11 01:20
Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Superku Offline
Senior Expert
Superku  Offline
Senior Expert

Joined: Sep 2003
Posts: 6,861
Kiel (Germany)
Your code is different to MrGuest's and my advice, the mistake is obvious: You've removed "counter = 48;" from the line before the while(counter > 0) loop, i.e. you only set it once to a value (10) above zero. The next time you press key_space, counter will be of course < 0 and thus the while loop will never be executed.

Btw. it's horrible to look at this code without indentation, next time please use the [code ] my code here [/code ] tags (without the spaces between code and ]).


"Falls das Resultat nicht einfach nur dermassen gut aussieht, sollten Sie nochmal von vorn anfangen..." - Manual

Check out my new game: Pogostuck: Rage With Your Friends
Re: action player [Re: Funeral] #385955
10/26/11 01:21
10/26/11 01:21
Joined: Jul 2008
Posts: 1,178
England
M
MrGuest Offline
Serious User
MrGuest  Offline
Serious User
M

Joined: Jul 2008
Posts: 1,178
England
It's impossible to see what's going on in your code, your naming convention should have some representation of what the variables are doing

SJ, js and rt mean nothing to me and won't do to you in a couple of weeks after you close this file.

use [ code ] [ /code ] tags when you post that much code so it stays indented

remove everything you don't need and just get the basics working

and ensure you've attached the player_script to the player.

once you've done that I'll have another look

Page 1 of 2 1 2

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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