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

Pages: [1]
1
General discussions / How Do You Do While Intersects
« on: December 04, 2008, 06:50:59 am »
I have the following code which changes the color of EasternAustraliaSprite whenever the PointerRect intersects the EastAustRect.

what I want to do though is while the pointerRect intersects the EastAustRect change the color. How would i do this?

Code: [Select]

if(EasternAustraliaRect.Intersects(PointerBoxRect))
{
EasternAustraliaSprite.SetColor(sf::Color(0, 255, 0));
}

2
General / Error when trying to display background and image
« on: November 26, 2008, 03:39:55 am »
As the title says im trying to display my background and an image on top of the background but when i run it i get an error.

Debug Assertion Failed!
Program:..
File d:\programmes\visual studio 2005\vc\include\vector
Line: 756

Expression: vector subscript out of range

Code: [Select]

#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
//Windows is included in Graphics
#include <iostream>

#define PLAYER_SPEED 100

int main()
{
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Tutorial");

//BackGround drawing pieces
sf::Image bgImage;
sf::Sprite bgSprite;

sf::Image plImage;
sf::Sprite plSprite;

//load image
/*if(!bgImage.LoadFromFile("background.jpg"))
{
return EXIT_FAILURE;
}

if(!plImage.LoadFromFile("terror.png"))
{
return EXIT_FAILURE;
}*/

// point out  sprite to our image
bgSprite.SetImage(bgImage);
plSprite.SetImage(plImage);

//set center
plSprite.SetCenter(plImage.GetWidth() * .5, plImage.GetHeight() * .5);

//plSprite.Setposition(App.Width * .5, App.height * .5);
plSprite.SetPosition(400, 300);

while(App.IsOpened())
{
//update
// handle player input

//get our frame time
float deltaTime = App.GetFrameTime();

if(App.GetInput().IsMouseButtonDown(sf::Mouse::Left)
{
if(App.GetInput().GetMouseX();

//check for left key
if(App.GetInput().IsKeyDown(sf::Key::Left));
{
float newX = plSprite.GetPosition().x - (deltaTime * PLAYER_SPEED);
//Keep the image on the screen
if(newX -(.5*plImage.GetWidth()) < 0)
{
newX = .5 *plImage.GetWidth();
}
plSprite.SetPosition(newX, plSprite.GetPosition().y());
}
if(App.GetInput().IsKeyDown(sf::Key::Right));
{
float newX = plSprite.GetPosition().x + (deltaTime * PLAYER_SPEED);
if(newX < App.GetWidth())
{
newX = App.GetWidth();
}
plSprite.SetPosition(newX, plSprite.GetPosition().y());
}


if(App.GetInput().IsKeyDown(sf::Key::Up));
{
float newY = plSprite.GetPosition().y - (deltaTime * PLAYER_SPEED);
plSprite.SetPosition(plSprite.GetPosition().x, newY);
}
if(App.GetInput().IsKeyDown(sf::Key::Down));
{
float newX = plSprite.GetPosition().x + (deltaTime * PLAYER_SPEED);
plSprite.SetPosition(plSprite.GetPosition().x, newY);
}

//Check for window event(like closing)
sf::Event myEvent;

//process all events
while(App.GetEvent(myEvent))
{
if (myEvent.Type == sf::Event::Closed)
{
App.Close();
}
}
App.Draw(bgSprite);
App.Draw(plSprite);
App.Display();
}
 
    return EXIT_SUCCESS;
}



3
General discussions / Where to start? tutorials
« on: November 20, 2008, 03:14:23 am »
Hello SFML forums!

I am new to SFML but very interested in it. I want to make a Risk-like game and was wondering which tutorials to do and in what order.

Thanks a ton and hope to see you all again!

Pages: [1]