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

Author Topic: Using Views for Multiple Levels  (Read 160 times)

0 Members and 1 Guest are viewing this topic.

crbn-hash

  • Newbie
  • *
  • Posts: 3
    • View Profile
Using Views for Multiple Levels
« on: May 01, 2020, 05:49:29 pm »
I'm looking to display a train track that extends horizonally out of the window. I would like to display the track as wrapping, and thus be able to scroll up and down to view the full length of the track - instead of including logic that would break the track up as it is rendered.

I would think that I could define a second view which contained the track outside the window, and then set a viewport stacked under the default view:

View view1 = getDefaultView();                             //contains first portion of track
View view2(offscreen  track x, offscreen track y);    //contains second portion of track

view2.setViewport( 0 , offset from view1.y);           //display second portion of track underneath first portion
                                                                          //scroll down to view this portion

I've consulted:

https://en.sfml-dev.org/forums/index.php?topic=11526.msg80208#msg80208

https://en.sfml-dev.org/forums/index.php?topic=23574.0

and a few other threads to no avail.

Thanks for any input!

Hapax

  • Hero Member
  • *****
  • Posts: 3001
  • My number of posts is shown in hexadecimal.
    • View Profile
Re: Using Views for Multiple Levels
« Reply #1 on: May 01, 2020, 06:11:28 pm »
I must admit that I don't fully understand the problem you have.

Is the train a single image that is just too large to store in a single texture?
Selba Ward - SFML drawables
Kairos - Timing Library
Rectangular Boundary Collision - Rectangular SAT Collision

@Hapaxiation - Hapaxia on Twitter

crbn-hash

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Using Views for Multiple Levels
« Reply #2 on: May 01, 2020, 06:42:22 pm »
The train track length will be dynamic and rendered based on different map files that are fed to the program, so I can't assume it will fit in the initial window ie.

window with tracks extending outside of it
_______________________
|====================================================                                       
|                                        |
|                                        |
|                                        |
|______________________|

versus

_______________________
| ================ |
| ================ |
| ================ |
| ======                         |
|______________________|

Hapax

  • Hero Member
  • *****
  • Posts: 3001
  • My number of posts is shown in hexadecimal.
    • View Profile
Re: Using Views for Multiple Levels
« Reply #3 on: May 01, 2020, 06:52:34 pm »
You could just draw it all; it allows you to draw outside of the window (it'll be clipped).
To scroll, either move the drawing or the view (that is used to draw it).
Selba Ward - SFML drawables
Kairos - Timing Library
Rectangular Boundary Collision - Rectangular SAT Collision

@Hapaxiation - Hapaxia on Twitter

crbn-hash

  • Newbie
  • *
  • Posts: 3
    • View Profile
Re: Using Views for Multiple Levels
« Reply #4 on: May 01, 2020, 07:04:41 pm »
Right! But I would like to scroll vertically instead of horizontally. Moving the drawing everytime it hit the window limits would be a lot of extra logic.

Hapax

  • Hero Member
  • *****
  • Posts: 3001
  • My number of posts is shown in hexadecimal.
    • View Profile
Re: Using Views for Multiple Levels
« Reply #5 on: May 01, 2020, 07:06:27 pm »
You mean every now and again show it? If so, moving it seems simple :p You could just position it using the mod approach.
Selba Ward - SFML drawables
Kairos - Timing Library
Rectangular Boundary Collision - Rectangular SAT Collision

@Hapaxiation - Hapaxia on Twitter

 

anything