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

Author Topic: Looping/scrolling sf::View?  (Read 3327 times)

0 Members and 1 Guest are viewing this topic.

Haikarainen

  • Guest
Looping/scrolling sf::View?
« on: May 04, 2011, 09:57:50 pm »
Hey, im working on an application, that will practice ppl's FPS-Aiming skills.

I need a fixedsize "surface", that will seamlessly loop/scroll. the centerposition of everything will be the mouseposition.

Basically i want to simulate a firstperson-shooter view in 2d, on a flat surface. I hope you get my point here.

My question is; Does anyone have a clue or hint how this could be done? im not asking you to write it for me, just asking for tips because i really dont know where to start on the whole seamless loop/scroll thing.

Wizzard

  • Full Member
  • ***
  • Posts: 213
    • View Profile
Looping/scrolling sf::View?
« Reply #1 on: May 05, 2011, 12:57:46 am »
You should attempt to master views and the solution will hopefully become apparent.
SFML 1.6 "Using Views" tutorial

Getting real-time mouse input will be necessary to set the center position of the view
SFML 1.6 "Handling Events" tutorial (scroll down to the "Getting real-time inputs" section)

Haikarainen

  • Guest
Looping/scrolling sf::View?
« Reply #2 on: May 05, 2011, 12:33:55 pm »
Quote from: "Wizzard"
You should attempt to master views and the solution will hopefully become apparent.
SFML 1.6 "Using Views" tutorial

Getting real-time mouse input will be necessary to set the center position of the view
SFML 1.6 "Handling Events" tutorial (scroll down to the "Getting real-time inputs" section)


I've been using views alot before, also realtime input. The problem im having is to have a SEAMLESS looped view.. so if(mousex > rightedge){mousex = leftedge} wont work,

Wizzard

  • Full Member
  • ***
  • Posts: 213
    • View Profile
Looping/scrolling sf::View?
« Reply #3 on: May 05, 2011, 08:57:48 pm »
I'm not generous enough to write a tutorial, but I'll give you a few hints on one way to implement infinitely looping views:

* The background image will have to contain redundant pixel data on it's right and bottom sides that replicates the left and top sides of the background image respectively.
* The amount of redundant pixel data on the background image's right and bottom sides pertains to how many pixels can be seen in the application at one time minus one.
* The redundant pixels can be added to the image file or dynamically added to the image at runtime.
* The view will reset to the opposite side every time it is about to exceed the image pixels on the X or Y axis.

 

anything