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

Pages: [1] 2
1
General / Re: How to return an iterator
« on: October 30, 2012, 02:55:46 pm »
Never mind, i realized i didnt need it. thanks anyway

2
General / How to return an iterator
« on: October 30, 2012, 01:56:25 pm »
I want to return an iterator from the beginning of a vector from another file.
std::vector<sf::Sprite> bigAsteroidV;
bigAsteroidV.begin();
What would the function header be for that?

3
Graphics / Re: Where to put renderwindow
« on: October 30, 2012, 01:36:55 pm »
But if I put it in main, I can't use it in my other class where I need it

4
Graphics / Re: Where to put renderwindow
« on: October 23, 2012, 04:12:47 am »
What doesn't make sense about it?

5
Graphics / Re: Where to put renderwindow
« on: October 22, 2012, 05:29:27 am »
Thank You! -_- I don't know how I didn't see that

6
Graphics / Re: Where to put renderwindow
« on: October 22, 2012, 05:21:15 am »
init.h
#include "SFML/Window.hpp"
#include "SFML/Graphics.hpp"
#include "SFML/System.hpp"

class init
{
public:
        init();
       
private:
        sf::View view;
        sf::RenderWindow App;//(sf::VideoMode(800, 600, 32), "Asteroid Dodger");

}

init.cpp
#include "init.h"

init::init()
{
        //(sf::VideoMode(800, 600, 32), "Asteroid Dodger");
        App.Create((sf::VideoMode(800, 600, 32), "Asteroid Dodger");
       
         

         //view(sf::FloatRect(0.0f, 0.0f, App.GetWidth() + 0.0f, App.GetHeight() + 0.0f));
         view.SetFromRect(sf::FloatRect(0.0f, 0.0f, App.GetWidth() + 0.0f, App.GetHeight() + 0.0f));
         App.SetView(view);
         
         
       
}

7
Graphics / Where to put renderwindow
« on: October 22, 2012, 04:44:00 am »
I need to use my sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Title"); in multiple cpps, so I should put it in a header right? and then make an init function that I call as the first thing in main()?

So i tried making a private variable in the header file class, sf::RenderWindow App;
but then how would I add the video mode and title after that in the cpp?

Also, i tried to use the Create function, but it gave me an error that said "no instance of overloaded function sf::RenderWindow::Create matches the argument list" I used App.Create((sf::VideoMode(800, 600, 32), "Asteroid Dodger");

8
General / Re: collision detection with point reduction help
« on: September 15, 2012, 04:37:32 am »
?

9
General / Re: collision detection with point reduction help
« on: September 13, 2012, 05:04:41 am »
Ok thanks!
Now I put my asteroid in its own file and its own class, but for one the functions, i need to use the view.
Should I make a class just for the view? But I was thinking that there wouldn't be much in it. I was then going to make it a friend of the asteroid class.

Right now, the view is in my main.cpp


Edit: view also needs App, so should I make a class for App and view together?

10
General / Re: collision detection with point reduction help
« on: September 10, 2012, 01:55:59 am »
Ok, it now works, but now i want to refill the asteroids that were deleted so that there are 5 again.
How do iterate through the vector?
std::vector<asteroidV*>::iterator iter;
......
if(asteroidV.size() < 5)
                {
                        for(iter = asteroidV.end(); iter<5; iter++)
                        {
                                asteroidV.push_back(sf::Sprite());
                                asteroidV.at(i).SetImage(asteroid);
                                asteroidV.at(i).SetPosition((float)sf::Randomizer::Random(50, 780), (float)sf::Randomizer::Random(-5, -50));
                                asteroidV.at(i).SetCenter((float)asteroid.GetWidth()/2, (float)asteroid.GetHeight()/2);
                        }
                }
 

I get an error when I make the iterator, it says that asteroidV is not a type name. Do I have to use a class in there?

11
General / Re: collision detection with point reduction help
« on: September 09, 2012, 05:59:35 pm »
My asteroids are in a vector, so on impact, I tried deleting them, but every time I do, I get an out of range at memory location error.
to delete them I do

if(smallHit == true)
      asteroidV.erase(asteroidV.begin()+smallHitNum);
 

smallHit is a bool that is set to true if the ship hits an asteroid and smallHitNum stores the location of the asteroid that was hit.

I also tried
if(smallHit == true)
                        {
                                for(int e=0;e<5;e++)
                                {
                                        if(smallHitNumA[e] == e)
                                                asteroidV.erase(asteroidV.begin()+smallHitNumA[e]);
                                }
                        }
 
There is more than 1 asteroid, so if one of them was hit, then i loop and check if smallHitNumA[e] == e.
smallHitNumA[] is an array of 5 with all the value initialized to -1. If an asteroid is hit, then the number of the one that hit it, get stored in the corresponding element in the array.

12
General / Re: collision detection with point reduction help
« on: September 09, 2012, 04:55:39 pm »
Oh ok that would make sense. Right now, they don't get destroyed on impact.

13
General / Re: Multiple Object generation
« on: September 09, 2012, 04:39:09 pm »
Oh ok thanks. That helped a lot!
But how would I delete my SHIP sprite without making that into a vector?

14
General / collision detection with point reduction help
« on: September 09, 2012, 04:36:18 pm »
In my asteroid game, where you control a ship and try to avoid asteroids. I want to make you lose points, if you hit an asteroid. However, in my collision detection, it returns true a lot of times per second, so they keep on losing points really fast. Like if they hit one asteroid, they lose maybe 50 points, when it should only be -1 point. What should I do to prevent that from happening. I tried using bools to set it equal to true and if its true then subtract 1 point, but that makes them lose lots of points as well.

15
General / Re: Multiple Object generation
« on: September 04, 2012, 12:07:25 am »
No, but my ship isn't in a vector, it is just a sprite made in my main.cpp. So how would I delete that?

Pages: [1] 2
anything