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

Author Topic: Scrolling Enemy with map  (Read 2962 times)

0 Members and 1 Guest are viewing this topic.

WitchD0ctor

  • Full Member
  • ***
  • Posts: 100
    • View Profile
    • http://www.teleforce-blogspot.com
Scrolling Enemy with map
« on: August 22, 2010, 02:30:15 pm »
I'm honestly surprised that i haven't run into this problem sooner,

I need help figuring out how to draw enemies in their correct positions, when the map starts scrolling. Previously when I worked with the allegro Library, i would do something like this
Code: [Select]

g_blitTile(Images.Enemy, enemy_x - Map.x_scroll, enemy_y-Map.y_scroll, 32, 32, frame);


which means i would simply call a draw function and subtract the Maps scroll offset, but in SFML, i can't exactly do that. because there are no parameters for draw, it just takes its current position. Seems like a simple problem to solve but I can't seem to wrap my head around it, Might be because its 5 in the morning :o...need sleep.

Any suggestions?


PS. I would use views to simply the whole matter but Mappy doesn't play nice with them, (auto culls out of screen tiles)
John Carmack can Divide by zer0.

CytraL

  • Jr. Member
  • **
  • Posts: 68
    • View Profile
    • GitHub
Scrolling Enemy with map
« Reply #1 on: August 22, 2010, 05:08:51 pm »
dev@redneboa.es | WordPress | GitHub | YouTube

WitchD0ctor

  • Full Member
  • ***
  • Posts: 100
    • View Profile
    • http://www.teleforce-blogspot.com
Scrolling Enemy with map
« Reply #2 on: August 23, 2010, 12:51:07 am »
Yes, I mentioned those in my post script :)
John Carmack can Divide by zer0.

Dig

  • Newbie
  • *
  • Posts: 31
    • View Profile
Scrolling Enemy with map
« Reply #3 on: August 24, 2010, 05:42:15 am »
Unless I'm confused about what you are using Mappy for it all should play nicely with Views I'm sure.

We use Mappy just as a tool to make the levels, saving them out in a text format that is then read by the engine.  It should be your game that manages culling on and off screen tiles.  I've noticed there are 'playback' libraries for Mappy, maybe thats what you are used to for allegro?

I'd suggest loading the map data into your SFML game and managing loading and displaying sprites from there are you would get to use views.  Views are the best solution for what you are wanting to do.

If you have to change the position of everything everytime the screen scrolls you'll have lots of problems later on managing the locations of things.

WitchD0ctor

  • Full Member
  • ***
  • Posts: 100
    • View Profile
    • http://www.teleforce-blogspot.com
Scrolling Enemy with map
« Reply #4 on: August 24, 2010, 02:39:14 pm »
I'm using the sfml mappy playback library that's in the project forums, when drawing a map, it automaticly culls tiles that are not in the view. So when I scroll with a view, the rest of the map is cut off. I'm currently looking for a way to disable this so I can use views to simplify my life.


EDIT:

nevermind, i got it working with views (Wahoo!)
Thank you
John Carmack can Divide by zer0.

 

anything