1
Graphics / Maths and Rotations
« on: August 26, 2011, 06:29:52 am »
That is only a small problem, SFML is really great.
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.
case FINALSTAGE:
{
if(Event->Key.Code == sf::Key::N)
app->Close();
if(Event->Key.Code == sf::Key::S)
{
Initialize();
backgroundMusic = new sf::Music();
backgroundMusic->OpenFromFile("Ambient.ogg");
backgroundMusic->SetLoop(true);
backgroundMusic->Play();
}
break;
}
while(app->GetEvent(*Event))
{
if(Event->Type == sf::Event::KeyPressed)
{
if(Event->Key.Code == sf::Key::Escape)
app->Close();
switch(stage)
{
case INITIALSTAGE:
{
if(Event->Key.Code == sf::Key::Space)
{
Initialize();
backgroundMusic->Play();
}
break;
}
case GAMESTAGE:
{
if(Event->Key.Code == sf::Key::Space)
Initialize();
break;
}
case FINALSTAGE:
{
if(Event->Key.Code == sf::Key::N)
app->Close();
if(Event->Key.Code == sf::Key::S)
{
Initialize();
/ / here I had written: backgroundMusic-> Play () / / at this point throws the exception
}
break;
}
}
}
}
if(lifes == 0)
{
state = LOSE;
stage = FINALSTAGE;
backgroundMusic->Stop();
}
else if(points == 1000)
{
state = WIN;
stage = FINALSTAGE;
backgroundMusic->Stop();
}
Initialize();
clock->Reset();
while(app->IsOpened())
{
ManageKeyboardInput();
CollisionDetection();
Update();
Draw();
}
sf::image *img1 = new sf::image();
sf::image *img2 = new sf::image();
img1->loadfromfile("img1.png");
img2->loadfromfile("img2.png");
sprite->setimage(*img1);
Character *character = new Character(*img1);
/* in the class I do image = img1, where "image" is sf::image *image; */
character->setimage(*img2);
/* in the class i tried this:
delete image;
image = img2;
sprite->setimage(*image);*/
if(input.isKeyDown(sf::keys::a) && input.isKeyDown(sf::keys::d))
{
//stop character
}
while(app.getEvent(Event))
{
if(Event.type == sf::event::keyPressed)
{
if(Event.key.code == sf::key::a)
{
app.getEvent(Event); //to read the next event
if(Event.type == sf::event::keyPressed)
{
if(Event.key.code == sf::key::d)
{
//stop character
}
}
}
}
}