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

Pages: [1] 2 3
1
General / Connecting scrolling map and collisions
« on: July 26, 2010, 10:11:38 am »
Why have you copied reply that was written before by someone else? I did it what was said.

2
General / Connecting scrolling map and collisions
« on: July 10, 2010, 01:27:28 pm »
Now I won't be at home till next Sunday, so if somebody will find some time for looking at my code and analyzing it, I will be grateful.

Here I post screenshots that shows how this two objects put on each other:

http://img683.imageshack.us/img683/1760/righto.jpg
http://img192.imageshack.us/img192/2450/leftof.jpg
http://img188.imageshack.us/img188/306/downu.jpg
http://img337.imageshack.us/img337/4456/29414335.jpg

I will be glad for any advices.

Kind Regards

3
General / Connecting scrolling map and collisions
« on: June 28, 2010, 04:00:09 pm »
It's not problem with scalling, becouse if I delete it the problem persist.

I added setting center to loop and it also changed nothing. It seems like the picture is "smaller" few pixels each sides.

I pasted all my code in here:
http://wklej.to/ADnz
There is nearly 300 lines, but most of them are not really connected with that issue and I hope You will catch what is important or not.

I think You don't need animations detalis, but if so there are:
http://www.sfml-dev.org/wiki/en/sources/frame_anim_animated

I have just changed inheritance of class Animated(now it inherits after(?) sf::Sprite - before: sf::Drawable.

I know that it might be hard for You to find what's wrong in stranger code, so I can send You all my project in Visual C++, so You can test what's wrong. If You find time for me of course.


Kind Regards
Fuv

4
General / Connecting scrolling map and collisions
« on: June 28, 2010, 02:37:33 pm »
Thanks for advices. I was wondering about it much time :)


Backing to my moved collision. I changed something it code and not it looks better... but not perfectly. Collision area is a bit smaller than image. Moreover I also use animation from here:
http://www.sfml-dev.org/wiki/en/sources/frame_anim_animated

And that complicates it more. So here I give part of my code, becouse in my opition all is not necessary:

Code: [Select]
Char.SetPosition(512, 384);

    Obstacle.SetCenter(Obstacle.GetSize()*.5f);
Char.SetCenter(20, 32); //fits to image size

    Background.Resize(2000,2000);
    Background.Move(-500,-500);
    Obstacle.Move(100,100);
    Obstacle.Scale(2.f, 2.f);

    sf::Vector2f Center(500,500);
    sf::Vector2f HalfSize(App.GetWidth()*.5f,App.GetHeight()*.5f);
    sf::View View(Center,HalfSize);

    sf::Event evt;

    while(App.IsOpened())
    {
      while(App.GetEvent(evt))
      {
         if(evt.Type==sf::Event::Closed){App.Close();}
         if(evt.Type==sf::Event::KeyPressed&&evt.Key.Code==sf::Key::Escape){App.Close();}
if(evt.Type==sf::Event::KeyPressed&&evt.Key.Code==sf::Key::F1)
{
sf::Image Screen;
Screen = App.Capture();
Screen.SaveToFile("sc2.jpg");
}
      }
   
 UpdateBoy(Char, App.GetInput(), Dir, App.GetFrameTime(), go);
      View.SetCenter(Char.GetPosition());

      App.Clear();
      App.SetView(View);
      App.Draw(Background);
      App.Draw(Obstacle);
  App.Draw(Char);

      App.Display();
   }


And image how it looks like:
http://img96.imageshack.us/img96/1225/sc2ki.jpg

If I made as You said(move SetCenter functions after scalling images it looks as that in my previous post.

In my opinion something still is wrong with setting center, but I couldn't find what).

Is that code which I pasted here all right?

Kind Regards
Fuv

5
General / Connecting scrolling map and collisions
« on: June 26, 2010, 02:31:08 pm »
Thanks really a lot. I am so grateful. :)

I have one more question. If I want to make collision with more object what is the fastest way to do that? Have I to write all conditions each time?

I tried that way:
Code: [Select]
if(App.GetInput().IsKeyDown(sf::Key::Down))
 {
 if((Collision::BoundingBoxTest(Player,Obstacle)==false) && (Collision::BoundingBoxTest(Player, Obst2) == false))
 {
 Player.Move(0,100*timer);
 lastKey="D";
 CFPS.Move(0, 100*timer);
 }
 else if(lastKey=="D")
 {
 Player.Move(0,-100*timer);
 CFPS.Move(0,-100*timer);
 }
 else
 {
 Player.Move(0,100*timer);
 CFPS.Move(0,100*timer);
 }
 }


Obst2 is my 2nd object that I want to collide with.

But it works not well. The collision place is moved left and up. I have image if you don't understand what I am talkin about:
http://img96.imageshack.us/img96/796/83280459.jpg

How to solve that?

6
General / Connecting scrolling map and collisions
« on: June 24, 2010, 02:08:32 pm »
Is anybody able to help me?

Kind Regards
Fuv

7
General / Connecting scrolling map and collisions
« on: June 20, 2010, 04:13:03 pm »
Thanks.

I made camera moving with player. I added:

Code: [Select]
Player.SetCenter(Player.GetSize() / 2.f);
Camera.SetCenter(Player.GetPosition());


And then moved my view.


It is almost working. I just need to know why I can't trigger:
Code: [Select]
App.SetView(App.GetDefaultView());

If I use this function collision is not handle and player is moving faster than camera does. On the other hand if I don't use it player is not dimensional (it is smaller than it should be) and collision location is moved a bit left and up.

All my code is here:
http://wklej.to/k602

And class I used for detect collisions here:
http://www.sfml-dev.org/wiki/en/sources/simple_collision_detection

Kind Regards
Fuv

8
General / Connecting scrolling map and collisions
« on: June 19, 2010, 02:29:39 pm »
I found out where the problem is, but I don't know how to solve it.

I ve done as u had said and I wrote possition both player and collisioner. And I noticed that Collisioner is always on the possition (100,100) (I want it to be there), but my player also has always the same possition (512, 384).

I know that player isnt moving - just view, but I don't know how shouls I do to detect collision is that way. Could you give me any advice?

Kind Regards

9
General / Connecting scrolling map and collisions
« on: June 17, 2010, 02:54:12 pm »
Hello all :)

I made successful my scrolling map and collisions, but when I tried to connect it - sth was wrong.

http://wklej.to/v46L

I am wondering whats wrong, becouse without map scrolling, collisions were workin'.

Kind Regards
Fuv

10
General / Scrolling map
« on: June 14, 2010, 03:46:50 pm »
I want to thank you so much. Everything is going well.

Thanks for your attention.

Kind Regards
Fuv

11
General / Scrolling map
« on: June 13, 2010, 05:16:34 pm »
Hello all again,
Unfortunately I have next trouble - now with moving map. I wrote code on two ways and both is not working :(

I need your help then.

My first effort was using this post:
http://www.sfml-dev.org/forum/viewtopic.php?p=5097&sid=f9a1cd64f563b420ac67e1e42a2e2f99

And what I made is:
http://wklej.to/TnAa

And then I tried to do sth myself, but ofc it also doesn't work:
http://wklej.to/f8Nz
Here I even don't see a map :o

Is here somebody willing to help me?

Kind Regards
Fuv

12
General / Collision - example(?)
« on: June 11, 2010, 09:21:37 pm »
But I dont have even any idea. I tried like that, but not working.

Code: [Select]
    if(!Collision::BoundingBoxTest(Ludzik, Przesz))
{
if(App.GetInput().IsKeyDown(Key::Up))
Ludzik.Move(0, -100 * time);
   if(App.GetInput().IsKeyDown(Key::Down))
    Ludzik.Move(0, 100 * time);
   if(App.GetInput().IsKeyDown(Key::Left))
    Ludzik.Move(-100 * time, 0);
if(App.GetInput().IsKeyDown(Key::Right))
    Ludzik.Move(100 * time, 0);
}


I dont know how it should be solved.

13
General / Collision - example(?)
« on: June 11, 2010, 06:56:07 pm »
Heh, yeah indeed.

I just want that one object can not go into the 2nd one. I want to make that one cannot cover 2nd in one place. No explosions there :)

Kind Regards
Fuv

14
General / Collision - example(?)
« on: June 11, 2010, 05:35:49 pm »
Thanks. It works.

And could you tell me what is yours idea to write condition? I mean I dont know what to write in here:

Code: [Select]
if(Collision::BoundingBoxTest(Ludzik, Przesz))
      {
              //here
      }


To make real collision. I found no examples in wiki.

Kind Regards
Fuv

15
General / Collision - example(?)
« on: June 10, 2010, 04:44:50 pm »
Quote
Your code seeme to test just only one time the collision. What are the size of the two images ? Because maybe "Przesz" is not 100px width nor 50px height...


Does it have to be exactly 100x50? Why? I have the same images and one was scaled to 0,5height and 0,5 width. But also after making it without scaling it is not working.

Quote
Your code seeme to test just only one time the collision.


I don t know how to make it other way.

Quote
Can you show us the BoundingBoxTest function too please ?


As I said at the beginning(but becouse of that off-topic it is not clear) I m using wiki example from there:
http://www.sfml-dev.org/wiki/en/sources/simple_collision_detection

Kind Regards
Fuv

Pages: [1] 2 3
anything