view.x,y& rand-->still problems with screen range

Non-platform specific questions.

view.x,y& rand-->still problems with screen range

Postby Just4Fun » Thu Apr 22, 2004 2:10 pm

Quote:
Makslane wrote: Try this:

x = (rand(40) - 20) + your_x_center;
This will make the actor around your x center with the range:
your_x_center - 20 to your_x_center + 20


I'm still having trouble with this. Please,anyone,help.

My screen coordinates for view.x are:

-360 (left upper corner)
-160 (right upper corner)
-260 (x center) ??

My screen coordinates for view.y are:

-130 (left upper corner)
130 (Lower left corner)
0 (y center) ??


Please show me the code for this. I have tried your example over and over. I have tried many senarios but I think I'm missing something.


Here is how I think it should work, but it doesn't:

x or y= rand (a random number from 0 to some number) - ( distance from actor's x or y center) + (view.x center or view.y center)

The actor should move between the view.x (-360) and view.x (-160) coordinates and view.y (-130) to (130) at rand locations.

I'm sorry to be so slow about this. If I can ever get the proper code through my head, my next very simple activation region demo will be pretty much done. TIA
Last edited by Just4Fun on Fri Apr 23, 2004 12:49 am, edited 1 time in total.
I've learned that I still have a lot to learn.

** Makslane == Genious **
Just4Fun
 
Posts: 524
Joined: Tue Jul 01, 2003 5:19 am
Location: USA: Washington State; West Coast
Score: 6 Give a positive score

Postby jazz_e_bob » Thu Apr 22, 2004 8:14 pm

Good morning.

I empathize with your frustration.

I must go to work this morning but I will look at your problem later today.

jazz
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby makslane » Thu Apr 22, 2004 11:12 pm

x = (rand(200) - 100) + (-260);
y = (rand(260) - 130) + 0;

I think this works
makslane
Site Admin
 
Posts: 3947
Joined: Sat Apr 05, 2003 6:47 pm
Score: 182 Give a positive score

Postby jazz_e_bob » Fri Apr 23, 2004 3:45 am

I'll see how you go with the previous post... :wink:
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby Just4Fun » Fri Apr 23, 2004 3:23 pm

jazz-e-bob,
Would you try to explain to me what is happening with this code. I need to understand it before I can apply it to my situation. The math doesn't seem to give me the boundries that I am after. I think I understand, but the logic isn't working... :?: Thank you...
I've learned that I still have a lot to learn.

** Makslane == Genious **
Just4Fun
 
Posts: 524
Joined: Tue Jul 01, 2003 5:19 am
Location: USA: Washington State; West Coast
Score: 6 Give a positive score

Postby jazz_e_bob » Fri Apr 23, 2004 8:19 pm

makslane wrote:x = (rand(200) - 100) + (-260);
y = (rand(260) - 130) + 0;


Yep

x is a random number between -360 and -160
y is a random number between -130 and 130

Don't forget:
The view is positioned from its upper left corner.
Actors are positioned from their centre.

Hope this helps. :)
Controlling complexity is the essence of computer programming.
User avatar
jazz_e_bob
 
Posts: 742
Joined: Tue Jul 01, 2003 9:38 pm
Location: Bloke from Cockatoo Creek Australia
Score: 14 Give a positive score

Postby Just4Fun » Fri Apr 23, 2004 9:09 pm

*Maybe* I just got it!

Does this mean that the -360 to -160 would always be at least the rand distance generated in x,y away from the actor? So, when I figured my coordinates based on the view, they would not work because my rand actor moves to different parts of the screen so sometimes the number generated would push the actor off a part of the screen? In this case, the logic I tried to use would not work for the application needed (restriction of random object movement to the screen boundries)?
-----------------------------
-360 to -160
**********************
**********************
**********************
**********************
******************* Actor
**********************
------------------------------
I've learned that I still have a lot to learn.

** Makslane == Genious **
Just4Fun
 
Posts: 524
Joined: Tue Jul 01, 2003 5:19 am
Location: USA: Washington State; West Coast
Score: 6 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest