Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Make Shapes Dissappear when a object hits it.  (Read 3991 times)

0 Members and 2 Guests are viewing this topic.

nevets_19

  • Newbie
  • *
  • Posts: 43
    • View Profile
Make Shapes Dissappear when a object hits it.
« on: January 21, 2011, 12:55:28 pm »
hi, at first i was gonna try to make a RPG game in sfml but then a friend suggest to start small as i just started learning it.

 so i'm trying to make a bricks type game where u bounce a ball off a paddle to hit a brick, and i want it so if i hit a brick it dissappears how would i do this? also i have no idea how to do a collision could somebody show me a bounding box collision if the ball is called ball and the brick is call brick.

thanks
XD 8)

JAssange

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Make Shapes Dissappear when a object hits it.
« Reply #1 on: January 21, 2011, 08:02:45 pm »
We can't really tell you how to make a brick disappear when hit until we know how you're structuring the game. Are the bricks just Sprites or do they have their own class? Where and how is the ball movement managed? As for bounding box collision it depends on if you want it to be preemptive which is more accurate or intersection which is simpler but slightly less accurate.

Terrydil

  • Jr. Member
  • **
  • Posts: 51
    • View Profile
Make Shapes Dissappear when a object hits it.
« Reply #2 on: January 22, 2011, 01:18:23 am »
There is some collision stuff on the wiki, you could start there.  Like JAssange said it depends on how you structure your program but making something disappear is as simple as not drawing it anymore.  So if you have a list of stuff to draw every frame, take it out.

nevets_19

  • Newbie
  • *
  • Posts: 43
    • View Profile
Make Shapes Dissappear when a object hits it.
« Reply #3 on: January 22, 2011, 03:02:16 am »
okay, thank you, i have one more question, if i have a paddle how to i make its x co-ordinate folow the mouse so if i move the mouse up the paddle moves up and vice versa.

do i just do like sprite.x = mouse.x or something similar because that how u do it in visual basic :D

JAssange

  • Full Member
  • ***
  • Posts: 104
    • View Profile
Make Shapes Dissappear when a object hits it.
« Reply #4 on: January 22, 2011, 06:54:57 pm »
I'd do it by tracking MouseMove events and storing the parameters for your update function to use.

Fierce_Dutch

  • Full Member
  • ***
  • Posts: 138
    • View Profile
Make Shapes Dissappear when a object hits it.
« Reply #5 on: January 23, 2011, 12:24:31 am »
Quote from: "JAssange"
I'd do it by tracking MouseMove events and storing the parameters for your update function to use.


Hey you could do something like, if bool collision = true then it wouldnt draw the shape.

nevets_19

  • Newbie
  • *
  • Posts: 43
    • View Profile
Make Shapes Dissappear when a object hits it.
« Reply #6 on: January 30, 2011, 11:23:08 am »
thanks for the reply and sorry for my late reply i was away but that is a good idea and i will try the bool = true then draw the shape and vice versa

 

anything