Gamestudio Links
Zorro Links
Newest Posts
New FXCM FIX Plugin
by flink. 06/04/24 07:30
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (AndrewAMD, LorraineJones, VoroneTZ, Akow), 1,446 guests, and 10 spiders.
Key: Admin, Global Mod, Mod
Newest Members
AemStones, LucasJoshua, Baklazhan, Hanky27, firatv
19058 Registered Users
Previous Thread
Next Thread
Print Thread
Rating: 3
Page 2 of 2 1 2
Re: Newton skripting [Re: Drew] #39172
01/28/05 19:40
01/28/05 19:40
Joined: Aug 2004
Posts: 593
Germany
Efrint Offline OP
Developer
Efrint  Offline OP
Developer

Joined: Aug 2004
Posts: 593
Germany
hi, the people in the newton forum cant help me . Do you know what i can do? My script is at the top of the first page. Please help me although its a newton question!

Efrint

Re: Newton skripting [Re: Efrint] #39173
01/29/05 11:18
01/29/05 11:18
Joined: Oct 2002
Posts: 2,256
Oz
L
Locoweed Offline
Expert
Locoweed  Offline
Expert
L

Joined: Oct 2002
Posts: 2,256
Oz
Hi Efrint,
I tried to translate your original message. That did not go so well. I am not sure where you should really put Newton question. I would think as long as you put Newton in the title either here or in Scripting forum would be about as good as anywhere. That's just my opinion.

Anyway, you can create a Newton moving with cursor bouncing ball by adding a new Newton material to the newtonScript2.wdl

Add this new newton material variable in declarations:

var rubber_material;

Add these skills in Declarations:

define SPEED_X, skill9;
define SPEED_Y, skill10;
define SPEED_Z, skill11;
define move_me, skill12;


Add this below NewtonWoodEnt action:

// uses mass, linear_drag, angular_drag_x, angular_drag_y, angular_drag_z, health, shape_factor, collision_groupId, collision_sph_box, start_active, compound_collision, destructible, spawn_children;
action NewtonBallEntity
{
NewtonCreateGravityEntity (rubber_material);

while (1)
{

if (key_cuu == on)
{
my.speed_x = 2 * time;
}
if (key_cud == on)
{
my.speed_x = -2 * time;
}
if (key_cul == on)
{
my.speed_y = 2 * time;
}
if (key_cur == on)
{
my.speed_y = -2 * time;
}
if ((key_cuu == off) && (key_cud == off))
{
my.speed_x = 0;
}
if ((key_cul == off) && (key_cur == off))
{
my.speed_y = 0;
}

if(my.SPEED_X || my.SPEED_Y)
{
my.MOVE_ME = ON;
NewtonGSScriptEvent();
my.MOVE_ME = OFF;
}
wait(2);
}
}

Add this in NewtonGSScriptEvent function:

if(my.MOVE_ME == ON)
{
// copy impact point on target
newtonImpulseRecord[0] = my.x;
newtonImpulseRecord[1] = my.y;
newtonImpulseRecord[2] = my.z;

// copy direction of push force
newtonImpulseRecord[3] = my.x - my.SPEED_X;
newtonImpulseRecord[4] = my.y - my.SPEED_Y;
newtonImpulseRecord[5] = my.z + .1; // give some top spin

// copy the push mass
newtonImpulseRecord[6] = 10;

// copy the some push speed, you may have to play with this
newtonImpulseRecord[7] = 5;

NewtonBodyAddImpulse (body, newtonImpulseRecord);
}

Add this in the NewtonSetupSystem() function: (notice how I set elasticity to .9)

// set material interaction propeteries (rubber_material, rubber_material)
NewtonMaterialSetFriction (rubber_material, rubber_material, 1.0, 1.0);
NewtonMaterialSetElasticity (rubber_material, rubber_material, 0.9);
NewtonMaterialSetDepthRecover (rubber_material, rubber_material, 0.2);

Now you can save newtonScript2.wdl. Close WED if it is open. Open WED place a sphere in your level. Place it up in the air. Open properties-behavior. Set action to NewtonBallEnt, set mass = 1.0, linear_drag, angular_drag_x,_y,_z all to 0.1. Check the flags for collison_sph_box and start_active. Build the level and run. The ball should fall from the air and bounce up and down a while. Use cursor keys to move.

That reminds me, when I added blocks to level the the newton_ball.mdl that came with Newton would pass through them for some reason. I made my own sphere(ball) model and it worked fine.

I hope that is close to what you wanted. It may need some fine tuning, but that ball moves, bounces around, and spins, so it should get you started.

Later,
Loco

Last edited by Locoweed; 01/29/05 13:58.

Professional A8.30
Spoils of War - East Coast Games
Page 2 of 2 1 2

Moderated by  HeelX, Spirit 

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