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

Pages: [1]
1
General / SFML Game Development book problem ( chapter 3 )
« on: August 22, 2014, 03:54:44 pm »
Hi everybody,
I'm currently working on this great book, and i'm having trouble at chapter 3.
Here is the error message :
C:\...\SFML_game_development\src\Aircraft.cpp|16|undefined reference to `ResourceHolder<sf::Texture, Textures::ID>::get(Textures::ID) const'|

I could give you the code but i don't think that's more useful, I also tried with the official code and it still doesn't work...I heard this could be because of my compiler and it's a template issue but i don't know how to fix that at the moment.

Here is my Aircraft.cpp where the error is detected :
Quote
#include "Aircraft.h"

#include <SFML/Graphics/RenderTarget.hpp>
#include <SFML/Graphics/RenderStates.hpp>


Textures::ID toTextureID(Aircraft::Type type){
    switch(type){
        case Aircraft::Eagle:
            return Textures::Eagle;
        case Aircraft::Raptor:
            return Textures::Raptor;
    }
}

Aircraft::Aircraft(Type type, const TextureHolder& textures) : mType(type), mSprite(textures.get(toTextureID(type)))
{
    sf::FloatRect bounds = mSprite.getLocalBounds();
    mSprite.setOrigin(bounds.width/2.f, bounds.height/2.f);
}


My header for Aircraft class :

Quote
#include <Entity.h>
#include <SFML/Graphics/Sprite.hpp>
#include "ResourceHolder.h"

namespace Textures
{
   enum ID
   {
      Eagle,
      Raptor,
      Desert,
   };
}

template <typename Resource, typename Identifier>
class ResourceHolder;

typedef ResourceHolder<sf::Texture, Textures::ID> TextureHolder;

class Aircraft : public Entity
{
    public:
        enum Type
        {
            Eagle,
            Raptor,
        };
    public:
        Aircraft(Type type, const TextureHolder& textures);
        virtual void drawCurrent(sf::RenderTarget& target, sf::RenderStates states) const;
    protected:
    private:
        Type mType;
        sf::Sprite mSprite;
};

The ResourceHolder.h and ResourceHolder.cpp are the exact same as in https://github.com/SFML/SFML-Game-Development-Book/tree/master/03_World

(but as i said, i also tried to c/p the original code and still doesn't work)

Thanks a lot and sorry for annoying you guys

2
General / Gravity, jump, physics : any advices?
« on: February 01, 2014, 04:30:55 pm »
Hi everybody,
I am interested into the creation of a 2D volley ball game, which as to be as realistic as possible.
In first, i want to create a prototype which allow to :
- display 2 circleshapes ( 1 ball and 1 player )
- player shape is located on the bottom on the screen and we can just make him moving left or right, and jumping by a realistic way( i mean with gravity )
- ball shape spawn in top of screen and fall with gravity; it has also to rebound with player, walls and ground

What I already have:
- player shape which move left or right, and a basic jump implemented:
( i want a real jump so i check on the internet to find equations, i found something like
y=y0 -(1/2*g*t*t) + v*t )

- every collisions test
- rebound against walls

I also have a formula to calculate rebound between two circles but i haven't implemented it at the moment;

So my questions are :
- is it best to use " myObject.move(mySpeed) " or " myObject.setPosition(x,y) " ?
- by trying to implement a realistic jump, i did this :

if(inAir)
               speed.y+=k*grav*clock.getElapsedTime().asSeconds();

where k is a fixed constant,
grav is equal to 9.81

But I have some difficulties with modiying speed.y when the player is on the ground and want to jump...
For example, when do i have to do a clock.restart() ?

Thank you for advance,
Have a good day ! :)

Pages: [1]