Alice Community  

Go Back   Alice Community > Alice 2 > How do I...?

Reply
 
Thread Tools Display Modes
How to loop these.
Old
keskk
Junior Member
 
Status: Offline
Posts: 13
Join Date: Feb 2013
Default How to loop these. - 03-28-2013, 07:05 AM

I want to make a game where my character keep running forward along a path. along the way, obstacles are going to appear randomly. My character has to move, left, right or jump dependingly. (I know many similar concepts available in the market)

My question is, how do I loop the environment objects to appear randomly? Any guidance is appreciated cos no luck so far in figuring out what my loop argument should be. Without this loop, it would mean creating 10s maybe 100s of objects to place along the path which is not efficient. Have created the running, controls and procedures less the loop.

Thanks for advice.
   
Reply With Quote
How to loop these
Old
djslater107
Administrator
 
Status: Offline
Posts: 190
Join Date: Jan 2007
Default How to loop these - 03-29-2013, 07:48 AM

Add a set of objects that you would like to appear randomly... Then create an array, not a list, loading all of the objects into the array... Then generate a random number that is within the range 0 <= index < number of objects in the array (in other words, if you have 10 objects in the array, the random number should be in the range {0 .. 9}). That random number then becomes the index value of the array, and you can then place the object at ary[index] into the scene appropriately.)

Hope this helps.


Don Slater
Alice Team
Carnegie Mellon University
   
Reply With Quote
Old
keskk
Junior Member
 
Status: Offline
Posts: 13
Join Date: Feb 2013
Default 04-04-2013, 05:27 AM

Thanks for reply.

I tried out what you mentioned. I'm still unclear on how I am going to make the obstacles appear randomly. Even though it is in an array, does it still mean I need to create the total number of obstacles (lets say 50) and individually place them in their appropriate places? Or anyway I can loop it such that I create only 5 obstacles but keep repeating them along the path of the main character randomly?

One more question. For collision detection, I am able to only detect on the first obstacle. It doesn't work for other obstacles. I attached my file for reference. Appreciate any advice. Thank you.

P.S Just working out the codes first before adding any nice scenario and movements so nothing fancy in the codes yet.
Attached Files
File Type: zip zombie.zip (48.5 KB, 2 views)
   
Reply With Quote
looping question
Old
djslater107
Administrator
 
Status: Offline
Posts: 190
Join Date: Jan 2007
Default looping question - 04-04-2013, 08:08 AM

Or anyway I can loop it such that I create only 5 obstacles but keep repeating them along the path of the main character randomly?

One more question. For collision detection, I am able to only detect on the first obstacle. It doesn't work for other obstacles. I attached my file for reference. Appreciate any advice. Thank you.


5 obstacles, placing them in the path of the character by moving them from former location to new location, i.e.

(do all of these things with duration of time 0)
* pick object from array
* make it invisible
* move it to a location in the path of the main character
* make it visible

You are testing for collision on the first object in every case... You have to rest what you are testing for (and each object may have different center points that you are measuring from)


Don Slater
Alice Team
Carnegie Mellon University
   
Reply With Quote
Old
keskk
Junior Member
 
Status: Offline
Posts: 13
Join Date: Feb 2013
Default 04-04-2013, 09:47 AM

Hi,

Thanks. I got the idea for looping the obstacles.

Regarding Collision detection, slight confusion.

I am using the parameter type value as 'model' to measure, which from my understanding is universal to detect all Alice models. Moreover all the objects are the same in my case thus no difference in center points.

As you pointed out, it is only detecting the first object and nothing else. When I loop it and this first object re-appears at another spot, it is not detected too.

Sorry if you have already answered this but I'm not getting the picture. Attached the file for reference. Thank you.
Attached Files
File Type: zip zombie.zip (52.7 KB, 2 views)
   
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump



Copyright ©2024, Carnegie Mellon University
Alice 2.x © 1999-2012, Alice 3.x © 2008-2012, Carnegie Mellon University. All rights reserved.