Share My Creation Bouncing balls in a 3D box with collision detection

Hi,

I wanted to do a small experiment, to use Android View rotation capabilities to do some of the work for me for a very simple 3D app, simulating perspective (there are some posts and snippets of view rotation here in the forum)
Android views can rotate on different axes and pivot points. So I thought that I could use them to emulate the walls of a box viewed from the front. I thought that for a square box, 45 degrees on each side would produce a nice perspective.. In my device, the good value (trial and error) has been 47º, I suppose that it is because I haven't taken into account camera position and a 'real' equation set. But it works ok.

(2nd edit) Added an example with 3 balls and a simple collision detector

The code is made just with a timer and a direction vector. One canvas for each 'side' draws the ball or its shadow, as if we were in front of each wall while it moves. Perspective does the rest. I think it can be modified with more than one ball and collision detection

A bit of math background will be needed to understand the code. Also, I have only used normal views, as speed was not the goal in this demo.

Hope you like it :)
 

Attachments

  • RotationView.zip
    4 KB · Views: 611
  • RotationView_2Balls.zip
    323.3 KB · Views: 626
Last edited:

Star-Dust

Expert
Licensed User
Longtime User
Maybe you have to insert an external element that can change the trajectory.
A movable bar, a racket or something like that. So to hit the balls and crawl the trap.

Add a black basket or hole at the bottom of the cube. The balls must enter the hole ....

This is just an idea, not very original, but so much to have a starting point
 

Star-Dust

Expert
Licensed User
Longtime User
In my opinion, these are the best projects, when you do not know where you want to go. The invisible way doing it ... and so new things never come up.

When you know what you want to get .... is that something like this already exists ...
 

JordiCP

Expert
Licensed User
Longtime User
I think it will be this simple: some balls (2,3,4...) in static positions and the user has to make the best possible shot according to a goal which will change in each level

In my opinion, these are the best projects, when you do not know where you want to go
I agree. Although there's the obvious danger to never arrive

To me it looks like you could turn this easily into a curveball clone ;)
OMG, I'll do it!!

Thanks for the inputs
 
Top