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

Author Topic: Repeating background?  (Read 4704 times)

0 Members and 1 Guest are viewing this topic.

Bonafide

  • Newbie
  • *
  • Posts: 18
    • View Profile
Repeating background?
« on: March 25, 2009, 06:16:39 pm »
Hey guys,

I'm wondering if there is a simple way of redrawing a background once it begins to run out of the View rectangle, or if it was possible to set an image as the background of a window/screen.

One more question. What's the method to check if there is a mouse click on a certain part of an image (e.g. a title screen, and I want to click on play or options, etc.)?

Hiura

  • SFML Team
  • Hero Member
  • *****
  • Posts: 4321
    • View Profile
    • Email
Re: Repeating background?
« Reply #1 on: March 25, 2009, 06:44:06 pm »
Quote from: "Bonafide"
One more question. What's the method to check if there is a mouse click on a certain part of an image (e.g. a title screen, and I want to click on play or options, etc.)?
None. You need to check yourself if the position of the click is on your sprite.
SFML / OS X developer

Tank

  • SFML Team
  • Hero Member
  • *****
  • Posts: 1486
    • View Profile
    • Blog
    • Email
Re: Repeating background?
« Reply #2 on: March 25, 2009, 11:23:07 pm »
Quote from: "Bonafide"
I'm wondering if there is a simple way of redrawing a background once it begins to run out of the View rectangle, or if it was possible to set an image as the background of a window/screen.

There's no method to tile an image/sprite, but you can easily do that on your own. Two simple for loops that increment by the proper image dimension each cycle and run as long as the loop counter variable is inside the view rectangle.

Setting a "background image" isn't possible directly. Instead you just draw a sprite over the whole screen each frame.

SamuraiCrow

  • Newbie
  • *
  • Posts: 40
    • Yahoo Instant Messenger - samuraileumas
    • View Profile
Repeating background?
« Reply #3 on: April 02, 2009, 05:18:11 pm »
Actually, the really efficient way to implement a repeating pattern is to use OpenGL.  You just set up the small backdrop image as the current texture and draw a large quad.

If you don't know OpenGL programming, then you're better off with the double-nested loop.