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

Pages: [1] 2 3
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
SFML projects / A Box2D x SFML proof of concept
« on: September 12, 2011, 03:58:18 am »
How long did it take you to make this?

3
Graphics / Possibly two different instances of the same code don't work
« on: September 11, 2011, 03:56:27 am »
Hmm, i just thought of something. Lets say I had a bunch of different objects that just needed to move across the screen and they started at positions like that... could i just simply have 1 test like seen there in the first code to trigger all the balls movements back n forth decreasing overhead of a bunch of if tests.

P.S. I spent so many hours on that...

4
Graphics / Possibly two different instances of the same code don't work
« on: September 11, 2011, 03:54:31 am »
HOLY CRAP!!! haha i didn't even see that... smhv(violently)


that's so funny. Alright, this is where I officially stop using variables with too much alike names.

5
Graphics / Possibly two different instances of the same code don't work
« on: September 11, 2011, 03:33:59 am »
Oh yeah... I was testing different things... like since I was moving every loop 2.2 i just changed the argument to ... idk it doesn't matter... looking back it was senseless. Anyhow the balls simple go back and forth, starting from one end and ending from the other. Once that is complete, they flip and do that repetitively in till the program ends. That happens in the first one... Although in the second one the second ball actualy does that and when coming back to the point where it originally began it goes right passed it and off the actual screen bypassing the if test that's suppose to switch its direction and make it go back in the direction it was just coming from.


Yes 100% sure its the green ball.

Also, I think it could be an internal problem in SFML.  Possibly how the sprites are tested. At first I thought it could possibly be using a hybrid approach of testing if these objects met criteria to affect its behavior. But that doesn't seem to be the case and doesn't make sense as well.

If its not an of that, then its definitely my code.

6
Graphics / Possibly two different instances of the same code don't work
« on: September 11, 2011, 03:07:12 am »
Exactly, nothing does differentiate.

Well except how ball 1 test arguments work. but ball 1 works perfectly.
ball 2 on the other hand using the same code in both sources acts differently

7
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;
}

8
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.

9
Graphics / Class uses RenderWindow but can't use base constructor?
« on: August 20, 2011, 03:12:39 am »
Wow, that's really cool. I finally got my own constructor working and it gives me a seg fault. Run it through gdb but at the same time just try that one.

10
Graphics / Class uses RenderWindow but can't use base constructor?
« on: August 18, 2011, 04:03:35 am »
Quote from: "Haikarainen"
Code: [Select]
class _2deWindow : public sf::RenderWindow {
public:
_2deWindow(sf::VideoMode a, std::string title):sf::RenderWindow(a,title){}
};


Something like that should work


That's really nice. I thought I understood how it worked but now I'm confused.. The single colon ":sf::RenderWindow(...)...{}" part is confusing. did you mean a comma and to keep it in the first list or arguments or is that a feature I'm not even aware of?

11
Graphics / Class uses RenderWindow but can't use base constructor?
« on: August 17, 2011, 07:05:03 pm »
Quote from: "thePyro_13"
I noticed that I improved and learnt at a much faster rate after swapping to books compared to doing online tutorials. At the very least it's easier than alt-tabbing to compare your code with the examples.

But at least you've already found cplusplus.com, I think it's the best online reference available. Keep it handy when dealing with the STL.  :D


I've learned the fastest by simply using tutorials writing code, reading others code, and doing major refactoring implementing a bunch of new ways that just did the same stuff as the old ways faster and better with conciseness in mind.

also learning a new language, but not even writing in it, can augment your currently known and in use languages a lot.

12
Graphics / Class uses RenderWindow but can't use base constructor?
« on: August 17, 2011, 04:23:55 pm »
Yeah The books I was reading was Game Programming All in One third edition; Accelerated C++; cplusplus.com C++ Language Tutorial for quick reference. I haven't completely finished any of them yet. The first two not even close lol. I might start looking at them little by little now.


EDIT: I will take a look at that one.

13
Graphics / Class uses RenderWindow but can't use base constructor?
« on: August 17, 2011, 02:13:10 am »
I haven't read one. I don't really plan on it either.

They kind of turn me off from coding. I want to read effective c++/accelerated c++, but I really haven't got the time. I'm using cprogramming.com && cplusplus.com's tutorials which are pretty nice.

14
Graphics / Class uses RenderWindow but can't use base constructor?
« on: August 17, 2011, 12:30:22 am »
hpp file
Code: [Select]

class _2deWindow : public sf::RenderWindow {
//couple variables
public:
//couple functions
};


source file
Code: [Select]

_2de::_2deWindow App(sf::VideoMode(800,600,32), "Boundaries Test");


error
Quote

BoundTests.cpp: In function β€˜int main()’:
BoundTests.cpp:8: error: no matching function for call to β€˜_2de::_2deWindow::_2deWindow(sf::VideoMode, const char [16])’
_2de.hpp:51: note: candidates are: _2de::_2deWindow::_2deWindow()
_2de.hpp:45: note:                 _2de::_2deWindow::_2deWindow(const _2de::_2deWindow&)


I have no constructors what so ever. As you can see, which I just noticed, it's noticing it as a function which is weird.

15
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.

Pages: [1] 2 3
anything