Author Topic: COLLISION  (Read 3001 times)

0 Members and 1 Guest are viewing this topic.

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
COLLISION
« on: November 13, 2011, 05:20:18 pm »
ok i need help with my collision... I want to make a normal field, with a line in the center of the screen, the ball can only land on top of the line...
It cannot jump through it... Or better yet, how would I do collision in general? Help!

Offline BalancedFury

  • LV8 Addict (Next: 1000)
  • ********
  • Posts: 722
  • Rating: +29/-2
    • View Profile
Re: COLLISION
« Reply #1 on: November 13, 2011, 05:38:03 pm »
Ask my brother TBO_Yeong :P
He's dont that a lot of time :D
Antonio Nam = DualBLDR = Tony Arthur... U choose!





JOIN THE PETITION TO ADD THIS EMOTICON!!
[|:{P ------->


Yo dawg I herd u lost the game game so I coded the game game in your calc so you can lose the game game while you code your code about losing the game game.

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: COLLISION
« Reply #2 on: November 13, 2011, 06:20:34 pm »
Just so a ball doesn't fall through a line?
I have no idea of to what extent the advancedness of what you want is... But whatever.
If assuming that's what you want, but I might be wrong :P
Just do something like
If y-sprite height<25
Y++
End
If the line is at 25 y axis.

For collision in general to check if 2 things are touching I usually do
X is x of first object
Y is y of first object
A Is x of second
B is y of second

If abs(X-A)<6
If abs(Y-B)<6
Stuff
End
End

That'll check if if the 2 objects are less than six pixels apart.


« Last Edit: November 13, 2011, 10:10:55 pm by epic7 »

Offline C0deH4cker

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 258
  • Rating: +11/-1
    • View Profile
    • iNinjas Forum/Repo
Re: COLLISION
« Reply #3 on: November 13, 2011, 10:05:08 pm »
Well, you'd have to do this instead:

Line(0,25,96,25)
If Y-(Sprite Height)<25
.Whatever
End

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: COLLISION
« Reply #4 on: November 13, 2011, 10:07:55 pm »
Oh yeah. But if you're holding the screen upside down... :P

Offline C0deH4cker

  • LV5 Advanced (Next: 300)
  • *****
  • Posts: 258
  • Rating: +11/-1
    • View Profile
    • iNinjas Forum/Repo
Re: COLLISION
« Reply #5 on: November 13, 2011, 10:19:54 pm »
then it would move down until its top was even with the line ;)

Offline epic7

  • Chopin!
  • LV11 Super Veteran (Next: 3000)
  • ***********
  • Posts: 2200
  • Rating: +135/-8
  • I like robots
    • View Profile
Re: COLLISION
« Reply #6 on: November 13, 2011, 10:22:38 pm »
If you were Holding the screen upside down and the object was coming up from the bottom of the screen and the sprite was rotated 180°. Then it would work!

Offline hellninjas

  • LV7 Elite (Next: 700)
  • *******
  • Posts: 625
  • Rating: +17/-0
    • View Profile
Re: COLLISION
« Reply #7 on: November 14, 2011, 02:32:04 pm »
Well thanks for the help, I've been needing this for some of my games that had gravity in it...