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.


Messages - aNewHobby

Pages: [1] 2 3 ... 6
1
The Nom game won't play for some reason. The screen blacks out with a white area when it first comes up than completely whites out when it tries to render anything. :(  No clue why since this just started happening to me.

I'm not sure.. I have not had problems playing it on a number of computers.. I do not really no what to say or how to fix that :(

2
subed to your chan.. looking forward to this...  Good luck.. and I hope you keep motivated!!

3
Just simple example were you can sync animations to sounds... it would need more clean up but you get the idea... also you could key things off animations themselves...
Wouldn't it make more sense to change the sound when you change the animation? I mean some "event" triggers the state of the entity and you change the animation and the sound, rather than chaning the animation and then try to figure out if the animation has changed.

My example was supposed to illustrate a time were you have an animation that is not synced to a sound. So if you just play a sound it will end before the animation, and if you play the sound on loop it will go past the animation end.. the above code will play the smaller sound for as long as the animation lasts allowing you to tweak the animation at will for polish with out having to go and sync and redo all your sounds.

Again, this was just an example of the top of my head.

The point being that any feature added creates its own uses. People would find uses for it I am sure that makes more logical sense. It seams like a cool thing ot be able to check if there was ana option for it.. and once the option is there you could use it in creative ways as yet not foreseen.

4
Why do you need to get the ID for the currently playing animation?

There could be a number of reasons... like....

If (_anim.whatisplaying() == "RunAway")
{
    if (soundSIRIN.getStatus() == sf::Sound::Stopped)
               soundSIRN.play();

}

Just simple example were you can sync animations to sounds... it would need more clean up but you get the idea... also you could key things off animations themselves...


Indeed I have already thought about this. The reason why I haven't implemented a function as proposed by aNewHobby is: What do I return if no animation is playing?

Well I guess the best idea would be to return "NULL" I suppose or something like that. Strings can be a string and completely empty as well (can't they?). I'm new to programming so I may be mistaken on that.

5
General / Re: [Tutorial] - Building SFML2 + Thor2 in VS2010
« on: August 08, 2012, 01:05:31 am »
This is all true and your tutorial was fine for me to work it out... but I have this mate and he is a visual kind of person and he is my x-wife's new kid, meaning he has grown up on the internet and dose read as much as "skims" text. He found this tutorial easier to understand..

The tutorial is provided as is and you can either use it or not, or get a mod to del the thread.. As I said I made it for a mate of mine, so it is really for him.. I just thought some others might like to look at it as well.

6
General / [Tutorial] - Building SFML2 + Thor2 in VS2010
« on: August 07, 2012, 09:22:17 pm »
Hi a mate of mine wanted help getting sfml2 and thor to compile... so I made him this video... not sure if it is the "best" way but it works for me

http://www.youtube.com/playlist?list=PL4375CFE3936CE63A&feature=view_all

7
Well... it is assessment time at UNI and here is my new game!! Woot-a-loot-a-lot!!!

This is a Pac-Man Clone called NOM!.... hope you guys like it.. as before this is a windows binary but I will eventually make a Mac and Linux version as I have time.. I am in the middle of assessments at the moment so not much time unfortunately.

I'm pretty happy with this one there are some small problems still and it isn't very memory efficient and lacks some polish but as a learning project I think it came out pretty well in the few weeks we had to work on it.

Big thanks again to the various people who hang in IRC and are foolish enough to speak tor me!

As with all our assignments we are required to make a "Rolling Demo" so here it is.. though They always look kinda lame to me..



Nom! V1.1 (Windows)

Source @ BitBucket - (Warning a fucking mess)

8
Is there a way to tell witch animation is currently playing? I know there is a way to tell if an animation is playing, but is there a way to return the string key of the currently playing animation? Or something like that...

so you could do something like...

if (anim.whatsplaying() == "anim1")
{
// Do something that is unique to when this animation is playing.
}

9
General / Collisions Fail at higher speed....
« on: July 21, 2012, 04:28:34 am »
I'm using a bunch of collision tests. Everything works great.. but if I am going to fast then the collisions simply fail and nothing happens. I am trying to make a pacman clone so I would like pac-man to move pretty fast by the end of a long game.

  • Pac-Man is moving though a factor = velocity * frametime;
  • I am using SFML rectangles to do the tests... eg...sf::FloatRect.contains(pacman.getPostion); This tests a point in space to see if it is inside the rectangle. The point being the centre of pac-man.


So yeah.. I would love to hear any ideas on this!

Thanks in advance

Example of Collision as it is now...

 if ( _rectSwitch.getGlobalBounds().contains( PacMan.getPosition().x, PacMan.getPosition().y ) )

10
Graphics / Pixel Perfect Sprite Position checking?
« on: July 20, 2012, 08:51:53 am »
I am having a problem and I was hoping you guys would have a solution... as I am kinda stuck.

I have a sprite for the main character that is moving around the screen using a velocity and frame time to make a factor to adjust the sprite position. This is a float value. This means that the getPosition(); will return a float and it could be say 300.6348 300.2894 instead of 300,300 for screen cords.

I had planned to do a test on a single pixel to see if the main character was at that pixel. Though I can not get it to work as the sprite seams to just pass directly over it with out trigging the reaction.  I think this is because  the get position of get top/left for the "switch" is a whole number but the testing numbers for the sprite that is moving is in fractions.

I tried using ciel and floor to round the values.. but no real luck there either..

here is what I am trying to do...



Now the coloured squares would not be visible in the end but for now the "switches" can be seen. The idea was for the centre point of each square to test if the pacman centre point is in the same position, and if so do something. Pac-Man and the rects have the transform set to the centre.

I thought this would be trivial with some code something like this....

if (_switch.getPosition() == PacMan.getPosition()
{
//do somthing
}

but it just doesn't seam to work and I am not sure why or how to fix it... Any ideas?

// - - //
Some more info

Each Switch is 40,40px and PacMan is 40x40px. The main idea of this test was so that pacman can not change direction unless he is completely inside the switch. I can test is a point is in the switch or is a edge of pacmans bounding box hits the switch.. but I am unsure about how to do the center === center test if it is possible at all.

11
hmm... seams I just complete remove the default animation and then no problems... ..  .
Although your problem is probably not related to it, I have already planned to remove the special case of a "default animation"... I mean, the same functionality can achieved by an own animation, and thus stopAnimation() really stops the animator.

What dose relate to it then.. what was the problem?

12
hmm... seams I just complete remove the default animation and then no problems... ..  .

13
Hmm, tried those things.. unless you meant something else and still having problems... it could be my imaginations but it seams to be loading more often but I'm still getting that assertion error.

CPP
#include "goPac.h"

goPac::goPac()
        : _nextDirection(STOPPED)
        , _velocity(10.0f)
        , _maxVelocity(100.0f)
{
        InitiliseAnimation();
}

goPac::~goPac()
{
}

void goPac::Update(sf::RenderWindow& rw, sf::Event& _event, float TimeElapsed)
{
        rw.pollEvent(_event);
        rw.setKeyRepeatEnabled(false);


        if (_event.type == sf::Event::KeyPressed)
        {
                if (_event.key.code == sf::Keyboard::Up || _event.key.code == sf::Keyboard::W || _event.key.code == sf::Keyboard::Num8)
                {
                        debug("UP");
                        playAnimation();

                }

                if (_event.key.code == sf::Keyboard::Left || _event.key.code == sf::Keyboard::A || _event.key.code == sf::Keyboard::Num4)
                {
                        debug("LEFT");
                }

                if (_event.key.code == sf::Keyboard::Right || _event.key.code == sf::Keyboard::D || _event.key.code == sf::Keyboard::Num6)
                {
                        debug("RIGHT");
                }

                if (_event.key.code == sf::Keyboard::Down || _event.key.code == sf::Keyboard::S || _event.key.code == sf::Keyboard::Num2)
                {
                        debug("DOWN");
                }

        }

        animPac.update(animClock.restart());
        animPac.animate(_PACsprite);
}

void goPac::playAnimation()
{
        debug("playAnimation();");
        //animPac.update(animClock.restart());
        animPac.playAnimation("chomp", true);
}

void goPac::Draw(sf::RenderWindow& rw)
{
        rw.draw(_PACsprite);
}

void goPac::InitiliseAnimation()
{

        _PACsprite.setTexture(*TextureManager::getInstance().rSpriteSheet());

        defaultAnim.addFrame(1.f, sf::IntRect(40, 80, 40, 40));
        // Create animation: CHOMP
        chomp.addFrame(1.f, sf::IntRect(120, 80, 40, 40));
        chomp.addFrame(1.5f, sf::IntRect(160, 80, 40, 40));
        chomp.addFrame(1.f, sf::IntRect(120, 80, 40, 40));
        chomp.addFrame(2.f, sf::IntRect(40, 80, 40, 40));

        animPac.setDefaultAnimation(defaultAnim, sf::seconds(1.f));
        animPac.addAnimation("chomp", chomp, sf::seconds(0.4f));

}

.H
#ifndef GOPAC_H
#define GOPAC_H

#include "Debug.h"
#include "SFML/Graphics.hpp"
#include "Thor/Animation.hpp"
#include "GameObject.h"

class goPac : public GameObject
{
public:
        enum {STOPPED, LEFT, RIGHT, UP, DOWN};

        goPac();
   ~goPac();

   void Update(sf::RenderWindow&, sf::Event&, float);
   void Draw (sf::RenderWindow&);
private:
        float _velocity;
        float _maxVelocity;
        float _startofTimer;

        int _nextDirection;

        // Sprite Animation
        sf::Sprite _PACsprite;
        sf::Clock animClock;
        thor::FrameAnimation defaultAnim;
        thor::FrameAnimation chomp;
        thor::Animator<sf::Sprite, std::string> animPac;
        void InitiliseAnimation();
        void playAnimation();
};

#endif // - GOPAC_H

14
It's interesting that it runs so often. :-D
You're declaring the animations in the constructor, this means as soon as you leave the constructor the animation pointer will get invalid. Funny enough it seems like the data in memory is still kept there sometimes, thus the pointer can access it.
Make your animation ptr a member variable and you should be good. ;-)

Sorry I am very new to programming... Are you saying that I should make a member function something like InitilizeAnimation(); and place that in the constructor.. then put all the animation initialisation code for the animation in hat function and then call the function from the constructor?

This is the header as it is for the header...

#ifndef GOPAC_H
#define GOPAC_H

#include "Debug.h"
#include "SFML/Graphics.hpp"
#include "Thor/Animation.hpp"
#include "GameObject.h"

class goPac : public GameObject
{
public:
        enum {STOPPED, LEFT, RIGHT, UP, DOWN};

        goPac();
   ~goPac();

   void Update(sf::RenderWindow&, sf::Event&, float);
   void Draw (sf::RenderWindow&);
private:
        float _velocity;
        float _maxVelocity;
        float _startofTimer;

        int _nextDirection;

        // Sprite Animation
        sf::Sprite _PACsprite;
        sf::Clock animClock;
        thor::FrameAnimation defaultAnim;
        thor::FrameAnimation chomp;
        thor::Animator<sf::Sprite, std::string> animPac;
        void playAnimation();
};

#endif // - GOPAC_H


Quote
Make your animation ptr a member variable and you should be good. ;-)
This is the question I have... I am not declaring any pointers in the code I posted...

edit

oh you mean
thor::FrameAnimation defaultAnim;
?? I'll try this

edit2

I think you mean this? All I did was comment out the marked lines,

goPac::goPac()
        : _nextDirection(STOPPED)
        , _velocity(10.0f)
        , _maxVelocity(100.0f)
{
        _PACsprite.setTexture(*TextureManager::getInstance().rSpriteSheet());


        //thor::FrameAnimation defaultAnim;  // This is in the .h file WTF am I doing?
        defaultAnim.addFrame(1.f, sf::IntRect(40, 80, 40, 40));

        // Create animation: CHOMP
        //thor::FrameAnimation chomp; // This is in the .h file WTF am I doing?
        chomp.addFrame(1.f, sf::IntRect(120, 80, 40, 40));
        chomp.addFrame(1.5f, sf::IntRect(160, 80, 40, 40));
        chomp.addFrame(1.f, sf::IntRect(120, 80, 40, 40));
        chomp.addFrame(2.f, sf::IntRect(40, 80, 40, 40));

        animPac.setDefaultAnimation(defaultAnim, sf::seconds(1.f));
        animPac.addAnimation("chomp", chomp, sf::seconds(0.4f));
}

15
It seams to stop erroring (though the animation will not play) if I remove

animPac.update(animClock.restart());

I have tried setting addFrame so everything is 1.f and add Animation is 1.f
any ideas?

I think it has somthing to do with "pollEvent"?

Pages: [1] 2 3 ... 6