Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

CannoN346

Side-scrolling?

This topic is 6156 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How do you get a 2D game to use sidescrolling(using DirectX). I assume once a player reaches the maximum screen width you move the image on screen over so the player can see the next area of the map.

Share this post


Link to post
Share on other sites
Advertisement
Yeah you got the right idea, say a character is centered on the screen, as he goes closer to one direction the background will scroll. If you want the vertical scroll to move the background up when he jumps its the same thing. The background x,y is similar to that of the chr''s x,y

sorry if this isn''t too clear I''m not the best at explaining things...hope this helps, or at least others will post...

~~~~
sjunkim - P0et
Liquid Ice Studios
members.home.net/liquidicestudios/

Share this post


Link to post
Share on other sites
I´m not good at explaining in english but I´ll try...

Let´s say that your screen resolution is set to 640 x 480.

You load an image with the dimensions 1280x1024.

You start by drawing the map/image at (0,0).
Your character is centered on the screen.

When your character moves to the right you should see more of the map to the right.

Simply decrease the xpos of the image when drawing it to the screen. This will scroll the background...

NOTE: If you want to have large backgrounds/maps you should look up tiling or tilemaps.

Share this post


Link to post
Share on other sites
Oh one question are you using tiles? or are you using a larger background without multiple tiles?


~~~~
sjunkim - P0et
Liquid Ice Studios
members.home.net/liquidicestudios/

Share this post


Link to post
Share on other sites
hmmm I''m not quite sure how you would do this in VC++ but in VB bitblt makes it really easy...

If there is some function that would allow you to post only part of your image you could use that...I''m not quite sure...sorry...

I am looking forward to seeing some other solutions by other people though....

~~~~
sjunkim - P0et
Liquid Ice Studios
members.home.net/liquidicestudios/

Share this post


Link to post
Share on other sites
If you want to scroll with using larger bitmaps with no tiles, here's how I implemented it.

Let's say all you're .bmp's are 640x480 (since many times surfaces can't be larger than the screen), and you want to scroll around. All you need to do is when the edge of one background has been reach, blit the next background image at the edge of the last background image. Example:
Let X = where you're blitting the image (left edge) and Xsize is the size of the image horizontally.
if (X + Xsize < SCREEN_WIDTH)
{
Blit(Next_Image, X + Xsize, Y);
}

You'll need a way to know what images go where, so a world array should handle that.

Hope it helps.


Edited by - BeerNutts on July 17, 2001 3:22:40 PM

Share this post


Link to post
Share on other sites
Thanx. Im still in the process of learning. Ive got Windows programming down pretty good now. Now im learning DirectX(just DIrectDraw, DirectSound, and DirectInput). I want to make a 2D side scroller when im done. Also... what does the Sleep() function do??

Share this post


Link to post
Share on other sites
Where did you learn your windows programming? I''m still doing that and its pretty tough...

Sleep() ''freezes'' your program for a certain number of milliseconds, I think...if its the same thing as sleep in Visual Basic...

the sleeping loL! is required when a program runs TOO fast that the graphics flicker or things move to fast etc.

hope this helps,



~~~~
sjunkim - P0et
Liquid Ice Studios
members.home.net/liquidicestudios/

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!