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.


Topics - AngelHoof

Pages: [1]
1
Graphics / Simulating Window-Border Collision!
« on: August 05, 2011, 09:02:20 pm »
Hey!

Got this tiny 'lil problem now... I'm trying to keep my moving sprite from going outside the window borders, currently using:

Code: [Select]

float KeyMove = 0.10f;

sf::FloatRect BorderColl(0, 0, 800, 600);
sf::Vector2f BlobPosition = Blob.GetPosition();
bool CheckBorderColl = BorderColl.Contains(BlobPosition);
if (CheckBorderColl == 1);
{
if (ShiftKeyDown)
KeyMove = 0.3f;

if (LeftKeyDown)
Blob.Move(-KeyMove, 0);
if (RightKeyDown)
Blob.Move(KeyMove, 0);
if (UpKeyDown)
Blob.Move(0, -KeyMove);
if (DownKeyDown)
Blob.Move(0, KeyMove);
if (GKeyDown)
Blob.Rotate(KeyMove);
if (HKeyDown)
Blob.Rotate(-KeyMove);
}

Win.Clear();
Win.Draw(Blob);
Win.Display();

}


I originally had it as
Code: [Select]
while (CheckBorderColl)

but that froze the program as soon as it executed... Umm, am I using the wrong functions for checking this, any ideas?

2
Graphics / Simulating character movement - How do? [SOLVED]
« on: July 21, 2011, 05:10:18 pm »
Hey!

So, I've managed to get together a blob that moves around the screen with the WASD keys, by this code:

Code: [Select]

const sf::Input& Input = Win.GetInput();
bool LeftKeyDown = Input.IsKeyDown(sf::Key::A);
bool RightKeyDown = Input.IsKeyDown(sf::Key::D);
bool UpKeyDown = Input.IsKeyDown(sf::Key::W);
bool DownKeyDown = Input.IsKeyDown(sf::Key::S);


And then later down the switch (Event.Type) this:
(Head is the sprite I want to control movement with)
Code: [Select]

case sf::Event::KeyPressed:
if (UpKeyDown)
Head.Move(0, -10);
if (DownKeyDown)
Head.Move(0, 10);
if (RightKeyDown)
Head.Move(10, 0);
if (LeftKeyDown)
Head.Move(-10, 0);


Now, this works to a degree, using the sf::Input i can press up and right  at the same time and it'll go diagonal. (Whereas i just had KeyPressed before)

However, upon pressing for example W (to go up) it moves one step (10 pixels) then stops for about half a second, then continues relatively smooth.

I guess I should use the clock somehow and decrease the Move to maybe 1 pixel per 0.1 seconds or something, so that I can get the smooth movement I want.

Just not sure how to go about this, any ideas?

Also, sorry if this is in the wrong section.

3
General / Visual Studio 2010 Express Problems [SOLVED]
« on: June 29, 2011, 01:48:20 pm »
Hiya...

So, once again I've attempted to get SFML to work, with no real success.

I run this code:

Code: [Select]
#include <SFML/Graphics.hpp>

int main()
{
    // Create the main rendering window
    sf::RenderWindow App(sf::VideoMode(800, 600, 32), "SFML Graphics");
   
    // Start game loop
    while (App.IsOpened())
    {
        // Process events
        sf::Event Event;
        while (App.GetEvent(Event))
        {
            // Close window : exit
            if (Event.Type == sf::Event::Closed)
                App.Close();
        }

        // Clear the screen (fill it with black color)
        App.Clear();

        // Display window contents on screen
        App.Display();
    }

    return EXIT_SUCCESS;
}


And get this in my output:
Code: [Select]
1>------ Build started: Project: SFMLFixThisShit, Configuration: Release Win32 ------
1>SFMLFixThisShit.obj : error LNK2001: unresolved external symbol "public: void __thiscall sf::Window::Display(void)" (?Display@Window@sf@@QAEXXZ)
1>SFMLFixThisShit.obj : error LNK2001: unresolved external symbol "public: bool __thiscall sf::Window::GetEvent(class sf::Event &)" (?GetEvent@Window@sf@@QAE_NAAVEvent@2@@Z)
1>SFMLFixThisShit.obj : error LNK2001: unresolved external symbol "public: bool __thiscall sf::Window::IsOpened(void)const " (?IsOpened@Window@sf@@QBE_NXZ)
1>SFMLFixThisShit.obj : error LNK2001: unresolved external symbol "public: void __thiscall sf::Window::Close(void)" (?Close@Window@sf@@QAEXXZ)
1>SFMLFixThisShit.obj : error LNK2001: unresolved external symbol "public: __thiscall sf::VideoMode::VideoMode(unsigned int,unsigned int,unsigned int)" (??0VideoMode@sf@@QAE@III@Z)
1>C:\Users\Ante\Documents\Visual Studio 2010\Projects\SFMLFixThisShit\Release\SFMLFixThisShit.exe : fatal error LNK1120: 5 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========


It's configured for release, I have Linker->Input = sfml-graphics.lib, in the VC++ Directories I have the Include folder and lib folder from the VC++ install directories added in, whereas the SFML files are.

What did I miss? I'm going crazy here.

4
General discussions / Microsoft Visual C++ 2010 Express problems.
« on: December 01, 2010, 05:43:41 am »
Hi!

Firstly, sorry if I'm just being stupid - I've always wanted and tried to be a computer geek but sometimes I just think it may not be for me...


Anyway, my problem is this: When I build/compile (whichever is the proper word) the following code

Code: [Select]

#pragma comment (lib, "sfml-window.lib")
#include <SFML/Window.hpp>
#include <iostream>

#define width 800
#define length 600
#define depth 32


int main()
{
sf::Window MainWindow(sf::VideoMode(width, length, depth), "Tester");
bool running = false;
while (running);
{
MainWindow.Display();

}
return 0;
}


works fine - I had big problems with getting the libs and linkers and whatnot to work correctly, so I was pretty bummed to see that when I actually run this I get an error saying

"Run-Time check failure #2 - Stack around the variable "MainWindow" was corrupted."

If I hit the Continue button after this, I get another message telling me that the .exe has been "buffer overrun, corrupting the internal state of the program".


I could do the tutorials fine on Bloodshed Dev-Cpp, which leads me to believe that I've done something wrong, or have forgotten something.

Not being able to finish even the first tutorial makes me a sad panda, truly.


Thanks for any replies!

Sincerely,

AngelHoof

Pages: [1]