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

Pages: [1]
1
General / scale and resolution question
« on: December 15, 2015, 06:16:44 am »
So, I have made a button class where my "button" has dimensions and if the mouse is clicked within those dimensions then it activates it, but each button has its own sprite and when I change the resolution I think it will break because I need all the sprites to stay the same size relative to the resolution of the window and I need some way to change the dimensions for each button so they stay with the dimensions of the sprites texture when the window resolution is changed,  I'm very confused
if you need any snippets of my code please just ask, but I dont even know what I should post because im just plum stuck.

2
Graphics / [Solved]Namespace to load in textures
« on: September 14, 2015, 01:47:54 am »
Hi, I'm trying to make a namespace that can load in textures, I have made it load in sf::music, but I can't make it load in textures because it gives me an error saying no suitable conversion from sf::texture to const sf::texture exists here is my code:
//other namespace stuff
namespace Resource {
 static void loadTextureFromFile(sf::Texture& Texture, std::string FileName){
        if (!Texture.loadFromFile(FileName)){
            std::cout << "ERROR could not load " << FileName << std::endl;
        }
        else{
            std::cout << "Loaded" << FileName << std::endl;
        }
    }
//other namespace stuff
}
sf::RectangleShape MShape;
    Resource::loadTextureFromFile(MenuBackGround, "Background.jpg");
    MShape.setTexture(MenuBackGround);//error line
 
 
thanks in advance!!!

3
Audio / Trouble with a load music function
« on: September 13, 2015, 01:39:45 am »
I'm having some trouble in my class of loading music.
I'm trying to make a function so I can load in Music simply by calling a function and tossing in some perameters, here is what I have so far:
Load.h
#pragma onc
#include <string>
class Load
{
public:
        void LoadMusic(sf::Music MusicLoaded, std::string FileName);
};
 
Load.cpp
#include <SFML/Audio.hpp>
#include "Load.h"
#include <string>
#include <iostream>
void LoadMusic(sf::Music MusicLoaded, std::string FileName){
        if (!MusicLoaded.openFromFile(FileName)){
                std::cout << "ERROR could not load " << FileName << std::endl;
        }
        else{
                std::cout << "Loaded" << FileName << std::endl;
        }
}
 
main()
//unimportant junk
sf::Music MenuMusic;
Load LoadOBJ;
        LoadOBJ.LoadMusic(MenuMusic, "Resources/MenuMusic");
//unimportant junk
 
I tried to show as little code as possible, also this is only my second time ever working with classes.
errors:
 \include\sfml\audio\inputsoundfile.hpp(203): error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'
sfml-2.3.1\include\sfml\system\noncopyable.hpp(67) : see declaration of 'sf::NonCopyable::NonCopyable'
sfml-2.3.1\include\sfml\system\noncopyable.hpp(42) : see declaration of 'sf::NonCopyable'
1>          This diagnostic occurred in the compiler generated function 'sf::InputSoundFile::InputSoundFile(const sf::InputSoundFile &)'
sfml-2.3.1\include\sfml\system\mutex.hpp(89): error C2248: 'sf::NonCopyable::NonCopyable' : cannot access private member declared in class 'sf::NonCopyable'
sfml-2.3.1\include\sfml\system\noncopyable.hpp(67) : see declaration of 'sf::NonCopyable::NonCopyable'
sfml-2.3.1\include\sfml\system\noncopyable.hpp(42) : see declaration of 'sf::NonCopyable'
1>          This diagnostic occurred in the compiler generated function 'sf::Mutex::Mutex(const sf::Mutex &)'

(I removed My Computer Name, and the name of the project from the error's as it is unimportant)
Thx in advance Y'all!!!

4
General / sf::clock getting reset
« on: September 07, 2015, 09:49:09 pm »
how else could I do this without having to restart everytime the function is called?, I'm trying to reset the players position after a certain amount of time
sf::Clock Timer;
sf::Time elapsed;
sf::Time elapsed = Timer.getElapsedTime();
void ResetPosition(){
    Timer.restart();
    if (elapsed.asSeconds() >= 1){
        Player.setPosition(750, 200);
    }
 

5
General / display variables
« on: September 07, 2015, 07:52:27 pm »
How would I go about displaying a variable to the string, like a score or something?

6
General / somethings going wrong
« on: September 07, 2015, 03:44:18 am »

scroll down to see the new problem


I'm having an issue where when I hold down a key it sends a bunch of things to the program saying im pressing it. so I did
MainWindow.setKeyRepeatEnabled(false);//doesn't work
while (MainWindow.pollEvent(Event)){
                                if (Event.type == sf::Event::KeyReleased){
                                        if (Event.key.code == sf::Keyboard::D){
                                                if (PlayerColor == Blue){
                                                        BlueScore++;
                                                        ChooseNextPlayer();
                                                }
                                                if (PlayerColor == Pink){
                                                        GameOver();
                                                }
                                        }
                                        if (Event.key.code == sf::Keyboard::A){
                                                if (PlayerColor == Pink){
                                                        PinkScore++;
                                                        ChooseNextPlayer();
                                                }
                                                if (PlayerColor == Blue){
                                                        GameOver();
                                                }
                                        }
                                }
//that it my code for trying to make part of a sorting game

7
General / Greater than or equal to location
« on: September 04, 2015, 10:43:57 pm »
I'm wondering how I would find if something is farther than a certain position. here is my code:
sf::Vector2f PinkLocation=PinkPlayer.getPosition();
   if (PinkLocation >= sf::Vector2f(100, 100)){
                     //do stuff
      }
I know that it can't take the two numbers a time, but it there another way to do this?

8
Graphics / animation?
« on: September 03, 2015, 04:49:23 am »
I watched CodingMadeEasy's tutorial on sprite sheet animation, but I don't really get it, so I googled it, and there are many different ways to animate a sprite, and I'm wondering how exactly you would go about this, all of my sprite sheets I have made are 32x32 pixels (per frame), and are only 1 row going from left to right, how would I go about animating them and setting a speed at which they are animated?

9
General / Can't open Graphics.hpp
« on: September 02, 2015, 12:01:10 am »
I saved last night with a clean compile, woke up this morning, with errors all over my code, I tried to compile, and it said it couldn't open my Graphics.hpp, or any other header files, and I cant remember how I did the linker, please help!

10
General discussions / Looking for work?
« on: August 31, 2015, 02:26:37 pm »
Who thinks it would be a good idea for them to add a looking for work area to the forum for those looking to make something with SFML?

11
General / Building mechanic?
« on: August 31, 2015, 02:23:32 pm »
I have googled this issue a few times, and I can't come up with an idea, but i want to figure out how to make a block building mechanic in 2d, I think you could have like a sprite spawn at a players position+1 or something, but not exactly sure about it, so help would be greatly appreciated. Also I will not be able to reply to this too much, because i am at school, so. Yah thx in advance!!

12
Graphics / If with window.draw
« on: August 30, 2015, 08:36:35 pm »
I'm having an issue, I'm trying to make an inventory screen, and when the player presses "I" I want the window to show me their inventory, and pause the game, I have done this:

         if (sf::Keyboard::isKeyPressed(sf::Keyboard::I)){
            window.draw(BAG);
         }
//BAG is inventory screen;
I get no compile errors, and my game runs, but, It just displays without me pressing "I", "I" does nothing.

P.S. I've only been learning SFML for about a week now, so please don't be angry if I made a newbish mistake.

Pages: [1]