The Daily Click ::. Forums ::. Klik Coding Help ::. Handling simultaneous events
 

Post Reply  Post Oekaki 
 

Posted By Message

»xerus



Registered
  28/06/2002
Points
  675

You've Been Circy'd!Game of the Week Winner
15th July, 2006 at 03:03:01 -

The situation is this:

I have enemies that have an "attack timer" value, that is only being added to while they are on the screen. When their attack timer reaches a certain value, they create a bullet. This bullet is an object that can bounce around the screen. When the bullet is created, its xSpeed, ySpeed, and life span are set (All alterable values, of course.)

It works just fine, as long as only one of the enemies on screen is firing. If two enemies fire at the same time, only one of the bullets will recieve the proper values. The other is left just bouncing in place since it doesnt have a proper xSpeed value or anything.

Is there an easy work around for this?

 
n/a

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
15th July, 2006 at 03:08:01 -

Well, it should work the way you described it. I'd really need to see your code to solve that one

 
n/a

»xerus



Registered
  28/06/2002
Points
  675

You've Been Circy'd!Game of the Week Winner
15th July, 2006 at 03:20:24 -

Alright well I can type out the lines that are in question:

Attack Timer of (Shooting Enemy) = 200
X position of (Player) > X("Shooting Enemy")
(Shooting Enemy): Change animation sequence to Shoot
(Create): Create (Bullet) at (0,0) from (Shooting Enemy)
(Bullet): Set xSpeed to 1
(Bullet): Set ySpeed to (4+Random(3))*-1
(Bullet): Set Lifespan to 150
(Sound): Play sample zap

Attack Timer of (Shooting Enemy) = 200
X position of (Player) <= X("Shooting Enemy")
(Shooting Enemy): Change animation sequence to Shoot
(Create): Create (Bullet) at (0,0) from (Shooting Enemy)
(Bullet): Set xSpeed to -1
(Bullet): Set ySpeed to (4+Random(3))*-1
(Bullet): Set Lifespan to 150
(Sound): Play sample zap

Okay, so if there are two enemies on the screen that reach 200 in their attack timers at the same exact time, there will be two bullets created. However, only one of those bullets will get the events:

(Bullet): Set xSpeed to -1
(Bullet): Set ySpeed to (4+Random(3))*-1
(Bullet): Set Lifespan to 150

And the other one will have the default values.


 
n/a

Del Duio

Born in a Bowling Alley

Registered
  29/07/2005
Points
  1078

GOTW WINNER CUP 1!GOTW WINNER CUP 2!GOTW WINNER CUP 3!GOTW WINNER CUP 4!Evil klikerHasslevania 2!The OutlawSanta Boot
15th July, 2006 at 07:45:33 -

Instead of creating a bullet and moving it, would it be better to have the "shoot an object" event instead?

EDIT: I just re-read your post, maybe not!

Image Edited by the Author.

 
--

"Del Duio has received 0 trophies. Click here to see them all."

"To be a true ninja you must first pick the most stealthy of our assorted combat suits. Might I suggest the bright neon orange?"

DXF Games, coming next: Hasslevania 2- This Space for Rent!

Klikmaster

Master of all things Klik

Registered
  08/07/2002
Points
  2599

Has Donated, Thank You!You've Been Circy'd!VIP MemberPS3 Owner
15th July, 2006 at 09:41:37 -

Hmm, that is a cufuffle, looks ok to me :/

 
n/a

axel

Crazy?

Registered
  05/02/2005
Points
  4766

Game of the Week WinnerYou've Been Circy'd!
15th July, 2006 at 09:47:58 -

=/

 
n/a

Knudde (Shab)

Administrator
Crazy?

Registered
  31/01/2003
Points
  5125

Has Donated, Thank You!Clickzine StaffKlikCast StarVIP MemberGhostbuster!Dos Rules!I donated an open source project
15th July, 2006 at 10:27:08 -

Here's your solution.

Bullet.Flag0 = Off - (Set your values here), Set Bullet.Flag0 = On


 
Craps, I'm an old man!

Fifth

Quadruped

Registered
  07/05/2003
Points
  5818

VIP MemberGOTW JULY 2010 WINNER!Kliktober Special Award TagGOTW HALLOWEEN 2011 WINNERPicture Me This Round 51 Winner!
15th July, 2006 at 14:46:04 -

H'm, I don't know if this'd be a defining factor, but when comparing the position of an enemy and a player, you should always do it relative to the enemy.

That is, instead of this:

X("Player") > X("Shooting Enemy")

Do this:

X("Shooting Enemy") <= X("Player")

That way it'll test through all of enemies, instead of just once through the player.

 
Go Moon!

»xerus



Registered
  28/06/2002
Points
  675

You've Been Circy'd!Game of the Week Winner
15th July, 2006 at 14:58:42 -

Thanks for the responses guys.

I redid it using a flag for the bullets and it seems to work. ;D

 
n/a
   

Post Reply



 



Advertisement

Worth A Click