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 - Chris Jozwiak

Pages: 1 2 [3] 4
31
General / Link error .exe
« on: March 19, 2013, 06:08:30 am »
Hello I'm trying to figure out how to use classes with sfml.  I know I can but this is the first i've programmed oo style. I'm fairly new to programming in C++ altogether.  I'm using vs 2012 and I'm getting the error:
1>LINK : fatal error LNK1104: cannot open file 'C:\Users\brr\documents\visual studio 2012\Projects\sfmlgame\Release\sfmlgame.exe'

Here's my main.cpp:

#include "functions.h"
int main()
{
        functions func;
       
    sf::CircleShape shape(100.f);
    shape.setFillColor(sf::Color::Green);
        bool running = true;
    while (running)
    {
 
                func.window.clear();
        func.window.draw(shape);
        func.window.display();
    }

    return 0;
}

functions.h:

#pragma once
#include <SFML/Graphics.hpp>
#include <SFML/System.hpp>
#include<SFML\Network.hpp>
#include <SFML/Window.hpp>
class functions
{
public:
        functions(void);
        ~functions(void);
        void Events();
        void Window();
        sf::RenderWindow window;
        sf::Event event;
       
};

 

functions.cpp:


#include "functions.h"




functions::functions(void)
{
}


functions::~functions(void)
{
}

void functions::Window(){
        window.setSize(sf::Vector2u(800,600));
        window.setTitle("Test");
       


}

void functions::Events(){
        while (window.pollEvent(event))
        {
            if (event.type == sf::Event::Closed)
                window.close();
        }
       
}

32
Graphics / Re: Font load issue...
« on: March 06, 2013, 03:06:26 am »
Ya.... About those debugging libraries.  Didn't build it in release config.  :-\ My bad.

33
Graphics / Re: Font load issue...
« on: March 05, 2013, 06:42:04 pm »
I'm in release mode and everything works except loading a font..

34
Graphics / Font load issue...
« on: March 03, 2013, 07:44:59 pm »
I can't seem to get my program to load the font. 
CodE:
#include <SFML/Graphics.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Network.hpp>
#include <SFML/System.hpp>
#include <iostream>
using namespace std;
int main()
{
        sf::RenderWindow window(sf::VideoMode(800, 600), "SFML works!", sf::Style::Close);     
        bool running = true;
        bool startmenu = true;
        bool ingame = false;
        bool gamemenu = false;

        //Declare Objects
        sf::Font font;
        if (!font.loadFromFile("ubuntu.ttf")){
                cout << "Could not load font..." << endl;
                system("PAUSE");
        }
        sf::Text text("Test", font, 50);
       
        text.setPosition(20,10);
        text.setScale(20,20);
        sf::RectangleShape rect;
        rect.setFillColor(sf::Color::Red);
        rect.setSize(sf::Vector2f(20,20));
        rect.setPosition(40,40);
       
        while (running){               

               


                sf::Event event;
                if (window.pollEvent(event)){

                        if (event.type == sf::Event::Closed)
                                running = false;
                       

                }
       
                window.clear();
                window.draw(text);
                window.draw(rect);
                window.display();
       
       
       
        }
    return 0;
}
 
It shows me failed to load font "tu.ttf" Failed to create font face.

My font is ubuntu.ttf.. Why is it outputting tu.ttf?

35
General / When is sfml 2.0 going to be the current version?
« on: February 26, 2013, 03:09:45 am »
When will 2.0 be the current instead of just for testing.  Also when will all of the tutorials be released?

36
General / Re: if statement and drawing to window problem...
« on: December 14, 2012, 06:27:44 pm »
Hm... I always miss those stupid things.  It works now.  I'll try to refrain from posting an issue without staring at it for at least 3 hours next time.  Thanks for pointing the other things out though. 

37
General / if statement and drawing to window problem...
« on: December 14, 2012, 05:40:32 pm »
Having a problem with drawing a rectangle to the window if my variable touching is equal to true.   The collision detection works fine.  If I put a printf statement within the if statement at the end it prints it out. I don't understand why it's not drawing.
#include <SFML\Graphics.hpp>
#include <SFML\System.hpp>
#include <SFML\Window.hpp>
#include <SFML\Network.hpp>
#define RAND_MAX 100;

   //Must get object to attach to player and follow player.
int main()
{
   
   sf::RectangleShape player;
   player.setSize(sf::Vector2f(30,30));
   player.setFillColor(sf::Color::Blue);
   sf::RectangleShape object;
   object.setSize(sf::Vector2f(30,30));
   object.setFillColor(sf::Color::Red);
   sf::RectangleShape object2;
   object2.setSize(sf::Vector2f(30,30));
   object2.setFillColor(sf::Color::Red);
   int x = rand();
   int y = rand();
   object2.setPosition(100,100);
   sf::RenderWindow window(sf::VideoMode(1024, 600), "Game");
   bool touching = false;
   
   player.setPosition(0,0);
   object.setPosition(100,100);

   while (window.isOpen())
   {
      sf::Event event;
      

      while(window.pollEvent(event))
      {
         if (event.type == sf::Event::Closed)
            window.close();
         if (sf::Keyboard::isKeyPressed(sf::Keyboard::Left)){
            player.move(-3,0);
            
         }
         else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Right)){
            player.move(3,0);
         }
         else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down)){
            player.move(0,3);
         }
         else if (sf::Keyboard::isKeyPressed(sf::Keyboard::Up)){
            player.move(0,-3);
         }
         
         if (object.getGlobalBounds().intersects( player.getGlobalBounds())){
            touching = true;
         }
         
         
         
         
      }

      
      
      window.clear();
      window.draw(player);
      window.draw(object);
      if (touching){
            window.draw(object2);
            
            
         }
      window.display();
      
      


   

      }
   return 0;
      


}

38
General / Re: Collision detection sfml 2.0
« on: December 14, 2012, 03:51:32 am »
Never mind.  Made a statement print out on the command line if the collision was true.  I just think my player.move method needs to be changed.  When the event polls i think it overruns the collision and the player keeps moving despite the player.move(0,0).

39
General / Re: Collision detection sfml 2.0
« on: December 14, 2012, 03:04:59 am »
Okay so I tried
if (object.getGlobalBounds().intersects( player.getGlobalBounds())){
            
            touching = true;
         }
         if (touching == true){
            player.move(0,0);
         }


:-\

40
General / Re: Collision detection sfml 2.0
« on: December 14, 2012, 01:13:26 am »
Okay what I'm trying to do is make a classic Snake game.  I think i would need to use something like object.GetGlobalBounds().contains().  Then I'm unsure what to put in the contains function.  I put in a number and a point?  What would the point be?

41
General / Collision detection sfml 2.0
« on: December 13, 2012, 03:48:20 am »
How would i perform a simple box collision detection in sfml?

42
Network / Re: SFML 2.0 Help?
« on: November 15, 2012, 07:34:44 pm »
 :-[ Woops.... cant believe i missed that!!! Wow i should prob just quit now.  I have programmed before I just completely missed that o_o.......

43
Network / Re: SFML 2.0 Help?
« on: November 15, 2012, 05:57:01 pm »
Edited topic.

44
Network / SFML 2.0 Help?
« on: November 15, 2012, 05:41:12 am »
Sorry noob here.  Heard 1.6 had bugs and kinda turned me away from downgrading to it just to learn the ropes.  But i tried using the network example in the docs.  Copied the server code into a new project. Here is the code: 

 // Create a listener to wait for incoming connections on port 55001
#include <SFML\Network.hpp>
#include <SFML\Graphics.hpp>
#include <SFML\System.hpp>
#include <iostream>

using namespace std;

sf::UdpSocket listener;
 listener.listen(55001);

 // Wait for a connection
 sf::UdpSocket socket;
 listener.accept(socket);
 cout << "New client connected: " << socket.getRemoteAddress() << std::endl;

 // Receive a message from the client
 char buffer[1024];
 std::size_t received = 0;
 socket.receive(buffer, sizeof(buffer), received);
 std::cout << "The client said: " << buffer << std::endl;

 // Send an answer
 std::string message = "Welcome, client";
 socket.send(message.c_str(), message.size() + 1);
 

I'm getting a whole bunch of weird errors... errors with cout even though I have iostream included.  Confused help anyone?

EDIT:: Both socket.recieve and socket.send give me an error of this specifier has no storage class or type specifier  listener. listen same thing.  cout same thing and it the "<<" giver error expected a declaration.  This is the only file in the project. main.cpp.

45
General / SFML 1.6 with visual studio 2012?
« on: November 13, 2012, 09:57:18 pm »
Would I have to compile the library with vs 12 first or should it just work after I link stuff?

Pages: 1 2 [3] 4
anything