Pages: 1
Topic closed
I am trying to set couple of cars to cross the screen one by one. The distance is sort of random and the speed is random as well.
Basically in stage I use:
<when I receive[ car_started ] >
<set{ next_car }to( ) >
when I receive "car_started"
set "next_car" = "current_car" + 1
if "next_car" > total_cars
set "next_car" = 1
broadcase "start_new_car"
for each car, I set a private variable = mynum and private flag
when receive "start_new_car" it checks if "mynum" == "next_car";
if yes, wait untail "flag" == 0
then pick random number for waiting / costume etc
then show the car ; set flag = 1; set current_car = mynum;
broadcast "car_started";
glide the car to the right side
hide the car;
set back to 0
but it doesn't work unless I broadcase "car_started" after the car finish its moving. I am guessing there is restrict for the re_enter the same submodule.
How to handle it? I am trying to create a array to maintain a public flag then I can decide any empty car as "next_car" but it doesn't support array variable
The example sb file can be found from
http://cid-315164ca3f0b4b54.office.live.com/self.aspx/scratch/cross^_the^_street.sb
Thanks for the help
Offline
Well, i suppose...
Is this what you wanted? http://scratch.mit.edu/projects/ssss/1503351
Offline
Thanks for the quick reply. I apologize to make it unclear. Could you please look at my code at: http://cid-315164ca3f0b4b54.office.live.com/self.aspx/scratch/cross%5E_the%5E_street%5E_save.sb again?
My main purpose is to create an my own sprite with as much shared codes as possible.
You can see all my cars have only difference is the "mynum". So it will be easier to duplicate. This is just like to create a class then make multiple instances but I don't know if scratch support this.
Thanks again for you quick reply
Offline
Scratch doesn't support classes and instances. I'll take a look at your code.
Offline
Thanks.
I used to try the GM (game maker) and it support the class and instance but I cannot figure out how it make the collision calculation (I may have the trend to make simple things complex ) so I moved to the simple scratch.
Offline
Hmmm... could you explain what your game is supposed to do? I'd be able to help you more if I knew
Offline
the car will come from either left or right. For different level the speed will be different and the space is somehow a prime number (level related) + some random number. Also, we will have six lanes for the highest level (bidirectional). The little monkey need to cross the street to save / pick little monkey / banana.
Randomly there is a speed car come up at higher level. Just like the famous game frog cross the street.
That's what my plan.
maybe I really should use forever loop to do such things. Just like the way I am currently using
Offline
nuoyalala wrote:
the car will come from either left or right. For different level the speed will be different and the space is somehow a prime number (level related) + some random number. Also, we will have six lanes for the highest level (bidirectional). The little monkey need to cross the street to save / pick little monkey / banana.
Randomly there is a speed car come up at higher level. Just like the famous game frog cross the street.
That's what my plan.
maybe I really should use forever loop to do such things. Just like the way I am currently using![]()
Okay. I'll work on that using your base. Wouldn't you want top views of the cars instead of side views?
Offline
ScratchReallyROCKS wrote:
Okay. I'll work on that using your base. Wouldn't you want top views of the cars instead of side views?
It doesn't matter at this stage. Will that make any difference?
Offline
ScratchReallyROCKS wrote:
Okay. I'll work on that using your base. Wouldn't you want top views of the cars instead of side views?
at the same time, could you tell me which way you will like to do it? Just want to open my mind.
Thanks,
Offline
Topic closed
Pages: 1