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

Author Topic: using views with a "background" of unlimited size  (Read 3912 times)

0 Members and 1 Guest are viewing this topic.

bobl

  • Newbie
  • *
  • Posts: 18
    • View Profile
using views with a "background" of unlimited size
« on: May 21, 2010, 08:56:49 am »
I've just run the graphics-views.cpp tutorial here
http://www.sfml-dev.org/tutorials/1.6/graphics-views.php

I'd like to modify it so that a user can set up a grid of cells...
where each cell is a coloured rectangle of fixed size
with the first so-many digits on it i.e. nothing fancy.

The thing is...
I want the grid size to be specified at run time,
i.e. avoiding statements like "Background.Resize(2000, 2000);"
which fixes the size of the background at compile time.
I'd like to start with one cell (top left) and have the user add cells
by pressing either the right or down arrow keys.

I used such unlimited pads in both ncurses and wxpython.

Any thoughts much appreciated
Rgds
Dean

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
using views with a "background" of unlimited size
« Reply #1 on: May 21, 2010, 10:04:04 am »
Kinda confusing.

If the background has tiles or repeats you want to fill in tiles or scroll back to a looping point in the texture.

If you're looking to avoid specific assets you use a reference to your grid and then it will lookup and find the tile and resize that tile.

It's all about moving things in relative position and giving the illusion of an unlimited field offstage of the screen/window.

bobl

  • Newbie
  • *
  • Posts: 18
    • View Profile
using views with a "background" of unlimited size
« Reply #2 on: May 21, 2010, 10:21:38 am »
Thanks very much for coming back and sorry for making a "meal" of it.
I'm not familiar with the terminology you're using
but it does give me something to look up.

Let me try to explain it another way.

1 user does nothing
cell|
----                          
                           
2 user presses right arrow    
cell | cell |                          
-----------                          
                                         
3 user pressess down arrow  
cell | cell |                        
---------------------            
cell | cell |                        
         
etc

The background grid will keep growing until the user
stops clicking the right and down arrow keys and presses DONE
at which time the size of the background gets fixed.


Is this more clear and, if so, is what you're suggesting still the solution?

EDIT:

Ahhh! I think I'm starting to see --- so you could have the background the same size as the view and just keep overwriting it with different cells?????

Ashenwraith

  • Sr. Member
  • ****
  • Posts: 270
    • View Profile
using views with a "background" of unlimited size
« Reply #3 on: May 21, 2010, 07:58:26 pm »
You would have a little extra for the edges so it looks seamless as it moves on screen.

Depending on what you are doing it might actually be faster to just move the squares and change the color/size instead of creating new images/sprites or whatever.

bobl

  • Newbie
  • *
  • Posts: 18
    • View Profile
using views with a "background" of unlimited size
« Reply #4 on: May 22, 2010, 01:07:03 pm »
I've been working on that basis following your previous suggestion
so thanks for that.

 

anything