Gamestudio Links
Zorro Links
Newest Posts
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
4 registered members (degenerate_762, AbrahamR, AndrewAMD, ozgur), 667 guests, and 8 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
Page 1 of 2 1 2
Give me gravity please #241602
12/17/08 14:34
12/17/08 14:34
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline OP
Serious User
croman  Offline OP
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
Hi,

Does anyone have a gravity script that is working? It doesnt matter if it's lite-c or c-script(i'll convert it) just that it's a working gravity script.
Please...:)

Thnx



Ubi bene, ibi Patria.
Re: Give me gravity please [Re: croman] #241609
12/17/08 15:58
12/17/08 15:58
Joined: Aug 2003
Posts: 7,439
Red Dwarf
Michael_Schwarz Offline
Senior Expert
Michael_Schwarz  Offline
Senior Expert

Joined: Aug 2003
Posts: 7,439
Red Dwarf
c_move(me, vector(0,0,-9), nullvector, IGNORE_ME);


"Sometimes JCL reminds me of Notch, but more competent" ~ Kiyaku
Re: Give me gravity please [Re: Michael_Schwarz] #241611
12/17/08 16:26
12/17/08 16:26
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Mathematically it should be:
Quote:
y(t) == y(0) + v(0) t + (1/2) g t2

where:
* y(t), height depending on time;
* y(0), starting height;
* v(0), starting speed;
* g, acceleration ( gravitational acceleration g is 9.98 on earth, 3.73 on mars);
* t, time.


In the example of a falling panel:
Code:
if (falling == true) {
  panel.pos_y = fallheight + (0 * falltime) + 0.5 * 9.98 * (falltime*falltime); //gravity formula, change (0 * falltime) for giving an initial speed
  falltime += time_step; //falltime is counting
}

if (falling == false) {
  falltime = 0; //reset falltime
  fallheight = panel.pos_y; //record height as long as we're on ground, can then be used as initial height when in the air
}


Last edited by Joozey; 12/17/08 16:44.

Click and join the 3dgs irc community!
Room: #3dgs
Re: Give me gravity please [Re: Joozey] #241615
12/17/08 16:53
12/17/08 16:53
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline OP
Serious User
croman  Offline OP
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
thnx. i'll try to implement that method smile but i hoped that someone has a piece of code with c_trace and c_move and everything else for gravity



Ubi bene, ibi Patria.
Re: Give me gravity please [Re: croman] #241618
12/17/08 17:10
12/17/08 17:10
Joined: Oct 2004
Posts: 4,134
Netherlands
Joozey Offline
Expert
Joozey  Offline
Expert

Joined: Oct 2004
Posts: 4,134
Netherlands
Then use Michael's approach? smile


Click and join the 3dgs irc community!
Room: #3dgs
Re: Give me gravity please [Re: Joozey] #241619
12/17/08 17:13
12/17/08 17:13
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline OP
Serious User
croman  Offline OP
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
i tried :P
i stuck quite often.
i even tried to use that khmovement gravity but it has some major problems with lite-c - dont know why

well it seems i'll use yours approach smile



Ubi bene, ibi Patria.
Re: Give me gravity please [Re: croman] #241621
12/17/08 17:29
12/17/08 17:29
Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
Quad Offline
Senior Expert
Quad  Offline
Senior Expert

Joined: Oct 2007
Posts: 5,210
İstanbul, Turkey
this was from Davids khmovement tut i guess(only the gravity part)

Code:
#define jumping_height 20
		vec_set(vec1_from,my.x);
		vec_set(vec1_to,my.x);
		vec1_to.z -= 1000;
	height = c_trace(vec1_from, vec1_to,IGNORE_ME|IGNORE_PASSABLE|IGNORE_SPRITES|USE_BOX); 
		
		if (key_space)
		{
			if (height < 2)
			{
				height = 1;
				move_vec.z = jumping_height*time_step;
			}
		}
		
		if (height > 0)
		{
			move_vec.z-=3 * time_step;
		  	if (move_vec.z < (height * -1))
			{
				move_vec.z = height * -1;
			}
		}
		else
		{
			move_vec.z = -1 * height;
		}
		
		c_move(me, move_vec, nullvector,GLIDE|IGNORE_SPRITES|IGNORE_PASSABLE|USE_BOX);


you have to definfe move_vec,height and such ofc.

Last edited by Quadraxas; 12/17/08 17:29.

3333333333
Re: Give me gravity please [Re: Quad] #241622
12/17/08 17:34
12/17/08 17:34
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Hint:
use two c_move instructions.
One for gravity, the other one for movement in x and y direction.
This hint is also given in the manual by the way.

Re: Give me gravity please [Re: Xarthor] #241624
12/17/08 17:53
12/17/08 17:53
Joined: Nov 2007
Posts: 1,032
Croatia
croman Offline OP
Serious User
croman  Offline OP
Serious User

Joined: Nov 2007
Posts: 1,032
Croatia
thnx Quadraxas

Xarthot, i will. can you explain why exactly?



Ubi bene, ibi Patria.
Re: Give me gravity please [Re: croman] #241627
12/17/08 18:25
12/17/08 18:25
Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
Xarthor Offline
Expert
Xarthor  Offline
Expert

Joined: Jul 2002
Posts: 4,436
Germany, Luebeck
The manual states that it might come to collision problems (getting stuck in the ground e.g.) if you use it in one instruction.
I currently have no further information available.

Page 1 of 2 1 2

Moderated by  adoado, checkbutton, mk_1, Perro 

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