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

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - eniddelemaj

Pages: [1]
1
General / many function arguments
« on: October 13, 2016, 03:52:12 pm »
is it an advantage when you have more than 5 function arguments?
i  am programming a pong game. i have functions which contains 8 arguments.
and there are several other ones which contains at least more than one.

for me i guess its kind of comfortable just to give arguments for example
the ballshape to update the ball position or something like that.
my worry is that its not very effective and this way of programming can
lead to performance loss am i right?

maybe im wrong but that was my concern.

sorry i didnt think it was necessary to post a code example

thank you for your answears!

2
General / diagonal line with collisiondetection
« on: October 06, 2016, 09:15:24 pm »
hey ,

i know how to use the getglobalbounds and intersects functions to simulate a collision
with to objects.an example would be pong. but it does only work
with straight sides not diagonal. as you know there is an invisible rectangle around the
entity and when its diagonal , there is too much space between the rectangle and the entity so
the hitbox is invalid.
now i want to make a collision detection which supports diagonal "hitboxes" too.
i looked for pixel collision detection but i read, that it isnt much effective.
are there any other ways to solve this? i didnt really found much on google about this.
thank you for your help:)

3
General / it doesnt render the bars
« on: October 03, 2016, 12:58:50 pm »
im creating a pong game with a play class and the ball and bat class.
bat and ball returning their shapes with a method. ball is working but i dont get the bat shapes!

this is in the bars(or bat) constructor:
Bars::Bars()
{
        //linke Bar
        barOne.setSize(sf::Vector2f(20.0, 90.0));
        barOne.setPosition(sf::Vector2f( 0.0, 640.0));


        //rechte Bar
        barTwo.setSize(sf::Vector2f(20.0, 90.0));
        barTwo.setPosition(sf::Vector2f(590.0, 640.0));
}

 
these methods return bat of type rectangleshape

sf::RectangleShape Bars::getBarOne()
{
       
        return barOne;
}

sf::RectangleShape Bars::getBarTwo()
{
        return barTwo;
}

and the draw method of class play is drawing the shapes to the window
void play::draw(game &Game)
{

        Game.window.draw(ball.getShape());
        Game.window.draw(bars.getBarOne());
        Game.window.draw(bars.getBarTwo());
       
}

i dont get it...only the ball is appearing but none of the bars.
in my dispair i changed the types of the bars to circleshape types.
in the constructor i initialized the circleshapes and it worked!
i dont get it what do i miss?

thank you for your help!

4
General / weird compiler problems
« on: September 30, 2016, 04:24:59 pm »
hello people

first ,english is not my mother language so dont wonder.

the problem is:
i have two classes. the first is called 'base' for example and the second is called 'second'.
In the header file of base i create an object 'obj' of type second.
okay now when i want to start the programm , there is an error which says, that there is an
missing ';' befor 'obj'.
the first weird thing is:
...that there really is no missing semicolon.

the second weird thing is :
...that i can easily handle the problem by:
1. deleting the creation of an object of type second.
2.running the programm so there will be an error because the obj i use in other cpp files is missing.
3.writing the same thing again (create an object named 'obj' of type second)
4.it runs!?

okay now i can call that problem again by changing something in the cpp file of second.
now the error appears again.

i hope you understant my problem
thank you for reading an answear

5
General / how to check collision with mouse?
« on: July 25, 2016, 12:54:14 pm »
        sf::Text text;
        text.setPosition(100, 100);
        text.setFont(font);
        text.setString("example");
        text.setColor(sf::Color::Green);

        sf::FloatRect collision = text.getLocalBounds();

        sf::Vector2f point = sf::Vector2f(100, 100);

       
        if (collision.contains(point))
        {
                text.setColor(sf::Color::Red);
        }
 
I want to check collision with mouse. so if i move with the cursor over the text that the text change its color to red. I didnt become smarter of the tutorials:/

the code works but there is no result

sorry for my english i hope you can help!

Pages: [1]
anything