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

Author Topic: How do I undraw text  (Read 10710 times)

0 Members and 1 Guest are viewing this topic.

ravenheart

  • Full Member
  • ***
  • Posts: 148
    • View Profile
How do I undraw text
« Reply #15 on: September 15, 2008, 06:10:06 pm »
ok so far so good, now when i want some kind of breakout clone, how can i manage collision and visibility for each brick?

i dont know how to manage more than 3 objects ^^

does anyone know maybe a good site with examplecode?

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32504
    • View Profile
    • SFML's website
    • Email
How do I undraw text
« Reply #16 on: September 15, 2008, 07:16:23 pm »
Quote
@Laurent:
What about adding this kind of functionality to sf::Drawable?

This kind of feature is out of the scope of SFML, it's up to the user to add it.
Laurent Gomila - SFML developer

eleinvisible

  • Newbie
  • *
  • Posts: 47
    • View Profile
How do I undraw text
« Reply #17 on: September 20, 2008, 02:46:57 am »
Quote from: "ravenheart"
ok so far so good, now when i want some kind of breakout clone, how can i manage collision and visibility for each brick?

i dont know how to manage more than 3 objects ^^

does anyone know maybe a good site with example code?


I suppose you'll need an array of some sort of sf::Sprites, I'm not sure which you want to implement but for break out its only like 64 bricks? So it really does not matter (for this anyways). Pseudo-code is as follows:

Code: [Select]

const int WindowX = 800;
const int WindowY = 600;
//Assuming your window goes from 0,0 to 800,600

sf::Sprite Bricks[64] = {...} // I assume you'd set there position somewhere

int InView(sf::Sprite& Arg)
{
    //compare to window view
    if(Arg.X > WindowX || Arg.X <0)
        return 0;
    if(Arg.Y > WindowY || Arg.Y < 0)
        return 0;
    if(Arg.Y < WindowY && Arg.Y > 0)
        return 1;
    if(Arg.X < WindowX && Arg.X > 0)
        return 1;
}

//... somewhere in render-loop
for(int i = 0; i <= 64; i++) //++i?
{
     if(InView(Bricks[i]))
    {
        //draw
    }
}


Didn't try to check if it was correct or anything, but if it is outside of the window range it should not draw it. Coincidentally you can rewrite InView to be Collision(int X, int Y, sf::Sprite& Arg) it will compare the X,Y you provide to the position of the object and see if they collide...

 

anything