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

Pages: [1]
1
General / Re: Movement
« on: March 12, 2013, 05:12:21 pm »
I have a pretty good understanding of C++, but the best way for me to learn is to make mistakes :) I also have a pretty good book here that I use for reference if I get stuck. Thanks for the info though I will check out your list of books, and stop using "lol" at the end of my sentences :) bad habit!

2
General / Re: Movement
« on: March 11, 2013, 10:25:45 pm »
I don't know i'm just using trial and error lol.

EDIT: I see, I took it out of the main loop and now it works fine. Boy do I feel stupid :( Thanks very much for your help!

3
General / Movement
« on: March 11, 2013, 09:01:03 pm »
Hello, i'm back for more  ::)

So my sprite moves to my mouse position ok, but when I let go of the mouse it reverts to its original position. I tried using sf::keyboard::iskeypressed in an if statement and the same thing happened. Am I missing something?

Quote
while ( mainWindow.isOpen() )
     {

       sf::Texture tFly;
       tFly.loadFromFile( "fly.png" );
       sf::Sprite sFly;
       sFly.setTexture( tFly );

         sf::Event event;

       while( mainWindow.pollEvent( event ) )
       {
         if( event.type == sf::Event::Closed )
            mainWindow.close();
       }
      
       if (sf::Mouse::isButtonPressed(sf::Mouse::Left))
       {
            sFly.setPosition(sf::Mouse::getPosition(mainWindow).x, sf::Mouse::getPosition(mainWindow).y);
       }
 
         // Clear screen
         mainWindow.clear();
       mainWindow.draw( sFly );
 
         // Update the window
         mainWindow.display();
     }

Thanks very much in advance. ( I've googled everywhere and couldn't see anything related. )

4
General / Re: Unhandled exception (Render window)
« on: March 10, 2013, 12:42:30 am »
Ok thanks for the help, i'll start again lol

5
General / Re: Unhandled exception (Render window)
« on: March 10, 2013, 12:29:51 am »
Thanks for the reply!

So I can't have sf::RenderWindow in the Game class? Taking the static away breaks everything else. Sorry i'm just really confused, im a novice lol.

6
General / Unhandled exception (Render window)
« on: March 09, 2013, 11:46:39 pm »
I've been banging my head off a wall for two days now with this.

Game.h

Quote
#pragma once
#include "SFML/Window.hpp"
#include "SFML/Graphics.hpp"

class Game
{
public:
   static void Start();
   static sf::RenderWindow& GetWindow();
   const static sf::Event& GetInput();

   const static int vWidth = 800;
   const static int vHeight = 600;
   

private:
   static bool IsExiting();
   static void GameLoop();

   enum GameState { Uninitialized, Playing, Exiting };

   static GameState _gameState;

   static sf::RenderWindow _window;

};

Game.cpp
Quote
#include "stdafx.h"
#include "game.h"

void Game::Start(void)
{   
   if(_gameState != Uninitialized )
      return;

   _window.create( sf::VideoMode( vWidth, vHeight, 32), "flaccy" );

   _gameState = Game::Playing;

   while( !IsExiting() )
   {
      GameLoop();
   }

   _window.close();
   
}

bool Game::IsExiting()
{
   if( _gameState == Game::Exiting )
      return true;
   else
      return false;
}

sf::RenderWindow& Game::GetWindow()
{
   return _window;
}

const sf::Event& Game::GetInput()
{
   sf::Event currentEvent;
   _window.pollEvent( currentEvent );
   return currentEvent;
}

void Game::GameLoop()
{
   sf::Event currentEvent;
   _window.pollEvent( currentEvent );

   switch( _gameState )
   {
   case Game::Playing:
      {
         _window.clear( sf::Color( 0, 0, 0 ) );
         _window.display();

         if( currentEvent.type == sf::Event::Closed )
         {
            _gameState = Game::Exiting;
         }
      }

      break;
   }
}

Game::GameState Game::_gameState = Uninitialized;
sf::RenderWindow Game::_window;

When I run this I get the error...
Quote
Unhandled exception at 0x76f015de in flaccy second.exe: 0xC0000005: Access violation writing location 0x00000004.

Debugger shows this
Quote
>   flaccy second.exe!`dynamic initializer for 'Game::_window''()  Line 65 + 0x28 bytes   C++

and its stopped on sf::renderwindow in the game.cpp file.

Sorry if this is stupid but I couldn't seem to find an answer anywhere.

Visual Studio 2012, SFML 2.0

7
General / Re: Linker warnings
« on: March 03, 2013, 06:15:32 pm »
Ah ok, good to know everything is ok :)

Thanks for the reply!

8
General / Linker warnings
« on: March 03, 2013, 05:13:13 pm »
Hi,

I've been trying to get this set up properly and just can't seem to get it. I followed the tutorial on here to the letter, and tried both static and dynamic configs.

When I use the window.draw function I get this warning first...

Quote
Warning   1   warning LNK4098: defaultlib 'LIBCMT' conflicts with use of other libs; use /NODEFAULTLIB:library   E:\Visual Studio 2010\Projects\flaccy second\flaccy second\LINK   flaccy second

then 37 of these for system, graphics, window and main (the only ones I linked to in the additional dependencies)  ...

Quote
Warning   2   warning LNK4099: PDB 'sfml-graphics-s-d.pdb' was not found with 'sfml-graphics-s-d.lib(Color.cpp.obj)' or at 'E:\Visual Studio 2010\Projects\flaccy second\Debug\sfml-graphics-s-d.pdb'; linking object as if no debug info   E:\Visual Studio 2010\Projects\flaccy second\flaccy second\sfml-graphics-s-d.lib(Color.cpp.obj)   flaccy second

Everything works and runs OK, just not sure what is conflicting.

I appreciate your time to answer! :)

EDIT: C++, Visual studio 2010, SFML 2.0 RC (latest one)

9
Window / Re: window.draw creates link error
« on: March 02, 2013, 11:40:08 pm »
No, I had it set up as static to begin with but switched back to dynamic and removed the SMFL_STATIC reference

EDIT: I'm really sorry your right. I removed it from Release but failed horribly to remove it from Debug.

Really sorry to waste your time and thanks very much for the fast response :)

10
Window / Re: window.draw creates link error
« on: March 02, 2013, 11:31:56 pm »
Are you linking against sfml-graphics, sfml-window and sfml-system?

for release yes, for debug I link to sfml-system-d etc

11
Window / window.draw creates link error
« on: March 02, 2013, 11:19:03 pm »
Hello,

When I try to draw text to the screen, running in release or debug gives me the errors:

Quote
Error   1   error LNK2001: unresolved external symbol "public: static class sf::RenderStates const sf::RenderStates::Default" (?Default@RenderStates@sf@@2V12@B)   E:\Visual Studio 2010\Projects\flaccy frame\flaccy frame\main.obj   flaccy frame

and

Quote
Error   2   error LNK1120: 1 unresolved externals   E:\Visual Studio 2010\Projects\flaccy frame\Debug\flaccy frame.exe   flaccy frame

I'm pretty new to this but i'm pretty sure I have everything set up correctly, it's the only thing that has returned an error so far.

Quote
#include <SFML/Graphics.hpp>

int main()
{
   sf::VideoMode vMode( 800, 600, 32 );
   sf::RenderWindow window( vMode, "Flaccy" );

   sf::Text text("hello");

    while ( window.isOpen() )
    {
        sf::Event event;
        while ( window.pollEvent(event) )
        {
         switch ( event.type )
         {
         case sf::Event::Closed:
            window.close();
            break;

         default:
            break;
         }
           
        }

      window.clear( sf::Color( 255, 0, 0 ));
      window.draw(text);
        window.display();

    }

    return 0;
}


Visual Studio 2010 | C++ | Windows 7 x64 | GTX 570 | SFML 2.0 (downloaded it fresh yesterday)

Any help is greatly appreciated thanks...

Pages: [1]
anything