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

Pages: [1]
1
Graphics / Collision Detection Complexities
« on: September 25, 2011, 06:04:40 am »
How would I check and see if a small object is in a box as it moves around randomly?

The box or sf::Shape::Rectangle doesn't give 4 coordinates to check to see if the object is inbetween the box.
e.g.
Code: [Select]

if( x > 40.0f && < 80.0f)
    if ( x > 30.0f < 10.0f)
           //...x is in between the box


I've decided to make a somewhat abstract body or frame around the actual object that will work as a method for checking to see it. The question that arises now is how do I update this box with the objects movement. Where do I get this data that's hard to get...? haha

I haven't looked inside the actual sfml code yet to see how you come up with the actual body when making an sf::Shape::Rectangle(because it only takes in two points) which I understand how it works but seeing how it's done would be nice... and possibly give insight on another problem a little more advanced then this...

Thanks.

2
Graphics / Possibly two different instances of the same code don't work
« on: September 11, 2011, 02:54:40 am »
I have two different instances of the same cold. One works as accordingly planned and the other messes up. Possibly I dont' see the erroneous lines of code that I posted. I was therefore looking for some help on finding them or identifying the underlying problem.

Code 1 that works
Code: [Select]

#include <SFML/Graphics.hpp>
#define CIRCLE sf::Shape::Circle(0.f, 300.f, 5.f, sf::Color::Red, 1.f, sf::Color::Blue);

#define CIRCLE1 sf::Shape::Circle(800.f, 300.f, 5.f, sf::Color::Red, 1.f, sf::Color::Blue);


int main () {
sf::RenderWindow App(sf::VideoMode(800,600,32), "Horizontal Circles");
App.SetFramerateLimit(60);
sf::Shape C1 = CIRCLE;
sf::Shape C2 = CIRCLE1;
int dir = 0;
int dir2 = 0;
while(App.IsOpened()) {
sf::Event ev1;
if(App.GetEvent(ev1))
if(ev1.Type == sf::Event::Closed)
App.Close();

if(dir == 1 && C1.GetPosition().x < 2.f)
dir = 0;
if(dir == 0 && C1.GetPosition().x > 798.f) {
dir = 1;
}

if (dir == 1 )
C1.Move(-2.2,0.f);
if (dir == 0)
C1.Move(2.2, 0.f);

if(dir2 == 1 && C1.GetPosition().x < 2.f)
dir2 = 0;
if(dir2 == 0 && C1.GetPosition().x > 798.f) {
dir2 = 1;
}


if (dir2 == 0 )
C2.Move(-2.2,0.f);
if (dir2 == 1)
C2.Move(2.2, 0.f);

App.Clear();
App.Draw(C1);
App.Draw(C2);
App.Display();


}

return EXIT_SUCCESS;
}


This is code 2. It does half of what it's suppose to
Code: [Select]

#include <SFML/Graphics.hpp>
#include <iostream>
#define CIRCLE sf::Shape::Circle(0.f, 300.f, 5.f, sf::Color::Red, 1.f, sf::Color::Blue);

#define CIRCLE1 sf::Shape::Circle(800.f, 280.f, 5.f, sf::Color::Green, 1.f, sf::Color::Blue);


int main () {
sf::RenderWindow App(sf::VideoMode(800,600,32), "Horizontal Circles");
App.SetFramerateLimit(60);
sf::Shape C1 = CIRCLE;
sf::Shape C2 = CIRCLE1;
int dir = 0;
int dir2 = 0;
while(App.IsOpened()) {
sf::Event ev1;
if(App.GetEvent(ev1))
if(ev1.Type == sf::Event::Closed)
App.Close();

//where ball 1 testing begins
if(dir == 0 && 800.f - C1.GetPosition().x  < 1.0 ){
//std::cout << (800.f- (C1.GetPosition().x)) << "Red This is Direction 0 ch to 1\n";
dir = 1;
}
if(C1.GetPosition().x - 2.f < 1.0 && dir == 1) {

dir = 0;
//std::cout << ((C1.GetPosition()).x - 2.f ) << "Red This is Direction 1 ch to 0\n";
}



//where ball 2 testing begins

if(dir2 == 1 && C1.GetPosition().x < 2.f){
dir2 = 0;
//change
}
if(dir2 == 0 && C1.GetPosition().x > 799.f) {
dir2 = 1;
}
//where ball2 movement two begins

if (dir2 == 0 )
C2.Move(-2.2,0.f);
if (dir2 == 1)
C2.Move(2.2, 0.f);


// This is where Ball movement 1 begins

if (dir == 1 ){
C1.Move(-2.2,0.f);
// std::cout << C1.GetPosition().x << std::endl;
}


if (dir == 0) {
C1.Move(2.2, 0.f);
// std::cout << C1.GetPosition().x << std::endl;

}


App.Clear();
App.Draw(C1);
App.Draw(C2);
App.Display();


}

return EXIT_SUCCESS;
}

3
Graphics / 3d graphics are projected onto a 2d plane
« on: September 01, 2011, 12:02:21 pm »
Can sfml make 3d graphics with a little bit more work?

I know if possible... it would be alot of work and should be avoided altogether. I just want to know if it's possible.

4
Graphics / Class uses RenderWindow but can't use base constructor?
« on: August 16, 2011, 10:52:46 pm »
I have a class that inherits public properties from sf::RenderWindow. What's wrong with it if it can't use basic constructor's like the 2 argument sf::VideoMode, string one?

Also i'm about to peak at the RenderWindow.cpp source code, but doesn't anyone know if I can just make my own constructor like that and use the variables used in the orig. constructor etc. Basically make a copy... but I still don't know why the first one wouldn't work if i'm using it correctly. Also this is my only error in compiling this one header with three source files.

5
Graphics / Collision detection for more than two objects?
« on: August 10, 2011, 10:14:04 pm »
How would I make a collision detection for 2d objects for more than 2 objects.

As in 3 object collision or possibly more?

6
General discussions / Can we see the source code for this?
« on: August 09, 2011, 09:30:02 pm »
Can we see the source code for this library. All I see is headers and I really want to find out more about how everything is being implemented and done so I can better manipulate things and make better software.

7
Graphics / Class inheriting sf::RenderWindow properties.
« on: August 08, 2011, 11:48:47 am »
Hi, I'm wondering if making a class sf::RenderWindow properties and adding a few vectors possibly of growing and sometimes depleting memory will be too expensive to actually have act as a sf::RenderWindow?

8
Graphics / Collision Detection Problems and freezes with sprites etc
« on: August 08, 2011, 06:02:47 am »
Hi, I've developed somewhat a basic little pong like ball that has to stay within certain boundaries. When dealing with a sf::shape, it doesn't have any type of bugs or errors. While using the same code as the sf::shape, if I switch it to sf::sprite with an image acting as the ball, it will freeze and be very buggy going through the boundaries set.

I'm wondering why is this? Is sf::sprite more intense and need to be implemented some other way. Should I add extra catching boundaries or possibly(just thought of now) have a exception like clause that will redraw and reimplement the ball on messing up exactly where it was last within the boundaries??

9
I know that a game engine has components that make a game easier to make. Or a lot of low level or repetitive things done to make the game producing/development a lot easier/faster.

I'm looking for a better definition, sample things that would go into a game engine(descriptive/detailed plz) and how i can use SFML to make one.

As in what would SFMLs job be in the game engine etc.

Thanks

10
Hey, I'm interested in reusable code. As I just started, I feel mines kinda bad. As it will improve obviously. But, I wanted to ask the community what type of functions/class/code do you typically find reusable? Why do you deem it reusable, and What extends or inherits that code.

11
Basically it's a "computer" that handles the paddle and watches the ball to move where the ball is going.

When the ball reaches GetPosition().x >= 400, it will start to move to where it's going. It works going down, but when it's needed to go up, it doesn't move at all.

Paddle & gBall inherit sprite characteristics

dir is a variable used within gBall to find out which direction it is going.
2 = right down 3 = right up

Code: [Select]


class Computer
{
public:
Paddle * IControl;
gBall * IWatch;
float BPD;

void Set(Paddle * CPaddle, gBall * IWatchIt);
void SetBall(gBall * IWatchIt){ IWatch = IWatchIt;}
void SetPlayer(Paddle * CPaddle){ IControl = CPaddle;}
void play();
float crunch();
void move();
};

void Computer::play()
{
if ( IWatch->GetPosition().x > 400 && IWatch->dir == 3 )
{
BPD = crunch();
if ( BPD > 50)
move();
}

if ( IWatch->GetPosition().x > 400 && IWatch->dir == 3 )
{
BPD = crunch();
if ( BPD < -50)
move();
}

if (IWatch->GetPosition().x > 400 && IWatch->dir == 2 )
{
BPD = crunch();
if(BPD > 50)
move();
}
if (IWatch->GetPosition().x > 400 && IWatch->dir == 2 )
{
BPD = crunch();
if (BPD < -50)
move();
}
}

float Computer::crunch ()
{
float copy;
if (IWatch->dir == 3 && IControl->GetPosition().y <= 300.f)
copy = IWatch->GetPosition().y - IControl->GetPosition().y;

else if (IWatch->dir ==  3 && IControl->GetPosition().y >= 300.f)
copy = IWatch->GetPosition().y - IControl->GetPosition().y;

else if (IWatch->dir == 2 && IControl->GetPosition().y <= 300.f)
copy = IWatch->GetPosition().y - IControl->GetPosition().y;

else if (IWatch->dir == 2 && IControl->GetPosition().y >= 300.f)
copy = IWatch->GetPosition().y - IControl->GetPosition().y;
std::cout << BPD << "        " << IControl->GetPosition().y << "        " << IWatch->GetPosition().y << "    " << IWatch->dir << std::endl;
return copy;
}

void Computer::move ()
{

if(IWatch->dir == 3)
if (BPD >= (-50))
IControl->Move(0.f, -.5f);  // doesn't work
if (BPD >= 50)
IControl->Move(0.f, .5f);


 
if(IWatch->dir == 2)
if (BPD >= (-50))
IControl->Move(0.f, -.5f); // doesn't work
if (BPD >= 50)
IControl->Move(0.f, .5f);

}

12
Graphics / When I load an image, My moving sprite freezes.
« on: June 25, 2011, 08:45:16 am »
I have a ball that moves and has boundaries that it can't go past. I use to use a sf::Shape that worked perfectly with my algorithms physics?lol and it was very basic and generic.

Now this image within a sprite has come a long and it's freezing after a while that it runs.  When it hits the boundary, it will freeze there. I think that possibly It caught it too late, and doesn't meet the requirements to move again?

I'm not sure why it does this. Again, it works perfectly fine with a shape. Just when I use the sprite, is there some limitations and precautions I should take when using the sprite with images loaded in it. Also the image is a jpg, which I'm not just finding out is a bad format.

13
Graphics / Programs used to make 2d Game images? Using gimp...
« on: June 25, 2011, 08:36:50 am »
Hey, I haven't gotten to this step in my game yet, but I plan to make all original graphics + sounds.

I've been using gimp and I've noticed that every time I try to make a sprite, It has the white background that I used to make it. I want the image just to be the object that I made not include the background around it. I've tried drawing on transparent layers and erasing this... but it doesn't work.

Anyone know the fix... What's going on?

Also, While I'm on this subject, what's some good programs that people use for 2d games to make the graphics.

And possibly tutorials, bits of useful information or other things relevant to the topic available over the web?

14
Graphics / Problems loading images when I split program into modules
« on: June 25, 2011, 08:31:43 am »
I have a program that I split into two modules with a header.

I'm new to the whole modules/headers thing. I started to use it because my code is now > 300 lines and daunting to look at. I suspect it to get to > 800 lines, this helps in the long run.

Anyhow, when it works, it's all consolidated into one source file. When I give a header... I put all Class declarations in the header file. I include SFML/Graphics.hpp and any #defines I have for the program. The first source module has all the definitions for the class declarations, while the second has all the main function. It compiles but it spits out an error while trying to load an Image. What's bizarre about this error is that the name of the image is a directory + image.

Anyone know why this is happening?


Failed to load image "gameImages/Pong/b1.jpg". Reason : Unable to open file

15
General / Clock Class/Time Class
« on: June 18, 2011, 05:43:22 am »
Hi, I have limited time on finishing a project i'm doing. The problem that's slowing me down from finishing this is kinda integral to my overall abilities and what I want to do with SFML.

I basically need to know how to display time. The tutorial shows how to use this, just not how to actually display it. I've played with it for a few hours, and I would rather not play with it any longer as my time is very limited.

I've been trying to cast sf::Clock.GetElapsedTime into a sf::String so I can concatenate them and display it on the screen. This obviously doesn't work.

sf::Clock doesn't inherit drawable so it's not something you can draw... etc. I'm kinda lost and on top of that, I kinda hardly know what I'm doing.

Pages: [1]