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

Pages: 1 ... 3 4 [5]
61
Graphics / Wwedish vowels in sf::Event::TextEntered, problem
« on: October 07, 2011, 01:02:30 pm »
Environment
VC++ 2010 Express
Windows 7 enterprise 64
SFML 1.6

I have a simple hangman game going on, but I've run into a nasty problem. In Sweden, we have three vowels not used in the english language, but could be called Å/AO, Ä/AE and Ö/OE.
I have changed VC++ to use swedish language by adding

        locale swedish("swedish");
        locale::global(swedish);

in the main code.

The wovels are placed on the keyboard as key 1 (Ö) and 2 (Ä) right of "L" and the (Å) key above those two.

If I write this code, I'll get the swedish wovels, but all other keys appear too.

Code: [Select]
if (Event.Type == sf::Event::KeyPressed)
 {
 if ( Event.Type == sf::Event::TextEntered )
        cout << "Char= " << (char)Event.Text.Unicode <<endl;  
 }




If I use this code instead to sort the other keys away, I won't get the swedish vowels

Code: [Select]
if (Event.Type == sf::Event::KeyPressed)
 {
     if ( Event.Text.Unicode < 0x80 ) // it's printable
           {

 if ( Event.Type == sf::Event::TextEntered )
                         
        cout << "Char= " << (char)Event.Text.Unicode <<endl;    
           }
}


I assume the "Unicode < 0x80" is the culprit to the behaviour. I just can't figure out what to write instead. Is there a solution to this problem?

62
Graphics / Animation only animates on stand still (solved)
« on: September 23, 2011, 02:10:07 pm »
Thanks pyro it works.

I'm a bit confused though. Setting a member of a set (state enum) to false make it work? I really can't see why it works, but it does. In my mind, it should be enough to say " hey, you have pressed the left button then I'll play the animation for moving left and move in that direction".

Instead it says "hey, I'm false. Because of that I'll move to the left when you press left with my move left animation. Then I become true but all my friends become false so they will move and animate in the future but not me.

I also added a <animsprite>.Stop(); in the end too to make it stop using an animation when no key is pressed. I also set all set members to false when no key is pressed so it is possible to hit the same key two times in a row and still have the animation running the second time.

 I'm satisfied that I've made it work with your help. Thanks!


Thanks

EDIT
I learn a lot C++ along the way, and I admit it's quite obvious how it works if you just think about it. A better way to think about it is that each state is a lightbulb and it gets current when an arrow key is pressed, but you can't light up two bulbs at the same time.

63
Graphics / Animation only animates on stand still (solved)
« on: September 23, 2011, 01:22:20 pm »
But Thor 1.1 is only for SFML 2.0? Or am I wrong there too? Furthermore, the only pre-compiled dll:s I can find there for vc++ 2010 are for 32 bit system.

At the end of the day, it would be nice to have a simple animation class in SFML that actually worked and let the more advanced user delve into Thor and other systems. Otherwise, I'm quite sure more people are like me, the act of creating an animation class of my own is a daunting task that I really can't manage but there are no alternatives so I am stuck with making pong games and such that don't demand animations.

A lot of people in here seems quite skilled in c++ programing, how hard can it be for a good and kind programmer to make an animation class that use a sprite sheet of say 16 equally big pictures to show an explosion or a helicopter with moving rotor and give that for free to us newbies in the game programming world? Then, we would at least have something that moves around on the screen, compared to nothing as it is now.

64
Graphics / Animation only animates on stand still (solved)
« on: September 23, 2011, 12:43:29 pm »
I took a quick look in Thor and it looks interesting but there seems to be no class for sprites or animation of sprites, or am I wrong?
http://www.bromeon.ch/thor/v1.0/doc/annotated.html

Furthermore, there's a lot of question in the SFML forum about animation, many new coders get stuck in it since there is no given class that show animations even though animated game sprites have been around for decades. A lot of questions when frustrated new game creators are asking for help with animations get the short answer "take a look at the animation class in the sfml wiki". So that was what I did also. But maybe I was looking for the wrong animation class?

65
Graphics / Animation only animates on stand still (solved)
« on: September 23, 2011, 11:34:54 am »
I have made a simple project with the class anisprite, more or less direct copied from the wiki:
http://www.sfml-dev.org/wiki/en/sources/anisprite

I need just a simple way to animate sprites, and that class seemed sufficient for my needs. The problem is that when everything is in place, the figure (boy with green hair) is animated when he is standing still. As soon as I try to move him by code or by key down, he moves but the animation stops. I suppose I can use the class still for explosions and such that aren't moving, but the idea to have animated sprites that move seems more tempting. If anyone has a solution to the problem, I would be grateful.

Environment:
SFML 1.6
Windows 7 Enterprise 64
Microsoft VC++ 2010 express

The code in main.cpp this far, the comment are in swedish since I intended to show the code for teenagers that want to create simple games, but I assume it can be read quite easy anyway by the pros in here :) The AniSprite header and cpp-file are more or less unchanged.
-------------------

Code: [Select]

#include <iostream>
#include <SFML\System.hpp>
#include <SFML\Graphics.hpp>
#include <SFML\Window.hpp>
#include <AniSprite.h> //länk saknas i originaldokumentet


  int main()
    {  //Början av programkörningen

sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Test - animation");

float pojkfart = 0.05f; //hastigheten när pojken flyttar sig
                               
 // Ladda in in sprite-karta, en uppsättning bilder som skall visas i sekvens
  sf::Image pojkkarta;
   if (!pojkkarta.LoadFromFile("character.png"))
        return EXIT_FAILURE;
  AniSprite Spritepojk(pojkkarta,47,64); //storleken på varje enskild bild
   Spritepojk.SetLoopSpeed(12); //12 fps
    Spritepojk.Play(0,1); //Visa första och andra bilden enbart, får inte vara 0,0
      Spritepojk.SetPosition(200.f, 200.f); //Placera ut bilden

while(App.IsOpened())
{
        sf::Event Event;

       
while (App.GetEvent(Event)) // Ta hand om händelser
   { //while 2

      if (Event.Type == sf::Event::Closed) //kryssat på [x] symbolen? stäng programmet
         App.Close();

      if (Event.Type == sf::Event::KeyPressed) // En tangent har tryckts ner

             { //if 1

               if (Event.Key.Code == sf::Key::Escape) // ESC tangenten = stäng programmet
                    App.Close();

              } //slut if 1

  } //slut, while 2


if (App.GetInput().IsKeyDown(sf::Key::Left))
         {
          Spritepojk.Move(-pojkfart, 0);
     Spritepojk.Play(12,15);
   } //Visa nedersta raden, pojken går åt vänster

else if (App.GetInput().IsKeyDown(sf::Key::Right))
         {
          Spritepojk.Move( pojkfart, 0);
      Spritepojk.Play(4,7); //Visa andra raden, pojken går åt höger
    }
else if (App.GetInput().IsKeyDown(sf::Key::Up))
        {
        Spritepojk.Move(0, -pojkfart);
   Spritepojk.Play(0,3); //Visa första raden, man ser ryggen på pojken
   }
else if (App.GetInput().IsKeyDown(sf::Key::Down))
        {
        Spritepojk.Move(0, pojkfart);
   Spritepojk.Play(8,11); //Visa tredje raden, man ser ansiktet på pojken
   }

// Rensa skärmen
    App.Clear();        
//updatera animation
    Spritepojk.Update();
    App.Draw(Spritepojk);
    App.Display();
}

return 0;
} //slut på programkörningen

Pages: 1 ... 3 4 [5]