Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

2D All the way! / 2d side scroller

Author
Message
farmkid4
14
Years of Service
User Offline
Joined: 23rd Sep 2009
Location: on my pc :)
Posted: 6th Feb 2010 20:40
Hi guys i am making a 2d shootem up. I want the player to be able to walk right until the end of the level. Is there a way to move the camera as he moves? or do i have to move alll of the other sprites left?

if i wasn't clear enough just let me know



TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 6th Feb 2010 21:23 Edited at: 6th Feb 2010 21:24
There is no camera in 2D. DB only creates a camera if and when you create a 3D object, so if you are using only 2D you don't get one.

Instead you use the 2D screen which is in whatever resolution you choose with Set Display Mode - eg: 800x600, 1024x768 and so on.

You place things on the screen in such a way as to fool the eye into thinking that your character is moving. Part of this is called 'side-scrolling' and I'm currently writing a tutorial on the subject.

So basically, the answer is yes you do place things on the screen yourself and move them.

TDK

farmkid4
14
Years of Service
User Offline
Joined: 23rd Sep 2009
Location: on my pc :)
Posted: 6th Feb 2010 21:34
Ok thanks for the reply. When is the tutorial going to be done? i will have to do a bit of experimenting. I was hoping there was an easy way though.

Pincho Paxton
21
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 7th Feb 2010 21:22
If you want to use a camera, you can put all of your graphics on plains, then it's 3D emulating 2D.

TDK
Retired Moderator
21
Years of Service
User Offline
Joined: 19th Nov 2002
Location: UK
Posted: 8th Feb 2010 05:22
As Pincho Paxton says, you can also use 3D to make it look like 2D - but that's a method I've never used myself so I can't say if it's easier or harder than sticking purely to 2D.

If you stay with 2D, here's something to think about...

Imagine your screen was built as a grid of squares, each one 8x8 pixels in size. In 800x600 screen mode, there would be 100 running from left to right and 75 running from top to bottom - 7500 squares in total.

If all those screen locations were represented by integer array such as ScreenLoc(100,75), you could store values in the array corresponding to what is on the screen at any particular location and use the array to draw the screen's contents.

Taking it one step further, instead of an array 100x75, now imagine an array 5000x75 - with the screen a 'window' with which you can look at any given 100x75 section of the array.

All you would need is an offset from 0 (or pointer) telling you how many vertical columns you are along the full width of the array and just move the pointer left and right as you move the character left and right.

With a parallax scrolling background and other sprites in the foreground you could get quite a nice effect.

Basic background scrolling is pretty much the same thing only the width of the section you are scrolling is only a little wider than the screen and instead of square tiles you would have thin vertical strips.

Basic Single Screen Scrolling (Character Moves Right):

Grab a two pixel wide vertical strip of the screen with Get Image. Grab the rest of the screen in another image and paste it two pixels to the left. Finally, paste the first two pixel wide image in the two pixel wide gap created on the far right of the screen.

Repeat.

Reverse the procedure to scroll in the other direction.

TDK

farmkid4
14
Years of Service
User Offline
Joined: 23rd Sep 2009
Location: on my pc :)
Posted: 8th Feb 2010 23:36
thanks for the tips i will try it/them.

Zyronagon
16
Years of Service
User Offline
Joined: 6th Mar 2008
Location: USA
Posted: 22nd Feb 2010 01:41
Oh look, a fellow Swagbucks user. Off topic.

Login to post a reply

Server time is: 2024-04-20 06:42:44
Your offset time is: 2024-04-20 06:42:44