Jump to content


Photo

i need relastic reflexion code


  • Please log in to reply
12 replies to this topic

#1 The Rock Abdo

The Rock Abdo

    GMC Member

  • GMC Member
  • 50 posts
  • Version:GM8

Posted 31 March 2012 - 05:17 PM

hi , I need the code which making the objects bouncing like this :

Posted Image

for example :
red lines are the balls , blue are corners

and thanks ,, sorry for my bad english :ermm:
  • 0

#2 jo-thijs

jo-thijs

    GMC Member

  • GMC Member
  • 1485 posts
  • Version:GM8.1

Posted 31 March 2012 - 05:39 PM

Are the blue lines 2 objects or one?
  • 0

#3 The Rock Abdo

The Rock Abdo

    GMC Member

  • GMC Member
  • 50 posts
  • Version:GM8

Posted 31 March 2012 - 06:32 PM

Are the blue lines 2 objects or one?

two objects
  • 0

#4 time-killer-games

time-killer-games

    GMC Member

  • Banned Users
  • 539 posts
  • Version:GM:Studio

Posted 31 March 2012 - 06:49 PM

collision event for the ball object to bounce, try:
if (direction<=179)
{direction+=90}
if (direction>=180)
{direction-=90}

i cant really play with it right now though.
edit:im probably not the best person for this kind of question. i should have noticed that second pair of red lines you had there. D:

Edited by time-killer-games, 31 March 2012 - 06:52 PM.


#5 The Rock Abdo

The Rock Abdo

    GMC Member

  • GMC Member
  • 50 posts
  • Version:GM8

Posted 31 March 2012 - 07:01 PM

collision event for the ball object to bounce, try:

if (direction<=179)
{direction+=90}
if (direction>=180)
{direction-=90}

i cant really play with it right now though.
edit:im probably not the best person for this kind of question. i should have noticed that second pair of red lines you had there. D:


i'm sorry it doesn't work ..

To illustrate the idea i need the reflection like this game

http://sandbox.yoyogames.com/games/2742-reflexion

thanks time-killer-games
  • 0

#6 orange451

orange451

    GMC Member

  • GMC Member
  • 995 posts
  • Version:GM8

Posted 31 March 2012 - 07:19 PM

http://gmc.yoyogames...howtopic=477696
  • 0

#7 jo-thijs

jo-thijs

    GMC Member

  • GMC Member
  • 1485 posts
  • Version:GM8.1

Posted 31 March 2012 - 07:43 PM

ok, first of all you need to know the angle of blue line, you can do this by or making 2 different objects where 1 object has an angle of 45 or 135, or you could just use the image_angle. I'll call it just angle in the code.
The code:
direction=2*angle-direction;
  • 0

#8 The Rock Abdo

The Rock Abdo

    GMC Member

  • GMC Member
  • 50 posts
  • Version:GM8

Posted 31 March 2012 - 07:49 PM

http://gmc.yoyogames...howtopic=477696


sorry >> it doesn't work perfectrly :sad: :

the gmk link :

https://www.rapidshare.com/files/3140365413/Reflexions.zip
  • 0

#9 The Rock Abdo

The Rock Abdo

    GMC Member

  • GMC Member
  • 50 posts
  • Version:GM8

Posted 31 March 2012 - 07:53 PM

ok, first of all you need to know the angle of blue line, you can do this by or making 2 different objects where 1 object has an angle of 45 or 135, or you could just use the image_angle. I'll call it just angle in the code.
The code:
direction=2*angle-direction;


it didn't work too :sad:
  • 0

#10 jo-thijs

jo-thijs

    GMC Member

  • GMC Member
  • 1485 posts
  • Version:GM8.1

Posted 31 March 2012 - 07:55 PM

What went wrong? I tested it on my pc and it worked there.
  • 0

#11 The Rock Abdo

The Rock Abdo

    GMC Member

  • GMC Member
  • 50 posts
  • Version:GM8

Posted 01 April 2012 - 06:09 AM

What went wrong? I tested it on my pc and it worked there.


In the gmk which i uploaded .. when you test it you will find that after three bounces the ball goes up and down without collide any of solids ?? .. could you solve it plz :sad:
  • 0

#12 jo-thijs

jo-thijs

    GMC Member

  • GMC Member
  • 1485 posts
  • Version:GM8.1

Posted 01 April 2012 - 08:43 AM

Oh, now I see, the problem is that you made the slim walls solid, unsolid them and it works fine.
  • 0

#13 The Rock Abdo

The Rock Abdo

    GMC Member

  • GMC Member
  • 50 posts
  • Version:GM8

Posted 01 April 2012 - 09:29 AM

Oh, now I see, the problem is that you made the slim walls solid, unsolid them and it works fine.


thanks .. it is good now
  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users