SFML community forums

Help => General => Topic started by: nevets_19 on January 21, 2011, 12:55:28 pm

Title: Make Shapes Dissappear when a object hits it.
Post by: nevets_19 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)
Title: Make Shapes Dissappear when a object hits it.
Post by: JAssange 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.
Title: Make Shapes Dissappear when a object hits it.
Post by: Terrydil 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.
Title: Make Shapes Dissappear when a object hits it.
Post by: nevets_19 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
Title: Make Shapes Dissappear when a object hits it.
Post by: JAssange 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.
Title: Make Shapes Dissappear when a object hits it.
Post by: Fierce_Dutch 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.
Title: Make Shapes Dissappear when a object hits it.
Post by: nevets_19 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