The Daily Click ::. Forums ::. Klik Coding Help ::. MATH Angle Bouncing? / Reflection
 

Post Reply  Post Oekaki 
 

Posted By Message

Solgryn

Solgryn dot org

Registered
  20/12/2008
Points
  12572

GOTW Winner!VIP MemberWii OwnerIt's-a me, Mario!The Cake is a LieGOTM 2ND PLACE! - APRIL 2009GOTM 2ND PLACE - JUNE 2009PS3 OwnerKlikCast #15 Compo Winner!LOL Sign
You've Been Circy'd!GOTM WINNER - JANUARY 2010I am an April FoolGOTW MARCH 2010 WINNER!Santa Hat
11th May, 2010 at 21:15:53 -

Hello everyone, how do I make an angle "bounce" off a wall using only 1 formula?? is it possible?

Right now I know bouncing off a wall at a top detector of an object is done using this formula:
Angle = Angle*-1

Image


And I also know bouncing an angle on a right/left wall is done using this one:
Angle = 180-Angle

Image

Is there a way to only using 1 formula? Because I really don't want to use loop detectors to do this bouncing thing if there's an easier way :/

Thanks =

 
www.Solgryn.org

Image

Sumo148

Super amazing fantastic user

Registered
  26/01/2009
Points
  530

360 OwnerThe Cake is a LieVIP MemberPokemon Ball!I am an April FoolI donated an open source projectSanta Hat
11th May, 2010 at 21:58:00 -

omg I'm having the same problem I want to have my 360 grenades bounce off walls

 
n/a

Sketchy

Cornwall UK

Registered
  06/11/2004
Points
  1970

VIP MemberWeekly Picture Me This Round 43 Winner!Weekly Picture Me This Round 47 WinnerPicture Me This Round 49 Winner!
11th May, 2010 at 23:15:30 -

Ball_Angle = (Obstacle_Angle * 2) - Ball_Angle

Edited by Sketchy

 
n/a

MBK



Registered
  07/06/2007
Points
  1578

VIP Member
11th May, 2010 at 23:38:03 -

Active collides with wall --> wall angle - active angle

? ? ?


 
Click Me! http://www.create-games.com/project.asp?view=main&id=1444

http://www.mediafire.com/download.php?aoo1dnnlq5i

Blood of the Ancient One, Seen only as Shadow, Faster than Lightning, Fierce as the Greatest Dragon, Nearly Invisible, Floating in a Dream, Entered through the Demon Door, Destroyer of Evil in a Realm with a Red Sky Scarred, Who could I be ?

Sumo148

Super amazing fantastic user

Registered
  26/01/2009
Points
  530

360 OwnerThe Cake is a LieVIP MemberPokemon Ball!I am an April FoolI donated an open source projectSanta Hat
12th May, 2010 at 00:19:47 -

Both of those formula didn't work exactly But I got it to work. I only needed horizontal and vertical bouncing so mine was pretty easy.

For the horizontal it was: Ball_Angle = (Obstacle_Angle * 2) - Ball_Angle
For the vertical it was: Ball_Angle = (Obstacle_Angle * 2) - Ball_Angle-180




 
n/a

Assault Andy

Administrator
I make other people create vaporware

Registered
  29/07/2002
Points
  5686

Game of the Week WinnerVIP Member360 OwnerGOTM JUNE - 2009 - WINNER!GOTM FEB - 2010 - WINNER!	I donated an open source project
12th May, 2010 at 00:41:19 -

What Sketchy and Sumo both said is exactly correct. The main problem is working out the object angle. For vertical and horizontal walls it's easy, but if you want anything more complicated, such as ramps/slopes/curves then you should look into using one of the physics extensions, such as Box2D.

 
Creator of Faerie Solitaire:
http://www.create-games.com/download.asp?id=7792
Also creator of ZDay20 and Dungeon Dash.
http://www.Jigxor.com
http://twitter.com/JigxorAndy

Sumo148

Super amazing fantastic user

Registered
  26/01/2009
Points
  530

360 OwnerThe Cake is a LieVIP MemberPokemon Ball!I am an April FoolI donated an open source projectSanta Hat
12th May, 2010 at 02:39:58 -

actually Sketchy is exactly correct. My wall angles were incorrect, but the changes in my code corrected the grenade bounce. So technically it should work with one line of code

Edited by Sumo148

 
n/a
   

Post Reply



 



Advertisement

Worth A Click