Jump to content
  • Advertisement

Camilos

Member
  • Content Count

    26
  • Joined

  • Last visited

Community Reputation

120 Neutral

About Camilos

  • Rank
    Member
  1. Camilos

    Error is driving me nuts

    thx for explaining
  2. Camilos

    Error is driving me nuts

    thx, it works now :D
  3. Camilos

    Error is driving me nuts

    #include "VisibleGameObject.h" class PlayerPaddle : public VisibleGameObject { public: PlayerPaddle(); ~PlayerPaddle(); }; header now cpp #include "basic.h" #include "PlayerPaddle.h" PlayerPaddle::PlayerPaddle(){ } PlayerPaddle::~PlayerPaddle(){ };
  4. Camilos

    Error is driving me nuts

    and the VisibleObject.h  #include <SFML\Graphics.hpp> class VisibleGameObject { public: VisibleGameObject(); virtual ~VisibleGameObject(); virtual void Load(std::string filename); virtual void Draw(sf::RenderWindow & window); virtual void SetPosition(float x, float y); private: sf::Sprite Sprite; sf::Texture Texture; std::string Filename; bool IsLoaded; }; and the cpp file: #include "basic.h" #include "VisibleGameObject.h" VisibleGameObject::VisibleGameObject() { IsLoaded = false; } VisibleGameObject::~VisibleGameObject() { } void VisibleGameObject::Load(std::string filename) { if(Texture.loadFromFile(filename) == false) { Filename = ""; IsLoaded = false; } else { Filename = filename; Sprite.setTexture(Texture); IsLoaded = true; } } void VisibleGameObject::Draw(sf::RenderWindow & renderWindow) { if(IsLoaded) { renderWindow.draw(Sprite); } } void VisibleGameObject::SetPosition(float x, float y) { if(IsLoaded) { Sprite.setPosition(x,y); } }
  5. Camilos

    Error is driving me nuts

    posting the output of the debugger in case it would help 1>------ Build started: Project: Pong 2.0, Configuration: Debug Win32 ------ 1>  main.cpp 1>c:\users\ruben\documents\visual studio 2010\projects\pong 2.0\pong 2.0\visiblegameobject.h(4): error C2011: 'VisibleGameObject' : 'class' type redefinition 1>          c:\users\ruben\documents\visual studio 2010\projects\pong 2.0\pong 2.0\visiblegameobject.h(4) : see declaration of 'VisibleGameObject' 1>c:\users\ruben\documents\visual studio 2010\projects\pong 2.0\pong 2.0\gameobjectmanager.h(23): warning C4150: deletion of pointer to incomplete type 'VisibleGameObject'; no destructor called 1>          c:\users\ruben\documents\visual studio 2010\projects\pong 2.0\pong 2.0\visiblegameobject.h(4) : see declaration of 'VisibleGameObject' 1>  game.cpp 1>c:\users\ruben\documents\visual studio 2010\projects\pong 2.0\pong 2.0\visiblegameobject.h(4): error C2011: 'VisibleGameObject' : 'class' type redefinition 1>          c:\users\ruben\documents\visual studio 2010\projects\pong 2.0\pong 2.0\visiblegameobject.h(4) : see declaration of 'VisibleGameObject' 1>c:\users\ruben\documents\visual studio 2010\projects\pong 2.0\pong 2.0\gameobjectmanager.h(23): warning C4150: deletion of pointer to incomplete type 'VisibleGameObject'; no destructor called 1>          c:\users\ruben\documents\visual studio 2010\projects\pong 2.0\pong 2.0\visiblegameobject.h(4) : see declaration of 'VisibleGameObject' 1>c:\users\ruben\documents\visual studio 2010\projects\pong 2.0\pong 2.0\game.cpp(12): error C2039: 'Load' : is not a member of 'PlayerPaddle' 1>          c:\users\ruben\documents\visual studio 2010\projects\pong 2.0\pong 2.0\playerpaddle.h(3) : see declaration of 'PlayerPaddle' 1>c:\users\ruben\documents\visual studio 2010\projects\pong 2.0\pong 2.0\game.cpp(13): error C2039: 'SetPosition' : is not a member of 'PlayerPaddle' 1>          c:\users\ruben\documents\visual studio 2010\projects\pong 2.0\pong 2.0\playerpaddle.h(3) : see declaration of 'PlayerPaddle' 1>  Generating Code... 1>  Compiling... 1>  PlayerPaddle.cpp 1>  Generating Code...
  6. Camilos

    Error is driving me nuts

    And i'm stuck again :(  got up to part 5 pretty easy but know i've got an error and i don't know why: PlayerPaddle *player1 = new PlayerPaddle(); player1->Load("images/paddle.png"); player1->SetPosition((1024/2)-45,700); gameObjectManager.Add("Paddle1",player1); In the last line, it says that the type of Playerpaddle* is incompatible with parameter of type VisibleGameObject*  but Playerpaddle is a class derived from VisibleGameObject so why doesn't he accept it?
  7. Camilos

    Error is driving me nuts

    IT'S ALIVE!!!!   I finally completed step 2 from http://www.gamefromscratch.com/page/Game-from-Scratch-CPP-Edition-Part-2.aspx after two days of searching here is the now correct code for people who experienced similar problems:  #include <SFML\Graphics.hpp> #include <SFML\Window.hpp> #include <SFML\Audio.hpp> #include <SFML\System.hpp> #include <iostream> #include <ctime> #include <stdio.h> #include <map> #include <cassert> #include <string> game.h:  #include "basic.h" class Game{ public: void Start(); private: void GameLoop(); bool IsExiting(); enum GameState { Uninitialized, ShowingSplash, Paused, ShowingMenu, Playing, Exiting }; GameState gameState; sf::RenderWindow mainWindow; }; Game.cpp: #include "basic.h" #include "game.h" #include <string> void Game::Start(){ gameState= Game::Playing; mainWindow.create(sf::VideoMode(1027,768,32),"Pong"); while(!IsExiting()){ GameLoop(); } mainWindow.close(); }; bool Game::IsExiting(){ if(gameState == Game::Exiting){ return true;} else{ return false;}; } void Game::GameLoop(){ sf::Event Event; while(mainWindow.pollEvent(Event)){ switch(gameState){ case Game::Playing: mainWindow.clear(sf::Color::Black); mainWindow.display(); if((Event.type == sf::Event::Closed)||(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))){ gameState = Game::Exiting; }; break; }; }; }; and main.cpp #include "basic.h" #include "game.h" int main(){ Game Pong; Pong.Start(); return 0; }; God i'm glad that it works
  8. Camilos

    Error is driving me nuts

    think I was wrong and that the problem lays with sf::RenderWindow Game::MainWindow;  because i've changed the code and it worked(kind of, not like I wanted) but when i put this line (sf::RenderWindow Game::MainWindow;) it showed the error.   Edit: I think i've found it, ive found this link http://stackoverflow.com/questions/24318663/displaying-window-with-sfml and when i removed the static, the error vanished,
  9. Camilos

    Error is driving me nuts

    What i meant was that the same thing happend as before, when the console screen appeared, an error message appeared saying  '"Unhandled exception at 0x77cad062 in Pong.exe: 0xC0000005: Access violation writing location 0x00000004"
  10. Camilos

    Error is driving me nuts

    ok, i've tried changing it to a string variable and then i get this error: >game.obj : error LNK2001: unresolved external symbol "public: static class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > Game::gameState" (?gameState@Game@@2V?$basic_string@DU?$char_traits@D@std@@V?$allocator@D@2@@std@@A)   and i don't really understand it   here are the code  class Game{ public: static void Start(); static std::string gameState; Game(); ~Game(); private: static bool IsExiting(); static void GameLoop(); }; #include "basic.h" #include "game.h" #include <string> Game::Game(){ gameState = "Uninitialized"; }; Game::~Game(){ }; void Game::Start(){ if(gameState != "Uninitialized"){ return; }; gameState= "Playing"; }; bool Game::IsExiting(){ if(gameState == "Exiting"){ return true; } else{ return false; }; } void Game::GameLoop(){ sf::Event Event; sf::RenderWindow mainWindow(sf::VideoMode(1024,768,32),"Pong"); while(mainWindow.pollEvent(Event)){ if(gameState == "Playing"){ mainWindow.clear(sf::Color::Black); mainWindow.display(); if((Event.type == sf::Event::Closed)||(sf::Keyboard::isKeyPressed(sf::Keyboard::Escape))){ gameState = "Exiting"; }; } }; };
  11. Camilos

    Error is driving me nuts

    didn't work, but I think i'm going to change gameState to a string var, see if that works
  12. Camilos

    Error is driving me nuts

    I kind of guessed this was the case, but i don't understand why it is a null pointer or how to fix it.
  13. Camilos

    Error is driving me nuts

    I know that there is something wrong with Game::GameState Game::gameState = Uninitialized; because that's when the error appears and i get this in the output: First-chance exception at 0x77cad062 in pong.exe: 0xC0000005: Access violation writing location 0x00000004. Unhandled exception at 0x77cad062 in pong.exe: 0xC0000005: Access violation writing location 0x00000004.   anybody know's how to fix this?   PS: maybe somebody can run the code and see the problem themselve
  14. Camilos

    Error is driving me nuts

    currently trying something but don't know if it will work so if you know something, please tell me
  15. Camilos

    Error is driving me nuts

    I don't know if this helps but when  started pong again this appeared:   Visual C++ found a suitable location to store its browsing database and IntelliSense files for the solution "C:\Users\Ruben\documents\visual studio 2010\Projects\Pong\Pong.sln."   Visual C++ examined the folder "C:\Users\Ruben\documents\visual studio 2010\Projects\Pong." This folder is not suitable because of the following: The browsing database in this directory is open by another instance of Visual Studio and cannot be reopened.  User Ruben on RUBEN-HP has it open.   Because a 'Fallback Location' was not specified in the C++ Advanced Options, Visual C++ is attempting to use your temporary directory.   Visual C++ examined the folder "C:\Users\Ruben\AppData\Local\Temp\VC++\pong-7e910abd." This folder is suitable because of the following: The directory is on a local drive.   The 'Fallback Location' is configurable under C++ Advanced Options.   Press OK to use this location. Press Cancel to disable C++ browsing information and IntelliSense for this session.
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!