Sign in to follow this  
  • entries
    686
  • comments
    1952
  • views
    386135

The man who is Blocky

Sign in to follow this  
Stompy9999

88 views

The parallax scrolling is now fixed, so the background scrolls relative to Blocky Man's speed. It turned out to be alot easier than I expected. I simply had to store the bg scroll values as doubles rather than integers, and used a proportion to set up the current scroll speed.

If you look in any of the previous demos for the game, you'll notice that the Background is always scrolling at the same speed, no matter how fast you are moving. This is no longer the case, as now the background speed is consistant with the foreground speed. I think it looks quite a bit nicer.

One thing I really miss from my days working with Allegro is the ability to have the program wait for the vertical retrace. My biggest problem graphically with Blocky Man is the constant tearing due to scrolling. I remember an Allegro side scroller I once worked on, where the scrolling was absolutly crisp because I could wait for V-Sync to redraw the screen. Sadly, I don't believe SDL provides this capibility, which is a shame.

Anyways, I can finally get back to working on the level. I need to start working on those missile turrents. I've actually had the graphics for the missile done for quite some time, but haven't gotten around to programming it.
Sign in to follow this  


5 Comments


Recommended Comments

I was quite suprised to hear that SDL_Flip doesn't wait for the retrace, but I've just been looking on the SDL site and there seems to be some confusion there about it working on some hardware and not others.

That seems like a major limitation to me if that's the case. Have you thought about jumping into using Direct3D directly for your next project? Once you've got a decent 2D sprite library up and running, it's really quite easy to use.

Share this comment


Link to comment
I'm suprised if SDL doesn't have this feature - I'm fairly sure I'm not getting tearing with my SDL with OpenGL games (I don't think Pierre and the Fish had that problem, did it? I might be a bit confused about the nature of the problem...). However since I'm using OpenGL with SDL it might make a difference - I call SDL_GL_SwapBuffers() instead of SDL_Flip().

Are you sure you're not forgetting to use double buffering or something like that?

Share this comment


Link to comment
On parallax scrolling:

The scrolling that I did for Mop of Destiny worked really well (and was easy to implement). Essentially, each layer of the map was its own mesh, with its own bounds. The layers are organized from back to front, with one of them marked as "main" which is used as the basis for the scrolling.

When you're to the far left of the main level, you're to the far left of all of them. Ditto for when you're to the far right.

Thus, the scrolling speed of a layer is controlled simply by how large it is relative to the main zone. Want a zone that scrolls at half speed? Make it half-the-size! Want a foreground zone that scrolls 1/3 faster? Make it 1.333x the size!

Just an idea, but it was really easy to implement (simply determine your current world scroll in the range of [0, 1] then use that scroll value for the other layers as well).

Share this comment


Link to comment
SDL_Flip will only wait for vertical retrace if it gets a hardware surface. This is usually only obtainable under fullscreen mode. Same with double buffering IIRC.

This is a great resource on SDL.

Share this comment


Link to comment
As far as I know, SDL can't wait for V-sync unless it is fullscreen, and as mentioned before, a hardware surface. I think SDL & OpenGL probably does, but plain SDL does not.

After Blocky Man, I'll be using XNA to write my games. I can't count how many times I've wanted to stop using SDL and just rewrite Blocky Man in XNA.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now