Gamestudio Links
Zorro Links
Newest Posts
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
Newbie Questions
by AndrewAMD. 12/04/23 11:14
Square root rule
by Smallz. 12/02/23 09:15
RTest not found error
by TipmyPip. 12/01/23 21:43
neural function for Python to [Train]
by TipmyPip. 12/01/23 14:47
Xor Memory Problem.
by TipmyPip. 11/28/23 14:23
Training with command line parameters
by TipmyPip. 11/26/23 08:42
Combine USD & BTC Pairs In Asset Loop
by TipmyPip. 11/26/23 08:30
AUM Magazine
Latest Screens
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Tactics of World War I
Who's Online Now
2 registered members (TipmyPip, izorro), 556 guests, and 2 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
bounce #103978
12/25/06 18:10
12/25/06 18:10
Joined: Dec 2005
Posts: 252
MyOwnKingdom
nipx Offline OP
Member
nipx  Offline OP
Member

Joined: Dec 2005
Posts: 252
MyOwnKingdom
Im using this code:

Code:

function _ball_event()
{
vec_to_angle(me.pan, bounce);
}

action aBall
{
my.enable_block=on;
my.enable_entity=on;
my.event=_ball_event;
.....
.....
.....

while(1)
{
c_move(me, v3Movement, nullvector, glide);
wait(1);
}
}




The ball bouces off but pretty strange.



(hope you see what I mean The thin line is the way my ball flys)


So this is not the right bounce, isnt it?

Can someone please tell me how to do it correctly?


thx nipx

Re: bounce [Re: nipx] #103979
12/25/06 23:22
12/25/06 23:22
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline
User
demiGod  Offline
User

Joined: Mar 2006
Posts: 752
Portugal
This simple code works for me:

Code:


var ball_speed[3];

function ball_hit()
{
if(event_type == event_block)
{
vec_to_angle(my.pan, bounce);
}
}

action bouncingBall
{
my.enable_block = on;
my.event = ball_hit;

while(1)
{
ball_speed.x = key_1 * 25 * time_step;
ball_speed.y = key_2 * 25 * time_step;
ball_speed.z = key_3 * 25 * time_step;
c_move(my, ball_speed, nullvector, glide);
wait(1);
}
}




Re: bounce [Re: demiGod] #103980
12/26/06 12:52
12/26/06 12:52
Joined: Dec 2005
Posts: 252
MyOwnKingdom
nipx Offline OP
Member
nipx  Offline OP
Member

Joined: Dec 2005
Posts: 252
MyOwnKingdom
It works but not well

When I use 1 the ball bounces off correctly

With 2 not It starts gliding along the wall instead of bouncing



Does your ball do that too? I tested it on 2 computers and its always the same.


thx nipx

Re: bounce [Re: nipx] #103981
12/26/06 13:11
12/26/06 13:11
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline
User
demiGod  Offline
User

Joined: Mar 2006
Posts: 752
Portugal
The code above its only for test purposes using that keys for input changing the ball_speed vector (x,y,z axis movement). If you are constantly pressing the keys the ball cant bounce because there is always a force applied on it against the wall. I didnt test but if you apply a force to the ball like ball_speed.x = 50, ball_speed.y = 80, ball_speed.z = 0 for example:

function apply_force()
{
ball_speed.x = 50;
ball_speed.y = 80;
ball_speed.z = 0;
}

on_z = apply_force;

may it will work. Hope it helps.

Re: bounce [Re: demiGod] #103982
12/26/06 13:25
12/26/06 13:25
Joined: Dec 2005
Posts: 252
MyOwnKingdom
nipx Offline OP
Member
nipx  Offline OP
Member

Joined: Dec 2005
Posts: 252
MyOwnKingdom
Quote:

cant bounce because there is always a force applied on it against the wall.




Right I didnt think about that

Anyway it still doesnt bounce as I want.



You see it still glides. But when it hits the upper wall its correct.


thx nipx

Re: bounce [Re: nipx] #103983
12/26/06 17:05
12/26/06 17:05
Joined: Dec 2005
Posts: 252
MyOwnKingdom
nipx Offline OP
Member
nipx  Offline OP
Member

Joined: Dec 2005
Posts: 252
MyOwnKingdom
Problem solved.

We were both wrong


Because vec_to_angle(my.pan, bounce) change the pan and we use reldist we dont need Movement.y.
Movement.x is enough.



nipx

Re: bounce [Re: nipx] #103984
12/26/06 17:15
12/26/06 17:15
Joined: Mar 2006
Posts: 752
Portugal
demiGod Offline
User
demiGod  Offline
User

Joined: Mar 2006
Posts: 752
Portugal
Well, i am not sure the problem its solved that way...
If you want try this code:

Code:


function ball_hit()
{
if(event_type == event_block)
{
vec_set(my.skill1, bounce);
}
}


action bouncingBall
{
my.enable_block = on;
my.event = ball_hit;
vec_set(my.skill1,vector(12*time_step,8*time_step,2*time_step));
while(1)
{
c_move(my,my.skill1,nullvector,glide);
wait(1);
}
}





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