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

Pages: [1]
1
General / Draw text with OpenGL?
« on: May 25, 2015, 09:39:49 pm »
I'm trying to draw 2D text in a sf::window so that I can use OpenGL in it too, but you (correct me if i'm wrong) can only draw with render windows. Is it possible to draw stuff in 2D (text etc.) with OpenGL in sf::Window class? Or should I use a different library?  ???

2
General / How to move something to rotation of shape?
« on: May 16, 2015, 09:31:41 pm »
Is there a way to move a sprite directly to the rotation of another (with getRotation())? The only way I can think of is to move it in a certain movement for when the other sprite is at every certain rotation, but surely there must be a much simpler and easier way? I tried:
shape1.move(shape2.getRotation());
 

3
Graphics / Movement and origin help
« on: May 14, 2015, 09:46:44 pm »
Hi
In a game I'm making, for one object, it has to rotate when triggered, but it's a bit complicated.  Basically I don't know how to rotate the shape from it's centre with setOrigin, because I have already used it. My code probably explains it better... Perhaps there is an easy solution to this?

 

shape1.setOrigin(-100, -375);

...
window.clear(sf::Color::Cyan);

si.setPosition(shape2.getPosition());
...
if (sf::Keyboard::isKeyPressed(sf::Keyboard::Down))
{
shape1.rotate(0.1); //need to rotate it from it's centre (x/2, y/2)
}

 

4
Graphics / Set position depending on another entity
« on: May 12, 2015, 09:04:31 pm »
Hi

I want to set the position of a shape to the same (or roughly the same, doesn't really matter) position of another shape. However I cant just do .setPosition(points) as the shape is often moving, therefore I would like to set it to same position as the other shape (every time it is triggered). I tried to set the position to the other shape's global bounds. I attempted "shape1.setPosition(shape2gbs)". How can I do this?  ;)

5
General / Entity origin irrelevant to rotation
« on: May 03, 2015, 09:55:12 pm »
I'm experiencing a problem with rotating a rectangle shape, I need it to rotate around the center of the rectangle, not the top left corner by default. However I have done .setOrigin(-100, -300), yet when I do .rotate(0.1) it still rotates from 0, 0 (the default, top left corner). I can't get my head round this, any ideas? It may be difficult to upload the relevant parts of my code, as my code is very large.

6
Audio / Sample volume of audio file every second?
« on: April 27, 2015, 04:46:27 pm »
I'm not expecting you to write a load of code for me (unless its very simple), but can anyone advise on if it is possible to sample the amplitutude/volume of the .wav/.ogg file every 1 second or less with the sfml audio? What function would allow me to do this? And please could you explain how it would work briefly if there is a function for it? Thanks  ;)

7
Graphics / Screen view wont change
« on: April 25, 2015, 03:37:56 pm »
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/System.hpp>
#include <Windows.h>


int main()
{
        sf::RenderWindow window1(sf::VideoMode(800, 700), "window");

        sf::Texture tx1;
        tx1.loadFromFile("pic.jpg");

        sf::Sprite st1;
        st1.setTexture(tx1);



        while (window1.isOpen())
        {
                sf::Event event1;
                while (window1.pollEvent(event1))
                {
                        if (event1.type == sf::Event::Closed)
                                window1.close();
                }



                window1.clear(sf::Color::Green);
                sf::View view1(sf::Vector2f(350, 300), sf::Vector2f(300, 300));

                view1.setCenter(200, 200);
                view1.move(400, 400);
                window1.draw(st1);

                window1.display();
        }
}
 
How do I make it work?

8
Graphics / != symbol error with sf::CircleShape
« on: April 22, 2015, 08:37:09 pm »
Can someone help me with points of a sprite? I am trying to make a sprite move when it intersects another's bounding box, but my code should be pretty much self explanitory on what im trying to do. I want the sprite to 'glide' or move smoothly in steps of 50 or less. How would I get the "not equal" bit right?
       
if (ball.getGlobalBounds().intersects(paddle1.getGlobalBounds()))
                {
                        while (ball.getGlobalBounds != (400, -260)){
                ball.move(20, 0);
               
                             }
 

9
Graphics / Bounding Box Help :/
« on: April 22, 2015, 05:06:14 pm »
Hello, I'm trying to make a simple game that needs to detect when one sprite touches another's bounding box, but I don't quite understand the code for this. Sorry if this has already been posted, but I could not find any help. The bit I don't understand is
// check collision with another box (like the bounding box of another entity)
sf::FloatRect otherBox = ...; //What goes here??
if (boundingBox.intersects(otherBox))
{
//collision
}
 

10
Audio / [Noob alert] OpenAL32.dll missing error
« on: April 15, 2015, 08:01:40 pm »
I am trying to play a .wav file but it won't work. I have got the correct dependencies and links etc setup, however for my code it says "The program can't start because OpenAL32.dll is missing from your computer". However it IS in my linker settings, and I can see it in the SFML files. So why isn't it being found? My code:
#include <SFML/Graphics.hpp>
#include <SFML/Window.hpp>
#include <SFML/Audio.hpp>

int main()
{
        sf::Window window(sf::VideoMode(800, 600), "My window");

        // run the program as long as the window is open
        while (window.isOpen())
        {
                sf::SoundBuffer buffer;
                buffer.loadFromFile("WhatCan.wav");
                // load something into the sound buffer...

                sf::Sound sound;
                sound.setBuffer(buffer);
                sound.play();
               
               
                // check all the window's events that were triggered since the last iteration of the loop
                sf::Event event;
                while (window.pollEvent(event))
                {
                        // "close requested" event: we close the window
                        if (event.type == sf::Event::Closed)
                                window.close();
                }
        }

        return 0;

}
 

11
Graphics / SFML_T.exe has stopped working error
« on: April 14, 2015, 10:43:45 pm »
Hello, I am trying to draw a sprite I made with the texture, however when I run it I get "SFML_T.exe has stopped working. I am new to this by the way. However the texture seems to 'load', because if you don't include the draw sprite bit it works as it should. I read the tutorials, but they didn't really mention my problem. Here is my code:
#include <SFML/Graphics.hpp>

int main()
{
        sf::RenderWindow window1(sf::VideoMode(400, 400), "Window");
        window1.setVerticalSyncEnabled(true); // call it once, after creating the window
        while (window1.isOpen())
        {
                sf::Event event;
                while (window1.pollEvent(event))
                {
                        if (event.type == sf::Event::Closed)
                                window1.close();
                }
                window1.clear(sf::Color::Black);
               
                sf::Texture texture;
                if (!texture.loadFromFile("pic.jpg"))
                {
                        //error
                }
       
                sf::Sprite sprite1;
                sprite1.setTexture(texture);
                window1.draw(sprite1);
       
window1.display();

        }
       
}
 

12
General / [please read] Error with newly installed SFML
« on: April 11, 2015, 09:38:06 pm »
I am using windows 7 and have visual studio 2013, and have just installed SFML 2.2. I did exactly what it said in the sfml tutorial (also watched some youtube vids) however when i type the code in the tutorial I get this:

1>------ Build started: Project: sfml, Configuration: Debug Win32 ------
1>  main.cpp
1>c:\users\computer\documents\visual studio 2013\projects\sfml\main.cpp(1): fatal error C1083: Cannot open include file: 'SFML/Graphics.hpp': No such file or directory
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

 

Any ideas why this isn't working will be appreciated a lot. This is starting to drive me crazy now  :-[ Thanks in advance.

Pages: [1]
anything