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.


Messages - eniddelemaj

Pages: [1]
1
General / Re: many function arguments
« on: October 14, 2016, 06:40:02 pm »
How is this related to SFML?

im sorry youre right.it wont happen again.

its depends on the compiler and the processor.

x86 have 4 register: EAX EBX ECX EDX (32 bits registers), a compiler can push directly parameters to the stack.

push [constant]|[register]|[memory adress]
push [constant]|[register]|[memory adress]
call _myFunctionName
 

Often the values pushed are not constant so the compiler needs to use the 4 32-bits registers.
If your function have a lot of arguments the compiler needs to move some data between register.

But if yuro processor supports and your compiler use SIMD extensions you can have 4 more 32-bits register (XMM registers).

If you have 8 arguments better you pack few in structs or something.

But don't worry how many arguments you are passing, it is unprobable that you notice the performance hit if any.

But 8 arguments are kinda ugly in my opinion.


And for those questions go to a general C++ forum.
This forum is to discuss about SFML related things.

okay thank you for your advice!
yes i found it ugly too... thats a good idea with structs i never used it anyway...
thank you for that!:)

2
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!

3
General / Re: diagonal line with collisiondetection
« on: October 07, 2016, 04:26:12 pm »
okay these information helped!:)
thank you very much guys

4
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:)

5
General / Re: it doesnt render the bars
« on: October 03, 2016, 05:02:39 pm »
thank you i appreciate that:)

6
General / Re: it doesnt render the bars
« on: October 03, 2016, 01:11:48 pm »
its just embarassing i found the mistake!

i dont want to talk about it its too dumb!

but thanks for everybody who read my post and wanted to help!

7
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!

8
General / Re: weird compiler problems
« on: October 01, 2016, 01:37:28 pm »
it worked! im so dumb ...i already did have problems like this...thank you for your help !

9
General / Re: weird compiler problems
« on: September 30, 2016, 05:03:44 pm »
im not a professional but i dont think that it is related on my experience.
i checked the includes ...everything is included.

yes but the problem is that it might be too much code but ill try.

this is the header file of class 'play' where i declared the movingBall object

//includes
 
#ifndef PLAY_HPP
#define PLAY_HPP
#include <SFML\Graphics.hpp>
#include "states.hpp"
#include "game.hpp"
#include "movingBall.hpp"
#include "wallCollision.hpp"

//there are other declarations but i dont show them to keep it clear to read

class play :public states
{
public:
       
        movingBall moBa; //the case when the compiler says that a semicolon is missing
                                     //i forgot to say that the compiler says that there is a missing type specifier
                                     //but nothing is marked red

        play();

        void draw(game &Game);
        void Update(game &Game);
        void handleEvents(game &Game);

protected:
 

header of the movingBall class:

//includes
#ifndef MOVINGBALL_HPP
#define MOVINGBALL_HPP
#include "play.hpp"
#include <time.h>



class movingBall
{
public:
        movingBall();
       

        //maybe it is connected with that much of arguments?! i dont think so..

        void ballIsMoving(sf::CircleShape &ball, sf::RectangleShape &barOne,
                              sf::RectangleShape &barTwo, sf::RectangleShape &wallOne,
                                          sf::RectangleShape &wallTwo,int &movementOne,int &movementTwo);


       

protected:
       

};

#endif

i forgot to say that the compiler says that there is a missing type specifier
but nothing is marked red!!



10
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

11
General / Re: how to check collision with mouse?
« on: July 25, 2016, 01:33:01 pm »
no im just trying the codes of the tutorials

12
General / Re: how to check collision with mouse?
« on: July 25, 2016, 01:03:39 pm »
i did but the same result:/

13
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