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!


Sunsharior

Member Since 14 Dec 2013
Offline Last Active Today, 01:04 PM

Posts I've Made

In Topic: Implementing a quest/achievement system

06 April 2015 - 08:34 AM

The observer design pattern is a good idea for decoupled achievements. Here is a link to an article describing it: http://gameprogrammingpatterns.com/observer.html


In Topic: please help with SDL

01 April 2015 - 09:27 AM

You are missing the methods "clean" and "update" from the file SDLGameObject.cpp


In Topic: How to implement skeletal animation in 2d game?

30 March 2015 - 06:56 AM

If you prefer to do thing yourself, i have something for you that you might like. I'll just explain how i did something similar in my game.

With more than 250 weapons sprites, it was out of the question to actually draw each sprite. So what i did was creating my own tool to manage the sprite animations and hitboxes. After that, i added "anchors" to each frame of animation to set where the weapon goes. Good thing is, i can even set anchor point for the weapon when it's sheathed. You need two anchors, one to set where it goes and another to set the angle.

So basically, i'm not using a complexe bone system but only anchor points to tell my game "that weapon goes there" at that frame.

Obviously, this method was very time consuming, but it give you an alternative to Spine.


In Topic: Rotating a sprite in SDL2?

17 March 2015 - 05:17 PM

With this simple snipet, you will be able to draw a sprite.

// for this to work, i will assume you already have a SDL_Renderer and a SDL_Window.
SDL_Texture *texture = IMG_LoadTexture(renderer, "image.png");

// if the texture was loaded.
if(texture)
{
    SDL_Rect rect = {0, 0, 32, 32}; // the rect is where you wants the texture to be drawn (screen coordinate).
    SDL_Rect crop = {0, 0, 16, 16}; // the crop is what part of the image we want to display.

    float angle = 180.0f; // set the angle.
    SDL_Point center = {8, 8}; // the center where the texture will be rotated.
    SDL_RendererFlip flip = SDL_FLIP_NONE; // the flip of the texture.

    // now, try to draw something
    int result = SDL_RenderCopyEx(renderer, texture, &crop , &rect, angle, &center, flip);
    
    if(result!= 0)
        std::cout << SDL_GetError() << std::endl;
}
else
    std::cout << Error << "Couldn't render texture." <<  std::endl;

Using this example, you will draw an image rotated 180 degree.

It will be drawn at 0,0 with a width of 32 and a height of 32. The crop is 16x16 and the rotation is 180 that is centered at 8,8.

 

I hope this help.

If you have errors, feel free to post it.


In Topic: Text Based RPG help

11 December 2014 - 02:12 PM

Like Josh Petrie said, you declared functions in a header file that were never defined elsewhere. I have enclosed 3 of your project's file code with the error fixed.

 

You will noticed a few things:

 

1. I have created the Prologue.cpp file and moved the content from Char info.cpp to it.

2. The prologue is now used as a class instead of static. See the modification i did to Main.cpp to notice it's scope remain inaffected.

3. The fonctions and member variables of the class Prologue are no longer static. Prologue.cpp now have the proper definition of thoses fonctions, and a constructor aswell.

4. The file Char info.cpp has been deleted.


PARTNERS