Feb 23, 2024 Replies: 1 Sure you will figure it out. A position vector and a speed vector. When it hits a vertical wall we change the direction of the x-position vector and for a horizontal wall we change the direction of the y-position vector. Change direction => position x / y = position x / y * -1 Attachments b4jSquareBounce.zip b4jSquareBounce.zip 2.3 KB · Views: 449 Last edited: Feb 23, 2024 Click to expand...
Sure you will figure it out. A position vector and a speed vector. When it hits a vertical wall we change the direction of the x-position vector and for a horizontal wall we change the direction of the y-position vector. Change direction => position x / y = position x / y * -1
Johan Schoeman Expert Licensed User Longtime User Feb 24, 2024 #2 Bouncing 200 rays simultaneously inside a square from the center of the square at increasing angles of 360/numOfRays. Sure you will figure it out how to do more than 200 rays. Code DIM's 1000 and number of rays for the attached project set to 200. B4X: Dim leftTop, rightTop, leftBottom, rightBottom, centre, ray(1000), speed(1000), oldPos(1000) As PVector B4X: numOfRays = 200 'number of simultaneous rays to be drawn and bounced Attachments b4jSquareBounce.zip b4jSquareBounce.zip 3.1 KB · Views: 388
Bouncing 200 rays simultaneously inside a square from the center of the square at increasing angles of 360/numOfRays. Sure you will figure it out how to do more than 200 rays. Code DIM's 1000 and number of rays for the attached project set to 200. B4X: Dim leftTop, rightTop, leftBottom, rightBottom, centre, ray(1000), speed(1000), oldPos(1000) As PVector B4X: numOfRays = 200 'number of simultaneous rays to be drawn and bounced