2016년 12월 17일 토요일

Drop multiple balls at random times


I have been working on creating a simple ball catch type of game.  Mostly I have been able to figure out what I need to do, but I am having trouble with one part.  (I have read through all the FAQs and watched many tutorials and still need this help if possible)

I have a santa sled that goes back and forth at the top of the screen.  I am looking to have presents "fall" off of it at random times. (The presents need to fall from the sled, not random points in the sky)

also,  I am looking to make it so more than one present can be on the screen at one time.

Something like:
Every 1000 milliseconds SantaSprite "drops" PresentSprite

I have tried several clock events but cannot make it happen.  Any assistance would be great.  Thank you

-- 
It would really help if you provided a screenshot of your relevant blocks, so we can see what you are trying to do, and where the problem may be.

-- 

Here are the blocks I have (that seem to work one time only) and a pic + explanation of what I am trying to do

The Grinch at the top flies back and forth.  With the blocks I have, I can have him drop 1 present.  But what I am looking for is:

He can drop multiple presents at random places  from his flight path

--
You will need to keep two lists of sprites for your falling presents:
All_Presents and Falling_Presents.

AT game initialize time, set Falling_Presents to create_empty_list, and
Reserve_Presents to a make_list of the component blocks for all of your sprites, 
however many you pulled into the Designer.
Loop thru Reserve_Presents to set them all invisible and inactive.

In your game timer, if Santa is flying and dispensing, check if the
Reserve_Presents list is empty or not.
If empty, do nothing, else take the sprite at slot 1 of Reserve_Presents 
and add it to the Falling_Presents list, then set its X and Y to Santa's location,
set it visible and active, and give it a speed and heading to make it start falling down.

Create a ground-level sprite to catch the falling presents, under the player sprite.

When the  ground-level sprite gets a hit with OTHER, find the index of OTHER in  the Falling_Presents list
so you can remove it and add it back on to Reserve_Presents , then set it invisible , inactive.

When the  player sprite gets a hit with OTHER, find the index of OTHER in  the Falling_Presents list
so you can remove it and add it back on to Reserve_Presents , then set it invisible , inactive.
Also add 1 to your caught present counter.

-- 
I must not be understanding something because I cannot see how the tables work to call the present.  I downloaded an app called Cone Crasher because that uses the same table set-up that you are discussing and it still makes no sense to me.  

Any chance you could help explain it to me?  I don't mean for you to do the work...I am here to learn to do it myself...but I am just not understanding this.

-- 
Have you done the Mole Mash tutorial yet?
It uses similar concepts.

-- 

댓글 없음:

댓글 쓰기