The first is painfully easy. What characters do I insert to continue code onto the next line when a line gets too long? I think it's something with the backslash or forward slash, but I can't figure it out or find the answer in Dan's book (though I know it's in there somewhere).
Second, I have a large array of squares that I randomly reassign to new location with every ENTER keypress. I have the squares move with the move command. It works very well, but I need the squares to not overlap. How do I repeat the move code until there is no overlap? Is that possible?
Two quick questions
Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller
Yes, intersect
I've tried used that along inside of a repeat loop (e.g., repeat move until no collision) but the code makes it choke each time. I've gone back to the drawing board, but the code did look something like this:
repeat until (collision = false)
put random () into newlocX
put random() into newlocY
move rectangle of cd to newlocx,newlocy
if intersect (rectangle,rectangle) then (collision = true).
One problem I foresee even if I got Revolution to accept the code is that, with 15 rectangles on screen, collisions are inevitable en route. I don't care if rectangles pass through one another as long as their terminal location is a nonoverlapping one. Any additional thoughts? Do I need a background of 0's that turn to 1's with a rectangle overlap. Then, only permit a move if the terminal spot is all 0's? Would anyone know how to code that if that's my only option?
P.S., Thanks for the /, sheesh what a turkey I am!
repeat until (collision = false)
put random () into newlocX
put random() into newlocY
move rectangle of cd to newlocx,newlocy
if intersect (rectangle,rectangle) then (collision = true).
One problem I foresee even if I got Revolution to accept the code is that, with 15 rectangles on screen, collisions are inevitable en route. I don't care if rectangles pass through one another as long as their terminal location is a nonoverlapping one. Any additional thoughts? Do I need a background of 0's that turn to 1's with a rectangle overlap. Then, only permit a move if the terminal spot is all 0's? Would anyone know how to code that if that's my only option?
P.S., Thanks for the /, sheesh what a turkey I am!
Solved
Hi,
Thanks for the help. I've figured it out. For public record, intersect is only concerned with the terminal location to begin with (good for me, additional difficulty for those hoping for "contact" in motion). I used a collision and grandcollision boolean to set it up.
collision and grandcollision became true if contact was made
collision set to false if contact not made
if grandcollision was false after all object moved, then repeat loop ends.
Thanks for the help. I've figured it out. For public record, intersect is only concerned with the terminal location to begin with (good for me, additional difficulty for those hoping for "contact" in motion). I used a collision and grandcollision boolean to set it up.
collision and grandcollision became true if contact was made
collision set to false if contact not made
if grandcollision was false after all object moved, then repeat loop ends.