Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7022637
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T23:36:29+00:00 2026-05-27T23:36:29+00:00

I’m working on a 2D shmup, and the idea is that the level continuously

  • 0

I’m working on a 2D shmup, and the idea is that the level continuously scrolls automatically, and your character can move around the screen.

Now, I’m having trouble figuring out how I would implement this and Google hasn’t been any help. Right now I have a scrolling background (the background position is simply decremented for each frame) and the player can move around freely in the window, but how would I go about creating the objects in the level? Would I just use a timer to trigger objects and enemies or is there a way to do it based on the position/width of the background (I’d prefer the second method…But I have no clue how that would be done)?

Since this is a general question and doesn’t really pertain to any of my code that I’ve already written as far as I know, I don’t think I need to include any of it…But I’ll be happy to provide any part of it if needed.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T23:36:30+00:00Added an answer on May 27, 2026 at 11:36 pm

    I’d recommend either:

    • Use physical triggers
    • Use a list of timed events

    Physical triggers

    Simply place a box on your level. When it scrolls partially or completely onto the screen (whichever makes more sense – maybe use both in different cases?), you trigger the event associated with that trigger.

    This would be simpler to support in a level editor because the physical nature is inherently very easy to visualize.

    Timed events

    You basically create a timer object at the beginning of the level, and an ordered queue of events. In your game update loop, peek at the head of the queue. If the trigger time of the item at the head of the queue is less than the current elapsed time, pop the item off the queue and trigger the event.

    Timed events would be more generically useful because it would also support non-scrolling level, or non-scrolling portions of levels.

    Combination of both

    You could also do some sort of combination of these to get the benefits of both styles: Easier visualization/level editing, and supporting non-scrolling sections or time-based events.

    Each physical trigger will have its own script queue. When the trigger is hit, a timer is started and an event queue is created. That timer and queue is added to a list of currently running timers and queues.

    In your update function, you check all items on the list, and trigger events the same way you did with the timed event queue above. Once a queue is emptied, you remove it from the list of timers/queues.

    How to detect that a trigger is on-screen

    You should implement scrolling first.

    One you have scrolling, calculate the rectangle that matches where the screen is located in your pixel/world coordinate system. This will give you the "bounding box" of the screen.

    From here, do an intersection test between your event trigger’s "bounding box" and the screen.

    Here is a test to see if there is any overlap between two rectangles. It isn’t order-specific:

    rect1.left < rect2.right && rect1.right > rect2.left
        && rect1.top < rect2.bottom && rect1.bottom > rect2.top
    

    If the rects are touching at all, it will return true.

    Here is a test to make sure rect1 contains rect2. Order is important:

    rect1.left <= rect2.left && rect1.right >= rect2.right
        && rect1.top <= rect2.top && rect1.bottom >= rect2.bottom
    

    If rect2 is completely contained by rect1 (it is completely on-screen), it will return true.

    How to implement simple timers

    Simply get some sort of clock value (could be SDL_GetTicks), and store that value.

    To see how long has elapsed since that timer was started, call the function again and subtract. Compare the values with < to see if the difference is greater than the target time.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I've got a string that has curly quotes in it. I'd like to replace
I have a French site that I want to parse, but am running into
Does anyone know how can I replace this 2 symbol below from the string
I need a function that will clean a strings' special characters. I do NOT

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.