Gamestudio Links
Zorro Links
Newest Posts
AlpacaZorroPlugin v1.3.0 Released
by kzhao. 05/22/24 13:41
Free Live Data for Zorro with Paper Trading?
by AbrahamR. 05/18/24 13:28
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 (BrainSailor), 857 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
LucasJoshua, Baklazhan, Hanky27, firatv, wandaluciaia
19054 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Gravity #373266
06/08/11 19:49
06/08/11 19:49
Joined: Jun 2011
Posts: 22
Germany
B
Bennett Offline OP
Newbie
Bennett  Offline OP
Newbie
B

Joined: Jun 2011
Posts: 22
Germany
Can someone please explain me how to use simple gravity?
I am using this code for jumping, and I suppose setting a downwards speed somehow might complete it.

if(key_space)
{
c_move(my, vector(0 ,0,15*time_step), nullvector,GLIDE);

}

Re: Gravity [Re: Bennett] #373276
06/08/11 21:26
06/08/11 21:26
Joined: Apr 2009
Posts: 81
J
JakeBilbe Offline
Junior Member
JakeBilbe  Offline
Junior Member
J

Joined: Apr 2009
Posts: 81
Code:
if(key_space)
{
c_move(my, vector(0 ,0,15*time_step), nullvector,GLIDE);
else
c_move(my, vector(0,0,-15*time_step), nullvector,GLIDE;
}


something like that maybe?

Re: Gravity [Re: JakeBilbe] #373327
06/09/11 15:04
06/09/11 15:04
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Look at the last AUM! There is a gravity example!


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Gravity [Re: 3run] #373334
06/09/11 16:12
06/09/11 16:12
Joined: Jun 2011
Posts: 22
Germany
B
Bennett Offline OP
Newbie
Bennett  Offline OP
Newbie
B

Joined: Jun 2011
Posts: 22
Germany
thanks...

Hey, you're a freerunner? I'm a Traceur! what a coincidence

Re: Gravity [Re: Bennett] #373336
06/09/11 16:17
06/09/11 16:17
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Yeah I am, nice to see colleague here laugh BTW not Traceur but Tracer.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Gravity [Re: 3run] #373338
06/09/11 16:19
06/09/11 16:19
Joined: Jun 2011
Posts: 22
Germany
B
Bennett Offline OP
Newbie
Bennett  Offline OP
Newbie
B

Joined: Jun 2011
Posts: 22
Germany
sry, it's because I speak french too...
it's a habit

Re: Gravity [Re: Bennett] #373344
06/09/11 16:41
06/09/11 16:41
Joined: Jun 2011
Posts: 22
Germany
B
Bennett Offline OP
Newbie
Bennett  Offline OP
Newbie
B

Joined: Jun 2011
Posts: 22
Germany
can someone please look for n00b mistakes like curly brackets? I didn't find anything, but Acknex crashes when I run this...

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

#define STATE     skill1
#define ANIMATION skill2
function main()
{
	level_load("Puschel.wmb"); 	
}

function camera_follow(ENTITY* ent)
{
	while(1) 
	{
		vec_set(camera.x,vector(-400,0,300));  // camera position relative to the player      
		vec_rotate(camera.x,ent.pan); // rotate the camera position with the player
		vec_add(camera.x,ent.x);      // add player position
		vec_set(camera.pan,vector(ent.pan,-20,0)); // look in player direction, slighty down      
		wait(1);
	}
}

action puschel()
{
	camera_follow(me);
	
	var speed_down = 0;   // downward speed by gravity
	VECTOR vFeet;
	vec_for_min(vFeet,me); // vFeet.z = distance from player origin to lowest vertex
	my.STATE = 1;
	
	while (1)
	{
	
// state 1: walking ////////////////////////////////////////////
		if (my.STATE == 1)
		{
				if(key_space)
		{
			c_move(my, vector(0 ,0,15*time_step), nullvector,GLIDE); //jump upwards
			
			}
		}
		}
		
// determine the ground distance by a downwards trace
      var dist_down; 
      if (c_trace(my.x,vector(my.x,my.y,my.z-5000),IGNORE_ME | IGNORE_PASSABLE | USE_BOX) > 0)
         dist_down = my.z + vFeet.z - target.z; // get distance between player's feet and the ground
      else
         dist_down = 0;
		// apply gravity when the player is in the air
      if (dist_down > 0)  // above floor, fall down with increasing speed
         dist_down = clamp(dist_down,0,accelerate(speed_down,5,0.1));
      else                // on or below floor, set downward speed to zero
         speed_down = 0;
// rotate the entity with the arrow keys     
			my.pan += (key_cul-key_cur)*8*time_step;   

// move the entity forward/backward with the arrow keys
			var distance = (key_cuu-key_cud)*8*time_step;
			c_move(me, vector(distance,0,0), nullvector,GLIDE);
					
						wait(1);
				}
			}
	}



Last edited by JustSid; 06/09/11 16:44. Reason: Please use the [code] Tags for code!
Re: Gravity [Re: Bennett] #373345
06/09/11 16:44
06/09/11 16:44
Joined: May 2009
Posts: 5,370
Caucasus
3run Offline
Senior Expert
3run  Offline
Senior Expert

Joined: May 2009
Posts: 5,370
Caucasus
Here:

Code:
if (my.STATE == 1)
{
if(key_space)
{
c_move(my, vector(0 ,0,15*time_step), nullvector,GLIDE); //jump upwards

}
}
}

Organize your script better... that way it will be more easy to find mistakes.


Looking for free stuff?? Take a look here: http://badcom.at.ua
Support me on: https://boosty.to/3rung
Re: Gravity [Re: 3run] #373350
06/09/11 17:07
06/09/11 17:07
Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
Pappenheimer Offline
Senior Expert
Pappenheimer  Offline
Senior Expert

Joined: Sep 2003
Posts: 5,900
Bielefeld, Germany
You have to organize your brackets and tabs properly, then you find it easely, if there's something wrong.

Re: Gravity [Re: 3run] #373357
06/09/11 17:47
06/09/11 17:47
Joined: Jun 2011
Posts: 22
Germany
B
Bennett Offline OP
Newbie
Bennett  Offline OP
Newbie
B

Joined: Jun 2011
Posts: 22
Germany
Whats the mistake there? I don't see it

Page 1 of 2 1 2

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