Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!

1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Member Since 30 Jan 2010
Offline Last Active Jul 13 2015 12:01 PM

Topics I've Started

Implementing a quest/achievement system

06 April 2015 - 03:45 AM

What's the best way to implement a quest system that's modular and how are the variables checked for say conversations being had, are they stored in the entities themselves as boolean triggers or in a bigger global list/class.


I've never done one before an it's a bit daunting trying to figure out what course of action is best.


I thought that if I store the variables in the NPC's and then have the quest class check for whether condition1 & itemB have been done then that would be the best way to bolt on extra levels and characters.


Am I on the right track?

Anyone got any ideas where 4k a sec is coming from?

31 March 2015 - 12:12 PM

I've got a basic program running SDL2 that loads a surface and a class wrapper that handles object creation/texture loading. Before I even start to generate objects SDL is streaming extra memory at around 4k a second.


Is this a known issue or could I have created some weird loop. I don't call any new objects in my code apart from the class to hold the objects that will be created:


pAsset_explosions= new GeneralObject("disposable_explosion.png", screenCoords);

Forward declarations of classes :S

01 February 2015 - 10:49 AM

Looking for a little help with class declarations.


If I have the following

#include "myApp.h"
int main(int argc, char* argv[])
       return myApp::GetInstance()->OnExecute(argc, argv);
is the forward declaration of Player available in main if placed here?

class Player; //forward declaration
class myApp


SDL2 and openGL3-4

24 January 2015 - 11:13 AM

Hey everyone, Can I ask a quick question about SDL2
What are it's restrictions when implementing openGL 3-4 with it? Am I wasting my time learning it or do they work hand in hand quite nicely?

SDL problem with passing pointers

27 November 2014 - 05:41 AM

I'm totally stuck with trying to implement a texture wrapper class, when I'm passing a pointer to a method through a pointer it dies and I have no idea why. can anyone help.


I'm following lazy foo's tutorials (http://lazyfoo.net/tutorials/SDL/10_color_keying/index.php) and they load properly when i'm using his tutorial format, but when trying to take the texture wrapper into a class structure it loads but dies when it displays a screen.


my code is as follows



#ifndef CTEXTURE_H_
#define CTEXTURE_H_

#include "capp.h"

using namespace std;

class CTexture
    SDL_Texture *_Texture;
    int _Width;
    int _Height;


    bool fLoadFromFile( SDL_Renderer *pRenderer, string path );
    void fRender( SDL_Renderer *pRenderer, int x, int y);

    int fGetHeight() { return _Width; }
    int fGetWidth() { return _Height; }

    void fFreeResources();

#endif // CTEXTURE_H


#include "CTexture.h"

    //auto initialize


bool CTexture::fLoadFromFile( SDL_Renderer *pRenderer, string path )
    fFreeResources(); //delete pre-existing texture

    SDL_Texture* newTexture = NULL;
    SDL_Surface* loadedSurface = IMG_Load( path.c_str() );

    if(loadedSurface == NULL)
        printf("unable to load image", path.c_str(), IMG_GetError() );
    } else {
        SDL_SetColorKey( loadedSurface, SDL_TRUE, SDL_MapRGB( loadedSurface->format, 0, 0xFF, 0xFF ) );
        newTexture = SDL_CreateTextureFromSurface( pRenderer, loadedSurface );
        if(newTexture == NULL)
            printf("unable to create new texture ", path.c_str(), SDL_GetError() );
        } else {
            _Width = loadedSurface->w;
            _Height = loadedSurface->h;
    _Texture = newTexture;
    return _Texture != NULL;

void CTexture::fFreeResources()
    if(_Texture != NULL)
        _Texture = NULL;
        _Width = 0;
        _Height = 0;

void CTexture::fRender( SDL_Renderer *pRenderer, int x, int y)
    SDL_Rect renderQuad = { x, y, _Width, _Height };
    SDL_RenderCopy( pRenderer, _Texture, NULL, &renderQuad );

The variables are initialized in main:


CTexture *charTexture;
CTexture *bgTexture;

And then loaded at the right time through a loadMedia function call:

    if(!charTexture->fLoadFromFile( Renderer, "images/foo.png"))
        printf( "Failed to load 'images/foo.png' texture image!\n" );
        return false;
    } else {
        printf("Success: 'images/foo.png' loaded" );

    if(!bgTexture->fLoadFromFile( Renderer, "images/background.png"))
        printf( "Failed to load 'images/background.png' texture image!\n" );
        return false;
    } else {
        printf("Success: 'images/background.png' loaded" );

    charTexture->fRender( Renderer, 0, 0 );
    bgTexture->fRender( Renderer, 240, 190 );

But It will not compile properly, any ideas what the hell I am doing wrong?