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

Pages: 1 2 [3] 4 5 6
31
Class uses a default copy constructor and default assignment operators, Whenever the class is used, it is used as an element of a vector, the _ClassList is working properly

creation of class:
void Window::MakeClass(sf::Texture* Pic){
   // copy a default class over to the vector
   _ClassList.push_back(Class(Pic));
}
 

32
probably did something stupid, or do not have proper understanding of sf::Texture:

// Pic is a valid sf::Texture pointer, created in main
Class::Class(sf::Texture* Pic){
   // _Texture is a member variable, so is _Sprite
   // currently only use of _Texture
   _Texture = *Pic; // assign _Texture to the value of Pic
   _Sprite = sf::Sprite(_Texture); // does not work, white rectangle drawn
   //_Sprite = sf::Sprite(*Pic);   draws the proper Texture
}
 

33
Graphics / Re: Sprite positions
« on: February 09, 2013, 06:15:32 pm »
a vector contains a public member variable called x and y, to access public members, use the '.' operater, just like you do with public functions

sf::Vector2<float> Vec(-1,-1);
if (Vec.x <= 0){
   // do stuff
}
 

34
General / Re: Assigning a direction to bullets from a vector
« on: February 08, 2013, 08:35:03 pm »
you could store the trajectory vector inside of ProjectileClass, and copy movementX and movementY into it on creation of the bullet, then just move each bullet by ProjectileClass's movement vector, example:

if (button is pressed)
        {
            shooting();// first, so that you get new movement values to use
            bullets.push_back(projectile(movementX/2, movementY/2));
            // have ProjectileClass's constructor copy the two floats to TrajectoryX and TrajectoryY
            // which should be public variables, as information hiding is not usefull here, and make syntax easier
        }


int ShootMove()
{
        for (int i = 0; i < bullets.size(); ++i)
        {
                window.draw(bullets[i]);
                bullets[i].move(bullets[i].TrajectoryX, bullets[i].TrajectoryY);
        }
        return 0;
}
 

35
Graphics / Re: What is this black magic thou speak of?
« on: February 08, 2013, 08:20:31 pm »
I want to do a simple collision between two sprites, one is rotated, other is not. My logic was, take bounding box coordinates(in the future, will use a bounding polygon), transform them to the coordinate space of my rotated sprite, then do a simple smaller than/greater than check if the points are inside of the bounding box.

Where I was having issues, is understanding how exactly sfml was doing everything, if I had access the the exact matrix data, I would implement it in my way, which would be: subtrace centre position from point, perform matrix multiplication, add relative position of sprite back to point, perform collision detect.

The reason I didn't want to use sfml's bounding box check, is that I plan on having a more complicated check in the future, like a bounding polygon, or a triangle seperation of the image, or whichever is my want at that point, and I find it easier to write my own functions for everything, commonly called "re-inventing the wheel", as it will eventually further my education, and lend some experience to areas in programming I sorely need.

36
Graphics / Re: What is this black magic thou speak of?
« on: February 06, 2013, 05:07:03 pm »
I expected -320,-320 because I didn't know you applied scale to your result, I had thought that the result was measured in pixels as a unit, and not a relative, but ty :D multiplying the result by scale fixed it

in the future, can I just have access to raw matrix data, its a-lot easier for me to make my own functions that I know exactly how work, maybe like a getMatrix()? ;)

37
Graphics / Re: What is this black magic thou speak of?
« on: February 06, 2013, 01:56:14 am »
specifically when I added a SetScale call, as my fishes have :-)

is this what you meant by minimal?
int main(){
        sf::Sprite A;
        A.setScale(0.5,0.5);
        A.setPosition(640,640);
        sf::Sprite B;
        B.setPosition(320,320);
        sf::Transform transform = A.getTransform().getInverse();
        sf::Vector2<float> P = transform.transformPoint(B.getPosition());
        std::cout << P.x << ", " << P.y <<"\n";//Outputs '-640,-640'
        return 0;
}
 

38
Graphics / Re: What is this black magic thou speak of?
« on: February 06, 2013, 01:34:05 am »
its global, the hard-coded numbers, multiplied by the scale factor results in local, plus the top-left hand corner position, resulting in global, I was wanting to see if I could program my own collision detection, just for the fun of it, but I guess its tome for me to give up and just use your functions. and as far as math, I have 3 large books next to me that I have been reading through for about a year on three dimensional space and linear mathematics :) I'm learning. my problem, was how to recognize when sfml's matrix is using its position coordinates (I would expect that transformPoint() would be a simple matrix multiplication, at origin 0,0; but was wrong)

39
Graphics / Re: What is this black magic thou speak of?
« on: February 05, 2013, 10:05:44 pm »
I don't want to use rectangle intersections :-)

possible problem: transform's element 12 and 13 are off by 2,700 and 400 respectively, I suspect those are position elements of the transformation, that maybe your inverse() function messed with?

40
Graphics / Re: Best Way to get the position of an indexed pixel
« on: February 05, 2013, 09:39:52 pm »
tried transformToGlobal, but got similar problems, so I just made the switch :D

awhile back, I made mention that a sf::Image could only load an image up to a certain size, so I said it was probably being stored as an array, instead of a vector, and it was(I think) you that said you were going to change it in the update. the difference of an array and a vector, is that an array can't rescale, and it grabs the entire amount of ram (for a 32x32 image, for example, would still eat up whatever your max size in pixels is).

41
Graphics / Re: What is this black magic thou speak of?
« on: February 05, 2013, 09:32:58 pm »
you can see if I did anything wrong, but explaining what the function does will probably be easier, :) I'm not used to matrices with another row/column other than their orientation, explanation on how inverse() and transformPoint(), and getTransform() handle the position(and maybe they handle scale too, instead of just scaling the orientation?) coordinates would help alot  :D

bool Window::FishyCollision(MainFish* Fishy, EnemyFish* Fish){
        if (Fish->_Scale > Fishy->_Scale){
                // code here works
        }else{
                // invert the transform, sp that when applied, world coordinates of EnemyFish
                // become relative coordinates to MainFish
                sf::Transform transform = Fishy->_Sprite.getTransform().getInverse();
                // set up corners of the EnemyFish, hard-coded numbers are positions in the image
                // where the bounding box is
                sf::Vector2<float> Min = transform.transformPoint(sf::Vector2<float>(12,6)*Fish->_Scale+Fish->_MinCornerPos);
                sf::Vector2<float> Max = transform.transformPoint(sf::Vector2<float>(240,94)*Fish->_Scale+Fish->_MinCornerPos);
                sf::Vector2<float> C1 = transform.transformPoint(sf::Vector2<float>(12,94)*Fish->_Scale+Fish->_MinCornerPos);
                sf::Vector2<float> C2 = transform.transformPoint(sf::Vector2<float>(240,6)*Fish->_Scale+Fish->_MinCornerPos);
                // set up corners of the Main Fish
                sf::Vector2<float> FishyMin = sf::Vector2<float>(12,6)*Fishy->_Scale;
                sf::Vector2<float> FishyMax = sf::Vector2<float>(240,94)*Fishy->_Scale;
                /* check corners against each other, in a simple smaller-lesser than check, this part was omitted
                 at this point, FishyMin, and FishyMax are as expected, but the corners of EnemyFish are
                 definitely way off, so maybe I did something wrong in applying the ransformation,
                 there is too much unexplained on how the matrix handles it's position coordinates,
                 so guessing what I did wrong is near impossible, I gave it expected numbers, but got weird
                 effects, MainFish corner coordinates are at origin of the upper left corner, EnemyFish corner
                 coordinates are at origin 0,0 being global
                */

        }
        return false;
}
 

42
Graphics / What is this black magic thou speak of?
« on: February 04, 2013, 01:59:33 am »
If a sf::Transform is a matrix, then its an odd one, since it contains position, but the position numbers are already filled in when I use sf::Sprite.getTransform(), another odd aspect is, not only the position is filled in, but it was the inverse of the object's matrix, at least the result was the inverse of what I expected when I used sf::Transform.transformPoint, whether that function inverted it, or it was inverted from .getTranform I don't know, but it needs looking into, inverse calculations are expensive on matrices. Also, perhaps weirder, when I use sf::Transform.getInverse(), then use the inverted matrix for the transformPoint() call I expected it to act as a world-space to object-space transformation, instead, I got a weird number, either aroun -3000 or +3000 on the x and y axis, when the distance between the two for each axis is only about 400-900;

I would like to know what the black magic of sf::Transform is, and why it is so difficult to use, and if there is a way I can just get a 2x2 matrix, like, two sf::Vector2<float>'s or (float,float,float,float)? or can someone give me the correct order of transformations to go from global space to object space(origin at sprite origin, same for rotation)?

43
Graphics / Re: Best Way to get the position of an indexed pixel
« on: February 03, 2013, 05:14:16 am »
Ok.. so not exactly what I needed, I was using SFML 1.6, so I tried to use TransformToLocal(), but it kept having really odd results, I'm in the middle of switching to 2.0 right now, so that I can use Laurent's code snippet.. lowerCamelCase functions... Lord help me! :'( I knew it would come to this eventually.

On a side note, did you change the image being stored to a vector in 2.0, or is it still an array? :-)

44
General discussions / When will SFML 2.0 be the Current version?
« on: February 01, 2013, 11:28:02 pm »
I've been using SFML 1.6 for a while now, because I don't want to mess with any errors from 2.0 beta, or have to deal with the major version change, so I've been dodging required features, and it looks like its just about here, does anyone have a guess on a timeframe?

45
Graphics / Re: Best Way to get the position of an indexed pixel
« on: February 01, 2013, 10:57:10 pm »
Yes, ty ;D that's exactly what I wanted to do, and I've decided each time I make some topics on the forum, to do some forum crawling to try to help give back to the community :)

Pages: 1 2 [3] 4 5 6