Gamestudio Links
Zorro Links
Newest Posts
Trading Journey
by howardR. 04/28/24 09:55
basik85278
by basik85278. 04/28/24 08:56
Zorro Trader GPT
by TipmyPip. 04/27/24 13:50
Help with plotting multiple ZigZag
by M_D. 04/26/24 20:03
Data from CSV not parsed correctly
by jcl. 04/26/24 11:18
M1 Oversampling
by jcl. 04/26/24 11:12
Why Zorro supports up to 72 cores?
by jcl. 04/26/24 11:09
Eigenwerbung
by jcl. 04/26/24 11:08
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (SBGuy, Quad), 768 guests, and 5 spiders.
Key: Admin, Global Mod, Mod
Newest Members
wandaluciaia, Mega_Rod, EternallyCurious, howardR, 11honza11
19049 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
HELP: hit detection - probably simple ?? #217456
07/23/08 09:05
07/23/08 09:05
Joined: Apr 2008
Posts: 437
dracula Offline OP
Senior Member
dracula  Offline OP
Senior Member

Joined: Apr 2008
Posts: 437
Can someone please show me how to test for hit detection so that I can terminate the while loop. At the moment, victim1 gets hit, dies but the is dragged across the ground due to the while loop continuing.
Thank you.


action victim1()
{

my.emask |= (ENABLE_IMPACT);
my.event = got_shot;

while(1)
{

c_move(my,vector(1*time_step,0,0),nullvector,0); // move ahead until obstacle is hit
wait(1);
}
}



function got_shot()
{
var anim_percentage = 0;
my.event = NULL; // the enemy is dead, so it should stop reacting to other bullets from now on
while (anim_percentage < 100) // this loop will run until the "death" animation percentage reaches 100%
{
ent_animate(my, "death", anim_percentage, NULL); // play the "death" animation only once
anim_percentage += 3 * time_step; // "3" controls the animation speed
wait (1);
}
set(my,PASSABLE); // allow the player to pass through the corpse now
}

Re: HELP: hit detection - probably simple ?? [Re: dracula] #217484
07/23/08 11:39
07/23/08 11:39
Joined: Feb 2008
Posts: 97
Steev Offline
Junior Member
Steev  Offline
Junior Member

Joined: Feb 2008
Posts: 97
I think, the while loop, for the walk-animation runs always (while(1)).

Create a flag for "alive" and set this onto false if the victim dies.

Code:
action victim1()
{
my.emask |= (ENABLE_IMPACT);
my.event = got_shot;
my.flag1 = true;
while(my.flag1)
{

c_move(my,vector(1*time_step,0,0),nullvector,0); // move ahead until obstacle is hit
wait(1);
}
}



function got_shot()
{
var anim_percentage = 0;
my.flag1 = false;
my.event = NULL; // the enemy is dead, so it should stop reacting to other bullets from now on
while (anim_percentage < 100) // this loop will run until the "death" animation percentage reaches 100%
{
ent_animate(my, "death", anim_percentage, NULL); // play the "death" animation only once
anim_percentage += 3 * time_step; // "3" controls the animation speed
wait (1);
}
set(my,PASSABLE); // allow the player to pass through the corpse now
}



Last edited by Steev; 07/23/08 12:19.

---
programming is a livestyle
Re: HELP: hit detection - probably simple ?? [Re: Steev] #217489
07/23/08 11:55
07/23/08 11:55
Joined: Apr 2008
Posts: 437
dracula Offline OP
Senior Member
dracula  Offline OP
Senior Member

Joined: Apr 2008
Posts: 437
Steev, you put me on the right track. If you look at my code, you will see I have used the Latest Lite C language changes. It's horrible to read, but it works !

Thanks Steev.


action victim1()
{

my.emask |= (ENABLE_IMPACT);
my.event = got_shot;
set(my,FLAG1);

while(is(my,FLAG1))
{

c_move(my,vector(1*time_step,0,0),nullvector,0); // move ahead until obstacle is hit
wait(1);
}
}


function got_shot()
{
var anim_percentage = 0;
reset(my,FLAG1);
my.event = NULL; // the enemy is dead, so it should stop reacting to other bullets from now on
while (anim_percentage < 100) // this loop will run until the "death" animation percentage reaches 100%
{
ent_animate(my, "death", anim_percentage, NULL); // play the "death" animation only once
anim_percentage += 3 * time_step; // "3" controls the animation speed
wait (1);
}
set(my,PASSABLE); // allow the player to pass through the corpse now
}

Re: HELP: hit detection - probably simple ?? [Re: dracula] #217503
07/23/08 13:45
07/23/08 13:45
Joined: Feb 2008
Posts: 97
Steev Offline
Junior Member
Steev  Offline
Junior Member

Joined: Feb 2008
Posts: 97
Sorry for my uggly code,

i am here at work and could not spent so much time for the forum...


---
programming is a livestyle

Moderated by  HeelX, Lukas, rayp, Rei_Ayanami, Superku, Tobias, TWO, VeT 

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