Gamestudio Links
Zorro Links
Newest Posts
Newbie Questions
by fairtrader. 12/05/23 14:22
Zorro Trader GPT
by TipmyPip. 12/04/23 11:34
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
3 registered members (Martin_HH, steyr, alibaba), 509 guests, and 4 spiders.
Key: Admin, Global Mod, Mod
Newest Members
fairtrader, hus, Vurtis, Harry5, KelvinC
19019 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Very simple collision #225271
09/03/08 19:22
09/03/08 19:22
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
Hello,
This is is what I have going on, I have two planes that two people can fly around. The planes can shoot missiles. I have working, where the collision take place beteen the plane and the missile. I can see then bump off one and a nother. I am using c-move for all objects.

I been reading all I can find on collision. I know what basicly all the comm. do, but I am not sure how and where to use them. I could not find any collision code at all. So if some one know where there is some simple collision code let me know.

What I need to know is the most simple way of reporting a collision and the taking action when there is a collision.

I found this EVENT_IMPACT in the manual and tryed this code.

Code:
function bounce_event()
{
  if (event_type == EVENT_IMPACT)
  {
    ent_ship1(my,explode,50);
    ptr_remove(me); // disappear when hit
  }
}






But I am not sure how and where I should use this code. I could not get it to work

This is my movement code.

Code:
c_move (me,vector( -9,0,0),nullvector,GLIDE);



All I want to do is when a collision happens beteen a plane and a missile is the both are removed.

May be some one can help with this.
Thank You
renny


I have A7 Commercial .............. Now I just need to learn how to use it

Re: Very simple collision [Re: sadsack] #225310
09/03/08 22:32
09/03/08 22:32
Joined: Aug 2005
Posts: 343
Germany
HPW Offline
Senior Member
HPW  Offline
Senior Member

Joined: Aug 2005
Posts: 343
Germany
Always do a wait(1); to wait 1 frame before remove the Entity in a event function to avoid errors.

Code:
function bounce_event()
{
	if ((event_type == EVENT_IMPACT) || (event_type == EVENT_ENTITY))
	{
		ent_ship1(my,explode,50);
		wait(1);
		ptr_remove(me); // disappear when hit
	}
}

action myEntity()
{
	my.emask |= (DYNAMIC | ENABLE_IMPACT | ENABLE_ENTITY);
	my.event = bounce_event;
	while (1)
	{
		c_move (me,vector( -9,0,0),nullvector,GLIDE);
		wait(1);
	}
}


Last edited by HPW; 09/03/08 22:34.

Evil Blood (v. 0.52) RPG
Commport.de (Social Network Community)
Re: Very simple collision [Re: HPW] #225789
09/05/08 23:46
09/05/08 23:46
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
Hi,
So far I been unable to even get the code to compile, I don't know what I am doing wrong, but I am sure there is a lot I can do wrong.

I have all week end to work on this. So hopefully I should have it down pat by Monday.

here is the code I am using.
CODE:

Code:
action act_missile2()
{
missile2 = me;

my.emask |= (DYNAMIC | ENABLE_IMPACT | ENABLE_ENTITY);
	my.event = bounce_event;
while(1)
{

{c_move (me,vector( 9,0,0),nullvector,GLIDE);}
wait(1);




This is the code that should take it to the collision function

Code:

function bounce_event()
{
	if ((event_type == EVENT_IMPACT) || (event_type == EVENT_ENTITY))
	{
		ent_ship1(me);
		wait(1);
		ptr_remove(me); // disappear when hit
	}
}


this is where the collision do stuff is. the missile should hit the ship and the ship should go way.

this is the error I am getting. I don't what is undeclared.




I been reading all week about collision, and it said in the manual that you need a big hollow box around every thing for one type of collision. I do not have that. All I have is a plane that is texture as a level.

I hope some wone can help.
Thank You
renny


I have A7 Commercial .............. Now I just need to learn how to use it

Re: Very simple collision [Re: sadsack] #225834
09/06/08 09:30
09/06/08 09:30
Joined: Aug 2005
Posts: 343
Germany
HPW Offline
Senior Member
HPW  Offline
Senior Member

Joined: Aug 2005
Posts: 343
Germany
You need to order your code. First the event function and after this the missile action. Lite-C can't know there is a event function after the action if you don't tell it to Lite-C. wink
Another possibility is to declare first the event function and let the order like you have now:

Code:
function bounce_event(); // event function declaration here!

action act_missile2()
{
  missile2 = me;
  my.emask |= (DYNAMIC | ENABLE_IMPACT | ENABLE_ENTITY);
  my.event = bounce_event;
  while(1)
  {
    c_move (me,vector( 9,0,0),nullvector,GLIDE);
    wait(1);
  }
}

function bounce_event()
{
  if ((event_type == EVENT_IMPACT) || (event_type == EVENT_ENTITY))
  {
    ent_ship1(me);
    wait(1);
    ptr_remove(me); // disappear when hit
  }
}




Evil Blood (v. 0.52) RPG
Commport.de (Social Network Community)
Re: Very simple collision [Re: HPW] #225908
09/06/08 16:45
09/06/08 16:45
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
Hi,
I have a new error that I do not know what to do with it.
I wish there was a list of errors that tell what they ment.

Here the error I am getting




This is how I have the code layed out.
Code:
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

//////////////////////////////////////////////// Die in the air sucker/////////////////////////////////////////////////////////////

///////////////////////////////////////////////    Col R. D. Hampton  ////////////////////////////////////////////////////////////

#include <acknex.h>
#include <default.c>

ENTITY* ent_ship1;
ENTITY* ent_ship2;
ENTITY* missile1;
ENTITY* missile2;
ENTITY* explode;

action act_ent_ship1()
{
ent_ship1 = me;

while(1)
{
if (key_z) {me.pan += 3*time_step;}
if (key_x) {me.pan -= 3*time_step;}



 {c_move (me,vector( -1,0,0),nullvector,GLIDE);}
wait(1);
}
}

action act_ent_ship2()
{
ent_ship2 = me;
while(1)
{
if (key_n) {my.pan += 5*time_step;}
if (key_m) {my.pan -= 5*time_step;}

{c_move (me,vector( 1,0,0),nullvector,GLIDE);}
wait(1);


}
}


action act_missile1()
{
missile1 = me;
while(1)
{


{c_move (me,vector( -9,0,0),nullvector,GLIDE);}
wait(1);


}
}

function create_missile1(){

	if(ent_ship1){ //makes sure ship1 exists
		   me = ent_create("missile1.mdl", vector(ent_ship1.x, ent_ship1.y+100, ent_ship1.z),act_missile1);
	   wait(1);
		
		{vec_set(me.pan, ent_ship1.pan);}//point missile the same as jet
	
		
		
	
	}
}


function bounce_event(); // event function declaration here!

action act_missile2()
{
  missile2 = me;
  my.emask |= (DYNAMIC | ENABLE_IMPACT | ENABLE_ENTITY);
  my.event = bounce_event;
  while(1)
  {
    c_move (me,vector( 9,0,0),nullvector,GLIDE);
    wait(1);
  }
}



function create_missile2(){
	if(ent_ship2){ //makes sure ship1 exists
		me = ent_create("missile2.mdl", vector(ent_ship2.x, ent_ship2.y+100, ent_ship2.z),act_missile2);
		
		wait(1);
		
		{vec_set(me.pan, ent_ship2.pan);}//point missile the same as jet
	}
}


function bounce_event()
{
	if ((event_type == EVENT_IMPACT) || (event_type == EVENT_ENTITY))
	{
		ent_ship1(my,explode,50);
		wait(1);
		ptr_remove(me); // disappear when hit
	}
}






void main()
{
level_load ("land.wmb");
wait(2);
vec_set(camera.x,vector(0,0,6800));
vec_set(camera.pan,vector(90,-90,0));


ent_create("ship1.mdl", vector(0,1000,200),act_ent_ship1);
ent_create("land.mdl", vector(-900,2000, -400),NULL);
ent_create("ship2.mdl", vector(-100,-2500,200),act_ent_ship2);
//ent_create("missile1.mdl",vector(0,500,100),act_missile1);
{on_d = create_missile1;}
{on_j = create_missile2;}
 

}



That is about it, I just don't know what to do with a call function error. All I want to happen at this point is when the missile hit the jet they both are gone.
Yes, there is one other thing, I need the missile to be removed after a set time, let say 5 sec. I am going now to the manual and see how I can set up a timer.
Thank You
renny


I have A7 Commercial .............. Now I just need to learn how to use it

Re: Very simple collision [Re: sadsack] #225931
09/06/08 19:08
09/06/08 19:08
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
Code:
if ((event_type == EVENT_IMPACT) || (event_type == EVENT_ENTITY))
	{
		ent_ship1(my,explode,50);
		wait(1);
		ptr_remove(me); // disappear when hit
	}


The function ent_ship1 doesn't exist, so when you try to call it, the engine is going to complain.

Re: Very simple collision [Re: DJBMASTER] #225941
09/06/08 20:09
09/06/08 20:09
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
Where does this code goto ?

function bounce_event(); // event function declaration here!




where does this code goto?

my.emask |= (DYNAMIC | ENABLE_IMPACT | ENABLE_ENTITY);
my.event = bounce_event;



where does this code (function) goto?

function bounce_event()
{
if ((event_type == EVENT_IMPACT) || (event_type == EVENT_ENTITY))
{
ship1();
wait(1);
ptr_remove(me); // disappear when hit
}
}


I can see what you talking about, so I put the function on the bottom side of the main function, it still did not work. I just don't know what you are talking about. Maybe you can give me a lttle more info?
Thank You
renny


I have A7 Commercial .............. Now I just need to learn how to use it

Re: Very simple collision [Re: sadsack] #226046
09/07/08 15:37
09/07/08 15:37
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
still no luck with any collision, I can see that it is taking place. I just don't know how to detect the collision and then do something.

I see that the comm. ptr_remove just remove the pointer. The manual say this:

Quote:


This function is the opposite of the .._create functions. It can remove dynamically created as well as statically defined objects.
The pointer of a removed object becomes invalid and must not be used anymore. Removing an already removed object will cause a crash.
Entities can also be removed by the ent_remove function.




Does the object or ent. still show up on the screen?

The manual is very poor on how and where to uae the collision code.

That is where I stand, if anyone that know how to use the collision code can point where I need to go I will be greatly appreciated

Thank You
renny


I have A7 Commercial .............. Now I just need to learn how to use it

Re: Very simple collision [Re: sadsack] #226057
09/07/08 17:34
09/07/08 17:34
Joined: Nov 2007
Posts: 1,143
United Kingdom
DJBMASTER Offline
Serious User
DJBMASTER  Offline
Serious User

Joined: Nov 2007
Posts: 1,143
United Kingdom
use events. There are several pre-defined events for collision with blocks, entities, the mouse cursor, etc.

You create a function that will run when this event is fired, and there you have your collision code.

Search for events in the manual, it will explain it all.

Re: Very simple collision [Re: DJBMASTER] #226066
09/07/08 17:57
09/07/08 17:57
Joined: Aug 2008
Posts: 408
mi usa
sadsack Offline OP
Senior Member
sadsack  Offline OP
Senior Member

Joined: Aug 2008
Posts: 408
mi usa
I will try that now.
Thank You
renny


I have A7 Commercial .............. Now I just need to learn how to use it

Page 1 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