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

Pages: 1 [2]
16
General / Adding 2 Events in an SFML Application?
« on: September 26, 2011, 11:42:58 am »
Okay, i learned how to initialize an Event through this code
Code: [Select]
while (Running)
{
    sf::Event Event;
    while (App.GetEvent(Event))
    {
        // Process event
    }

    App.Display();
}


I then became zealous and created 2 events
Code: [Select]
while (Running)
{
    sf::Event Event;
    sf::Event Second;
    while (App.GetEvent(Event))
    {
        // Process event
    }

    while(App.GetEvent(Second))
    {
        //Process other events
     }

    App.Display();
}


Then when I run my SFML program, it releases this...

"Run-Time Check Failure #3 - The variable 'Second' is being used without being initialized."

I don't get it. How do I initialize my Event named Second?

Cheers.

17
Graphics / How to simulate Mario Jump? (moving the sprite in mid-air)
« on: September 26, 2011, 11:18:47 am »
Greetings

Okay, i made this chunk of code that makes the sprite "jump". I havn't really learned anything about manipulating the FPS of a program, so it might explain how i formulated my jump sequence.


I managed to make the sprite "jump" when I press the "Up" button; however, I'm not sure how to make the sprite move horizontally while in mid-air like how mario manages to move horizontally before touching the ground.

Here is part of my code.

Code: [Select]
while(Window.IsOpened())
{

while(Window.GetEvent(Event))
{

if((Event.Type == Event.KeyPressed) && (Event.Key.Code == Key::Up))
{
for(int c = 0; c < 240; c++)
{
Sprite.Move(0, -1.0);
Window.Clear();
Window.Draw(Sprite);
Window.Display();
}

for(int c = 240; c > 0; c--)
{
Sprite.Move(0, 1.0);
Window.Clear();
Window.Draw(Sprite);
Window.Display();
}

}



}
while(Window.GetEvent(Event))
{
if(Event.Type == Event.Closed)
{
Window.Close();
}
else if((Event.Type == Event.KeyPressed) && (Event.Key.Code == Key::Left))
{

Sprite.Move(-10.0, 0);
Window.Clear();
Window.Draw(Sprite);
Window.Display();

}
else if((Event.Type == Event.KeyPressed) && (Event.Key.Code == Key::Right))
{

Sprite.Move(10.0,0);
Window.Clear();
Window.Draw(Sprite);
Window.Display();

}



}



}




Cheers.

18
Graphics / How to move a sprite without leaving multiple copies?
« on: September 12, 2011, 02:47:13 pm »
Well,  i was trying to make my sprite move to the left, however, Not only does it move to the left, it leaves a copy of the sprite at its former place.

How do i just let it move to the left WITHOUT leaving a copy of the sprite at its former place?

Here is my code:

Code: [Select]
#define SFML_STATIC

#include<iostream>
#include<SFML\System.hpp>
#include<SFML\Graphics.hpp>
using namespace std;
using namespace sf;

int main()
{

Image Image;


if (!Image.LoadFromFile("ToadR.png"))
return 1;

VideoMode Vmode(800,600,32);
RenderWindow Window(Vmode, "I am Awesome.");

Sprite Sprite;
Sprite.SetImage(Image);
float x = 400.0;
float y = 300.0;
Sprite.SetPosition(x, y);
Event Event;



while(Window.IsOpened())
{
Window.Draw(Sprite);
Window.Display();


while(Window.GetEvent(Event))
{
if(Event.Type == Event.Closed)
{
Window.Close();
}
else if((Event.Type == Event.KeyPressed) && (Event.Key.Code == Key::Left))
{

Sprite.Move(-10.0, 0);




}

}




}
return 0;
}




I'm stumped. I hope I could get help. Thanks!

19
Graphics / error LNK2019
« on: September 04, 2011, 01:54:01 pm »
Quote from: "Groogy"
You forgot sfml-window


That did the trick. Awesome.


Now that the console shows up, it says that it "failed to load MarioStanding.png" because "png not supported".

How do i fix this

cheers

20
Graphics / error LNK2019
« on: September 04, 2011, 12:56:56 pm »
Hello, I was trying to type a code just to add a sprite. however, before i can even put in the sprite in image i get this darn error message
Code: [Select]


1>------ Build started: Project: loadsprite, Configuration: Debug Win32 ------
1>  main.cpp
1>sfml-graphics-s-d.lib(Image.obj) : error LNK2019: unresolved external symbol "public: bool __thiscall sf::Window::SetActive(bool)const " (?SetActive@Window@sf@@QBE_N_N@Z) referenced in function "public: bool __thiscall sf::Image::CopyScreen(class sf::RenderWindow &,class sf::Rect<int> const &)" (?CopyScreen@Image@sf@@QAE_NAAVRenderWindow@2@ABV?$Rect@H@2@@Z)
1>sfml-graphics-s-d.lib(GraphicsContext.obj) : error LNK2019: unresolved external symbol "public: void __thiscall sf::Context::SetActive(bool)" (?SetActive@Context@sf@@QAEX_N@Z) referenced in function "public: __thiscall sf::priv::GraphicsContext::GraphicsContext(void)" (??0GraphicsContext@priv@sf@@QAE@XZ)
1>sfml-graphics-s-d.lib(GraphicsContext.obj) : error LNK2019: unresolved external symbol "public: static class sf::Context & __cdecl sf::Context::GetGlobal(void)" (?GetGlobal@Context@sf@@SAAAV12@XZ) referenced in function "public: __thiscall sf::priv::GraphicsContext::GraphicsContext(void)" (??0GraphicsContext@priv@sf@@QAE@XZ)
1>sfml-graphics-s-d.lib(GraphicsContext.obj) : error LNK2019: unresolved external symbol "public: static bool __cdecl sf::Context::IsContextActive(void)" (?IsContextActive@Context@sf@@SA_NXZ) referenced in function "public: __thiscall sf::priv::GraphicsContext::GraphicsContext(void)" (??0GraphicsContext@priv@sf@@QAE@XZ)
1>******\Debug\loadsprite.exe : fatal error LNK1120: 4 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========



here is my code so far...

Code: [Select]
#include<iostream>
#include<SFML\System.hpp>
#include<SFML\Graphics.hpp>
using namespace std;
using namespace sf;

int main()
{

sf::Image Image;
if (!Image.LoadFromFile("MarioStanding.png"))
return 1;
return 0;



I linked towards
sfml-graphics-s-d.lib
sfml-main.lib
sfml-system-s-d.lib


what's wrong with my code? How can I fix it?

Cheers

Pages: 1 [2]
anything