Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Maps, amimation, colission. some effects  (Read 3449 times)

0 Members and 1 Guest are viewing this topic.

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Maps, amimation, colission. some effects
« on: November 12, 2010, 01:02:45 pm »
Okay, sup there guys?
I finally made my main menu, new game menu, some pictures viewing, saving info to file and reading from file - basic stuff and now I need help from You guys, I got couple of questions:
1)I need tilemap map editor, I serched forum and found 2 intersting projects:
a) http://www.sfml-dev.org/forum/viewtopic.php?t=2340&start=45
b) http://www.sfml-dev.org/forum/viewtopic.php?t=1920
I wonder which one should I use? The game is top viewed.
Also if I use one of these editors how can I manage collisions with other objects like boundaries of map or other sprites? Also I dont' want to use .XML format.
I saw that SFMLMappy uses FMP format and it's also can handle isometric maps(I going to need that one in a future) - I will probably use this one editor but please give me some opinions.

2)I need to animate my character in game, You know move when I press A or W etc...
I saw that class to manage animations: http://www.sfml-dev.org/wiki/en/sources/anisprite
It's pretty cool, I think it will be enough right?
Also I want to use the same class to managa moving or trees or people in game, will it be possible?

3)How can i add some post effects like slowly moving string from top to bottom? I have to check if LastFrameTime is > 1s and if it is then change string position to lower?

Thanks in advance guys.

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Re: Maps, amimation, colission. some effects
« Reply #1 on: November 12, 2010, 01:06:55 pm »
Quote from: "darekg11"
3)How can i add some post effects like slowly moving string from top to bottom? I have to check if LastFrameTime is > 1s and if it is then change string position to lower?

Last frame time is often used with a value per second.
Code: [Select]
float speed = 200.f // Pixels per second
...
while(window.IsOpened())
{
...

sprite.Move(speed*window.GetFrameTime(), 0);
}

The given sprite will move to the right at 200 pixels per second.

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Maps, amimation, colission. some effects
« Reply #2 on: November 12, 2010, 02:50:19 pm »
Thanks man, working great : D

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Maps, amimation, colission. some effects
« Reply #3 on: November 13, 2010, 12:50:58 pm »
Okay, I just saw that both map editors have code to use with SFML in C++
And I use CSFML so I have to build my own map editor or translate C++ code to C which will be kinda hard?

Or just use normal editor and then ad colission by my self but how? Damn no C materials on wiki.

Animation code is also in C++, damn.

Damn I think translating everything will be better than reinventing the wheel?

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Maps, amimation, colission. some effects
« Reply #4 on: November 14, 2010, 03:08:00 pm »
Any idea, what about that map editor? Translating it will be pain in the ass.

I thought about using normal map editor but then write my own code to handle maps and then, write my own colission detection and finally storing all sprites in a C list and then checking if player collises with sprite by running check throught list?

panithadrum

  • Sr. Member
  • ****
  • Posts: 304
    • View Profile
    • Skyrpex@Github
    • Email
Maps, amimation, colission. some effects
« Reply #5 on: November 14, 2010, 07:34:45 pm »
Quote from: "darekg11"
I thought about using normal map editor but then write my own code to handle maps and then, write my own colission detection and finally storing all sprites in a C list and then checking if player collises with sprite by running check throught list?

I recommend using Box2D for collision.

darekg11

  • Full Member
  • ***
  • Posts: 127
    • View Profile
Maps, amimation, colission. some effects
« Reply #6 on: November 14, 2010, 08:36:30 pm »
Okay I found function:
Code: [Select]

bool b2TestOverlap
bool b2TestOverlap ( const b2Shape *   shapeA,
const b2Shape *   shapeB,
const b2Transform &   xfA,
const b2Transform &   xfB
)

ShapeA and shapeB would be sprites right? and the two last parametrs? This function return TRUE if shapes collises so then I just have to stop animating my char and set it to position before obstacle?

Also if I do it like this how can I test collisions with map boundaries or with for exmaple tree(as tile placed in map editor)? Then I have to check it manually?

I think I first will made some background and test animation and collisions.

What about animation, how can I translate C++ to C code?