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

Pages: [1]
1
General / Qt Creator and sfml
« on: July 12, 2010, 02:10:09 am »
hi i just had a quick question, i am using sfml with qt and everything is working fine except the images from sfml show up white when rendered in the window. i make sure that they load. they show up because i clear the color to green and they show up white with out am image... i was wondering if this was qt related or not. i use the qt creator to compile it but i configured it with the msvc2008 compiler so i think it uses that. i link against libs made in vc++ and im using sfml2

ok i had solved this for one of the windows but now my second child window will not load the image lol any one have an idea?

2
General / link error
« on: June 19, 2010, 03:39:12 am »
i made my own lib from a project i want to use in the future and it was giving me a bunch of undefined refs so i made it a dll instead of a static lib and now it only gives me this error

obj\Release\ScriptConsole.o:ScriptConsole.cpp:(.text$_ZN3gui6ButtonD1Ev[gui::Button::~Button()]+0xe): undefined reference to `vtable for gui::Button'
collect2: ld returned 1 exit status

here is the Button class


Code: [Select]

#ifndef _BUTTON_H
#define _BUTTON_H

#include "UIState.h"

namespace gui
{
    class DLL_EXPORT Button
    {
        public:
            Button( float x, float y, float w, float h, std::string lua_script = "", std::string text = "" );
            ~Button();

            void SetPosition(float x, float y);
            void Render(sf::RenderWindow& window);
            void Update();

            void LetLuaUpdate(bool let) { _luaUpdate = let; }

            void Lock()     { _locked = true;   }
            void UnLock()   { _locked = false;  }

            inline bool Clicked();
            inline bool Hovering();
            inline bool Locked()    { return _locked; }

            void SetText(std::string text);
            float GetX() const { return _rect.Left;         }
            float GetY() const { return _rect.Top;          }
            float GetH() const { return _rect.GetHeight();  }
            float GetW() const { return _rect.GetWidth();   }

        private:
            sf::Font        _font;
            sf::Shape       _button;
            sf::Shape       _hoverRect;
            std::string     _textStr;
            std::string     _luaScript;
            sf::String      _text;
            bool            _locked;
            bool            _luaUpdate;
            sf::FloatRect   _rect;
            UIState*        _ui;
            LuaManager*     _lua;
    };
}

#endif




and the cpp file



Code: [Select]


#include "Button.h"

using namespace gui;


Button::Button(float x, float y, float w, float h, std::string lua_script, std::string text)
:
_ui(UIState::GetInst()),
_lua(LuaManager::GetInst()),
_rect(x,y,x+w,y+h)
{

    _textStr = text;
    _luaScript = lua_script;
    _luaUpdate = true;
    _font.LoadFromFile("system.ttf", 20);
    _text.SetFont(_font);

    _text.SetText(_textStr);
_text.SetCenter((_text.GetRect().Left + (_text.GetRect().Right - _text.GetRect().Left)/2),
(_text.GetRect().Top + (_text.GetRect().Bottom - _text.GetRect().Top)/2));

    _text.SetScale(0.45f,0.45f);

    SetPosition(x, y);
}

Button::~Button() {}

void Button::Render(sf::RenderWindow& window)
{
    window.Draw(_button);
if(Hovering())
window.Draw(_hoverRect);
window.Draw(_text);
}


void Button::SetPosition(float x, float y)
{
    _rect.Left = x;
    _rect.Right = x + _rect.GetWidth();
    _rect.Top = y;
    _rect.Bottom = y + _rect.GetHeight();
    _button = sf::Shape::Rectangle(_rect.Left, _rect.Top, _rect.Right, _rect.Bottom, sf::Color(200, 200, 200));

_hoverRect = sf::Shape::Rectangle(_rect.Left, _rect.Top, _rect.Right, _rect.Bottom, sf::Color(0,0,200,60));

_text.SetPosition(_rect.Left + _rect.GetWidth()/2, _rect.Top + _rect.GetHeight()/2);
}


void Button::Update()
{
    if(_luaUpdate)
    {
        if(Clicked())
        {
            _lua->DoFile(_luaScript);
            _ui->itemActive = 2;
        }
    }
}

bool Button::Clicked()
{
    return (
_ui->mouseX >= _rect.Left   &&
_ui->mouseX <= _rect.Right  &&
_ui->mouseY >= _rect.Top    &&
_ui->mouseY <= _rect.Bottom &&
_ui->mouseDown              &&
_ui->itemActive <= 1          // only allow one click a click (lol)
);
}

bool Button::Hovering()
{
    return (
_ui->mouseX >= _rect.Left   &&
_ui->mouseX <= _rect.Right  &&
_ui->mouseY >= _rect.Top    &&
_ui->mouseY <= _rect.Bottom
);
}

void Button::SetText(std::string text)
{
    _text.SetText(text);
}

3
SFML projects / 3d game engine
« on: May 09, 2010, 04:19:54 pm »
i've been working on a 3d game engine for a few months now and it uses sfml for window and input, i made my own 3d model format and an exporter for blender and im currently working on creating a scripting language/engine for it. writing a scripting language is super hard and i may abort the mission lol but my engine currently supports a small amount of things. lighting, texturing, billboarding, 3d model loading ( 3ds, md2, cell(mine), obj ), input, game states, 3d math and some sound. much more to come

4
Graphics / Unexpected error at window.Clear();
« on: May 09, 2010, 05:58:20 am »
i have an unexpected error at window.Clear and it is only with projects that i recently compiled cause i can still run old exes.

Code: [Select]

_window.Clear();// fail here
_window.Draw(_page[_currentPage]);
_window.Display();


any help would be nice

5
Window / delay in key presses(for movement)
« on: March 10, 2010, 01:54:05 am »
there is a delay in key presses, i have tried 2 different things the first one was using an input and getting a bool for the key pressed

Code: [Select]

void Player::Move(const sf::Input &input)
{
if( input.IsKeyDown( sf::Key::Up ))
{
m_yVel -= m_speed;
Animate();
}

else if(input.IsKeyDown( sf::Key::Down ))
{
m_yVel += m_speed;
Animate();
}


else if(input.IsKeyDown( sf::Key::Left ))
{
m_xVel -= m_speed;
Animate();
}

else if(input.IsKeyDown( sf::Key::Right ))
{
m_xVel += m_speed;
Animate();
}

if( input.IsKeyDown( sf::Key::A ))
weapon->Add(new Knife(m_x, m_y));
}


then i tried to do the switch statement taking an event

Code: [Select]

if(Event.Type == sf::Event::KeyPressed)
{
switch(Event.Key.Code){
case sf::Key::Up:
m_yVel -= m_speed;
Animate();
break;
case sf::Key::Down:
m_yVel += m_speed;
Animate();
break;
case sf::Key::Right:
m_xVel += m_speed;
Animate();
break;
case sf::Key::Left:
m_xVel -= m_speed;
Animate();
break;
default:
break;
}
}
if(Event.Type == sf::Event::KeyReleased)
{
switch(Event.Key.Code){
case sf::Key::Right:
m_xVel = 0;
break;
case sf::Key::Left:
m_xVel = 0;
break;
case sf::Key::Up:
m_yVel = 0;
break;
case sf::Key::Down:
m_yVel = 0;
break;
default:
break;
}
}
}


ps the first one i decrease the accel in the main eventhandling function

There is only a delay when you switch form left to right or up to down with out releasing the previous button first and it is like a 1/2 sec delay and if any of my friends play i dont want them complaining so HELP!!

6
Audio / sf::Sound internal OpenAL error in soundbuffer.cpp [Solved]
« on: March 08, 2010, 02:51:50 am »
when i play a sound about 1000 times it gives me the error and the sound goes away

my code



Code: [Select]

sf::Sound m_sound;

//this returns the sound buffer for the hit sound
m_sound.SetBuffer(soundMgr->GetSoundBuffer(SoundManager::kHit));

/*
 * the function above
 * sf::SoundBuffer &SoundManager::GetSoundBuffer(int id)
 * {
 * return m_buffers[id];  // an array of buffers for the sounds
 * }
*/

//when added to weapon manager
WeaponManager::Add(Entity *weapon)
{
    weapon->PlaySound();
    m_weaponList.push_back(weapon);
}



this is a sound that is located in a knife class that gets added to a vector in my weapon manager when throwen and will play the kife's sound when it is added

so if there is anything i can do

7
Graphics / drawing a sprite to an image
« on: January 02, 2010, 06:05:06 pm »
i want to draw a sprite on to an image so i can draw a bunch of sprites then display the image

i tried sprite.draw( image )

here i was drawing to an image i created, im doing this because im putting tiles on the entire map with 2 for loops and every frame it needs to redraw the tiles so i wanted to put them to an image ( maby another sprite ) and draw the image every loop hopfully speeding it up a little

i was looking at the doc and could not find anything so if anyone could give me a tip it would be cool

8
Graphics / clipping and blitting sprite sheets
« on: January 02, 2010, 01:10:36 am »
like in sdl or allegro when you can choose a portion of the sprite sheet and draw it to the screen, if there is a way to do this already correct me

9
Graphics / setting a transparent color
« on: January 02, 2010, 01:08:04 am »
i need to know how to set a transparent color so that i can have a sprite not in a block, how do you go about doing this

i mean like in sdl when you set (255, 0, 255) aka pink to be transparent is there a way in sfml?

Pages: [1]
anything