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 - Roose Bolton of the Dreadfort

Pages: [1] 2
1
General / SetFrameRate/VertSync?
« on: March 05, 2013, 11:02:24 am »
So I was happily making my game,

I set the framerate limit to 60 which makes it easy for me to build my game around as I wanted to make it perform at a steady 60 fps on all machines so I knew what my update speed was going to be.

When I was adding Box2D and working on the new stuff, I noticed that there was a slight stutter in the movement of the player which made it look terrible.

I stuck VSync on and this fixed the problem completely and all looked amazing.

However; I have heard that using both of them together is a big 'No'.. so what should I do?

2
SFML projects / Simple Easy Particle Engine
« on: February 25, 2013, 01:03:14 pm »
Hey All,

Been working on my game for about a month now and the other night decided I wanted a particle system in it. I didn't want to follow the usual route of 'effectors and emitters' but instead just wrote my own functions inside the particle manager eg 'Explode', 'Shrapnel', 'Afterburner' and its very easy to add more of your own particle effects.

I decided it could help some people so I decided to release it as it might be helpful to someone..

haven't released fully yet still cleaning up the code but will be released this week!

this is a video of the effects below, it just uses a simple sf::circleshape and a colour and this is what the outcome looks like.. note its only using 3 effects (afterburner, explode, supernova) I am not a designer so I am sure people can make even cooler stuff...

The system also uses some OpenGL shaders for glowing etc.



Cheers!

3
General / Fading/Scale over time..
« on: February 23, 2013, 05:35:30 pm »
Okay I am trying to make an object fade over a certain time;

so say I want it to fade over 1 second, if I want to find out how much to remove each frame, whats the algorithm for it?

Alpha is 255 so say I want it to fade over 1 second I can do 1/255 to give me how much to subtract.. but my framerate is set to 60.. so only 60 frames are called a second not 255..

Cheers guys.

4
General / What is this called?
« on: February 18, 2013, 04:56:12 pm »
So I am making a particle engine for my game.. all is going fine.

I was looking at some video's for ideas and saw this one



Notice how the particles have a 'glow' about them.. what is this called in OpenGL? Is it possible with SFML or will I have to start doing raw OpenGL code?

Thanks !

5
General / Simple c++ Question...
« on: January 30, 2013, 12:22:06 am »
Okay.

Say I have a base class which has some physics objects in its private members so;

NOTE - THIS IS A MINIMAL EXAMPLE.

BaseObject Header:
class BaseObject
{
        BaseObject();
        ~BaseObject();

        b2Body& GetBody();
        b2BodyDef& GetBodyDef();
        b2FixtureDef& GetFixtureDef();
        b2PolygonShape& GetPolygon();
        b2World& GetWorld();

private:
        b2Body* mBody;
        b2BodyDef mBodyDef;
        b2FixtureDef mFixtureDef;
        b2PolygonShape mPolygon;
        b2World *mWorld;
};
 

and I have a class that inherits it so;

DerivedObject Header:
class DerivedObject: public BaseObject
{

public:
        DerivedObject(void);
        ~DerivedObject(void);

private:


};
 

DerivedObject code:
DerivedObject ::DerivedObject ()
        : BaseObject()
{

this->GetBody() = this->GetWorld().CreateBody(this->GetBodyDef());

}
 

Now, as with Box2d, it requires lots of initiating the variables. C++ does not allow me to use them as I use above, it gives errors like 'no operator matches =' and 'const this' errors, but I don't know how else to do it? I don't want to make them all public in the BaseClass.. is there any syntax to get around this?

I have use Protected, and that works perfectly and is not accessible to the outside world, but is there any syntax to be able to use the above logic with private get/setters?

6
Hello all.

Been hunting down a disguising problem with a game I've written and I gave up and so wrote the game up from the ground again, but this time compiling release at every major stage too.

Well I've hit the error again - this time I've worked out what it is.. sf::text.

if I load a font its fine, but the second I apply it to a sf::text it was crashing on exit.

after an hour of debugging I found the problem... if I set the string inside the sf::text before the font it set, it causes the problem. EG.

        if(!mFont.loadFromFile("Data/Fonts/comic.ttf"))
                std::cout << "Fail to load font.. " << std::endl;
       
        mText.setString("Press Space.");
        mText.setFont(mFont);
        mText.setOrigin(mText.getGlobalBounds().width / 2.0f, mText.getGlobalBounds().height / 2.0f);
        mText.setPosition(this->GetEnginePtr()->GetGraphics()->GetWindow().getSize().x / 2.0f,
                                          this->GetEnginePtr()->GetGraphics()->GetWindow().getSize().y / 2.0f);
        mText.setColor(sf::Color::Blue);
 

that above will cause a release build crash on exit.

        if(!mFont.loadFromFile("Data/Fonts/comic.ttf"))
                std::cout << "Fail to load font.. " << std::endl;

        mText.setFont(mFont);
        mText.setString("Press Space.");
        mText.setOrigin(mText.getGlobalBounds().width / 2.0f, mText.getGlobalBounds().height / 2.0f);
        mText.setPosition(this->GetEnginePtr()->GetGraphics()->GetWindow().getSize().x / 2.0f,
                                          this->GetEnginePtr()->GetGraphics()->GetWindow().getSize().y / 2.0f);
        mText.setColor(sf::Color::Blue);
 

However - the above code will work fine.

I could not find mention in the documentation that the process had to be so strict?

I am using AMD 6990 GFX.

7
Graphics / Quads with Transitions
« on: December 12, 2012, 04:04:02 pm »
Hey All,

so been playing with what im going to do with the background for my space game and I think I am going to use a simple QUAD with each corner set to a different colour to get a nice transitional background.

Now is it possible to get a QUAD strip to do this too?

so I have 4 quads in a big square like

QUAD QUAD
QUAD QUAD

if I set each vert to a diff colour will they all blend together?

8
General / Compiling in Release etc.. and 'Static'/'Dynamic'. Please Help.
« on: December 01, 2012, 04:11:29 am »
So my games been going perfectly recently.

Last night I decided to do a release build just to see what the FPS is like! So I compiled and got a 'The operation completed successfully, unhandled exception' error... I checked some forums and some people pointed it at the console window..

So I changed my release build from 'CONSOLE' subsystem to 'WINDOWS' to remove the console, and set 'main' as the entry point (had to do that for some reason?) - this got rid of the error!! However.. when I close my game now in release with this new no console window approach.. the game closes down, but it still lives in my processes.. as if its not being killed properly... also if i run in VS2010 the game closes, but its not actually shut down.. I have to actually hit the 'STOP' button.. whats going on?!

Also how do I know if I am linking static or dynamic..

Your my only hope guys I was enjoying myself so much :(

edit: Linked sfml-main.lib into the lib links and still getting error on exit linked to crtexe.c, this only happens when sfml-main is linked.. otherwise program closes sucessfully but doesnt actual end the process...wtf

9
General / Gradient Class in SFML 2.0
« on: November 30, 2012, 06:04:24 pm »
Been following this tutorial http://www.sfml-dev.org/wiki/en/sources/gradientcolor

but its for a different version, i've been trying to convert it but to no avail.. does anyone have a 2.0 version of it that can kindly share :(

10
Graphics / sf::circleshape gradient..
« on: November 30, 2012, 02:23:18 pm »
is it possible to have a fall off from the center off a circleshape? Say I want to use it as an overlay on top of a laser projectile, to give it some glow?

11
General / Advice on Background Coding.
« on: November 19, 2012, 10:32:46 am »
Hey All,

Hope all are having a great Monday!!  ;D

I am currently working on my 1st real game and I have hit a problem.

My game is a space game where you must 'survive' for as long as possible by dodging asteroids and collecting scrap metal.

The game world is roughly 8000x8000 pixels and I want a beautiful space background.

I am stuck in terms of how to approch the background.. I know that max textures I should load are 512x512 as people with older graphics card have trouble loading large size images so obviously making lots of massive textures and displaying them in a tile format is out of the question...

if I DO make a tilesheet for the background, it looks slightly funny because the player moves quite fast.. so he goes across the 'background' really fast, making it look a little wierd...

I thought about making the background move when the player does but slightly slower, thus making the background slower, but the problem is im using box2d.. so I end up Apply Force to my background.. which just seems.... wrong..

Check out this video..

http://www.youtube.com/watch?feature=player_embedded&v=gf0crpqeAlU#at=26

thats an awesome game I have been following and has a vey good background simulation with the clouds.. Thats essentually what id like. Its obviously quite a large background and its made of clouds.. so I doubt he used a tilesheet... what did he do?

12
General / Please Help! Access Problems..
« on: November 11, 2012, 12:55:10 am »
Right Hey All!

I am using a nice state manager kindly made by Exploiter.

Something very wierd has been happening.

Whenever I 'New' an object, I cannot do anything with it.. if I try and access its member functions or even delete it, I get access violations...

Example >

Entity.hpp
#pragma once

#include <SFML/Graphics.hpp>
#include <Box2D/Box2D.h>

class Entity
{
public:
        Entity(void);
        ~Entity(void);

        sf::Sprite mSprite;
};
 

Entity.cpp

#include "Entity.h"


Entity::Entity(void)
{
}


Entity::~Entity(void)
{
}
 

Playstate.hpp
#ifndef PLAYSTATE_HPP
#define PLAYSTATE_HPP

#include <SFML/Graphics.hpp>
#include <Box2D/Box2D.h>

#include "GameState.hpp"
#include "PhysicsManager.h"
#include "Entity.h"
class GameEngine;

class PlayState : public GameState
{
public:
        PlayState( GameEngine& game, bool replace = true );
        ~PlayState();
        void pause();
        void resume();

        void update();
        void draw();

private:
        PhysicsManager mPhysicsManager;
        Entity *mEntity;
};

#endif // PLAYSTATE_HPP

 

Playstate.cpp
#include <memory>
#include <iostream>

#include "PlayState.hpp"
#include "MenuState.hpp"
#include "GameEngine.hpp"

#include "sGraphicsManager.h"

PlayState::PlayState( GameEngine& game, bool replace ) : GameState( game, replace)
{
        std::cout << "PlayState Init" << std::endl;
        mPhysicsManager.GetWorld()->SetGravity( b2Vec2(0, 9.4f));
        Entity* mEntity = new Entity();
        mEntity->mSprite.setPosition(100,100);

}      

PlayState::~PlayState()
{
        delete mEntity;
        //Dtor
}

void PlayState::pause()
{
        std::cout << "PlayState Pause" << std::endl;
}

void PlayState::resume()
{
        std::cout << "PlayState Resume" << std::endl;
}

void PlayState::update()
{
        sf::Event event;

        sGraphicsManager *Graphics = sGraphicsManager::Instance();

        while( Graphics->GetWindow().pollEvent( event ) )
        {
                switch( event.type )
                {
                        case sf::Event::Closed:
                                m_game.quit();
                                break;

                        case sf::Event::KeyPressed:
                                switch( event.key.code )
                                {
                                        case sf::Keyboard::Escape:
                                                m_game.quit();
                                                break;
                                        case sf::Keyboard::M:
                                                m_next = m_game.build<MenuState>( false );
                                                break;
                                }
                        break;
                }
        }
}

void PlayState::draw()
{
        sGraphicsManager *Graphics = sGraphicsManager::Instance();
        Graphics->GetWindow().clear( sf::Color(7, 10, 29));
        Graphics->GetWindow().display();
}
 

Now as you can see.. this should work fine? But when I setposition on mEntity - get get access violation? Even if I remove that line, when I close the app, it gets access violation on the mEntity destructor when I delete it..

What the hell??

13
General / Memory Delete?
« on: October 28, 2012, 01:33:39 am »
Hey all.

Been working on my game recently using a state manager that Exploiter developed.

I have made a physics manager class in which I am going to add all my Box2D stuff.

Header
#pragma once
#include <Box2D/Box2D.h>

class PhysicsManager
{
public:
        PhysicsManager(void);
        ~PhysicsManager(void);

private:
        b2World *mWorld;
};

 

cpp
#include "PhysicsManager.h"
#include <iostream>

PhysicsManager::PhysicsManager(void)
{
        b2Vec2 Gravity(0.f, 9.4f);
    mWorld = new b2World(Gravity, false);

}

PhysicsManager::~PhysicsManager(void)
{
        std::cout << "Deleting Physics Manager" << std::endl;
        delete mWorld;
}

 

as you can see, very simple - all it does is make a new mWorld at the moment and delete it in its destructor.

Now, say I allocate this in my 'Play' state for instance -

class PlayState : public GameState
{
public:
        PlayState( GameEngine& game, bool replace = true );

        void pause();
        void resume();

        void update();
        void draw();

private:
        PhysicsManager mPhysicsManager;
};

 

now, this will allocate the mPhysicsManager on the stack, so when PlayState is killed when the app ends, mPhysicsManager will go out off scope so its destructor should be called correct? Thus deleting mWorld in my Physics Manager class.

but this doesn't happen. I get a horrible memory leak coming from mWorld..

if I explicitly call the destructor in my playstate constructor (so it deletes it straight after its created) it cleans up fine.. just not when playstate goes out of scope.

14
General / CircleShape & Box2D.
« on: October 23, 2012, 11:00:44 pm »
Right Here is my circle code
sf::CircleShape circle;
circle.setOrigin(15, 15);
circle.setRadius(SCALE * 0.5f);
circle.setPosition(SCALE * BodyIterator->GetPosition().x, SCALE * BodyIterator->GetPosition().y);
circle.setFillColor(sf::Color::Green);
circle.setRotation(BodyIterator->GetAngle() * 180/b2_pi);
circle.setOutlineColor(sf::Color::Red);
circle.setOutlineThickness(1.0f);
 

and this is my box2d code for assigning a circle..

void CreateCircle(b2World& World, int MouseX, int MouseY)
{
        b2BodyDef BodyDef;
    BodyDef.type = b2_dynamicBody;
        BodyDef.position = b2Vec2(MouseX/SCALE, MouseY/SCALE);
        BodyDef.userData = "Circle"; //Naughty ;)
    b2Body* Body = World.CreateBody(&BodyDef);

        b2CircleShape circle;
        circle.m_radius = 0.5f/SCALE;

        b2FixtureDef FixtureDef;
        FixtureDef.density = 10.0f;
    FixtureDef.friction = 0.4f;
        FixtureDef.restitution = 0.2f;
        FixtureDef.shape = &circle;

        Body->CreateFixture(&FixtureDef);
}  
 

oh and my constant it.

static const float SCALE = 30.f;
 

I have boxes working perfectly, but my circles go into the ground by about 1/3 of the shape.. any ideas why it might be happening?

15
General / Resolutions... Yes that topic!
« on: October 23, 2012, 02:42:21 pm »
Hey All..

Been working on my SFML Physics game and I am wanting to make it fullscreen!

I understand that the best way to do this is to build the game to a set resolution (which I have done)

so say I have built the game on 1600x900, and someone joins the game with a resolutions of 1900x1080 do I just divide 1900 by 1600 & 1080 by 900 to find the scale factor, then just scale the sf::view by the scale factors of the Width & Height?

is there any other way that is prefered?

Pages: [1] 2