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! / Scrolling question

Author
Message
JSN
20
Years of Service
User Offline
Joined: 8th Nov 2003
Location: 127.0.0.1
Posted: 16th Nov 2003 16:17
Hi All,

If I have a level, about 1 screen high, 10 screens wide, what's the best method of scrolling?

Do I use each indiviual 'tile' as a sprite, or load in one huge screen?

Also, if I wanted collision detection, how would that be used if I loaded the entire screen?

~ J ~
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 16th Nov 2003 16:37
indiviual tiles are best, as a bitmap too large may crash certian video cards. 10 screen as a single bitmap could be very large indeed depending on the resolution.

CTP

Lifes short, try to enjoy it and not take it to seriously!
JSN
20
Years of Service
User Offline
Joined: 8th Nov 2003
Location: 127.0.0.1
Posted: 16th Nov 2003 16:52
Trouble is though, if each tile is about 40 pixels x 40 pixels, over a normal 800 (x10) by 640 screen, this would be 128,000 sprites!!

Is there a way to paste an images, then simply scroll the screen rather than sprites?

~ J ~
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 16th Nov 2003 19:50
You don't need 128000 sprites just the ones on the screen.
Here's what I do,

I have a map array with a couple of layers
dim map(1000,20,2)
I use layer 1 as the background
and layer 2 as the foreground

I us images to draw the background and sprites only for my movable objects and the foreground. I draw my screen like this.
function draw_background(layer)
for drawx = -1 to 20
for drawy = -1 to 14
pastex = drawx + mapx
pastey = drawyy + mapy
if map(pastex, pastey, layer) > 0 then paste image map(pastex, pastey, layer), drawx*32-mapxoffset, drawy*32-mapyoffset
next drawy
next drawx
endfunction
mapx and mapy are the characters location evertime the screen scroll 32 pixels right the mapx value increase by 1( I used 32x32 tile in this program, you'll have to adjust for 40x40)
mapxoffset and mapyoffset are the part of 32 the ship has moved but it's not a full tile yet,( this is what makes smooth scrolling, and how you change the speed of the scrolling)

I draw my background first then my then I draw my playable pieces I use(normally) sprites for these.

I then draw my foreground layer which if it something I can collide with like land I use sprite instead of paste image, but if it's just effects like clouds and I just want them to pass over the objects and give a since of speed I'll use paste image.

I have done this before with nothing but images(no sprite) but DBP built in sprite collision and some of the sprite effects like scale sprite and rotate sprite are nice to use for the playable pieces.

as well I have done it with all sprites, but I always now (after doing a few) use images for the background layer.

It's not that hard to do. I suggest you build a map editor that you can scroll with the arrow keys first that will build and save the map array, then start making the game. 1st load in the map array and get the background layer to scroll then add the playable pieces and interactions, then a foreground layer and if you want a screen overlay I use one big sprite with transparency on drawn over the whole screen.

I hope some of this helps
CTP

Lifes short, try to enjoy it and not take it to seriously!
JSN
20
Years of Service
User Offline
Joined: 8th Nov 2003
Location: 127.0.0.1
Posted: 16th Nov 2003 20:19
Hang on now, this could be interesting...

You say that everytime you scroll the screen 32 pixels, you replace the old offset of tiles with the new. This sounds very very similar to my C64 programming days with the screen offset rule.

How on earth are you scrolling the screen? I can't see any of that in the documentation, only scrolling / moving sprites.

~ J ~
ReD_eYe
21
Years of Service
User Offline
Joined: 9th Mar 2003
Location: United Kingdom
Posted: 16th Nov 2003 22:06
when using sprites you don't scroll the screen, you give the impression of scrolling by moving each image 1 sprite to the left or right


GO TO THE ETERNAL DESTINY FORUMS!!! http://forums.eternaldestinyonline.com
Do it now!!!
IanM
Retired Moderator
21
Years of Service
User Offline
Joined: 11th Sep 2002
Location: In my moon base
Posted: 16th Nov 2003 22:47
Have a quick look in the codebase for the simple tiling example I posted there. Obviously it could be made cleverer, but it should give you a starting place.
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 16th Nov 2003 22:54 Edited at: 16th Nov 2003 22:58
heres a complete working example of a side scrolling game with a background and a foreground
use the arrowkeys to move around
no media needed
I only used images, you'll have to adjust it for sprite and I used 32x32 tiles, you'll need to adjust it for bigger tiles.

It's not ment to show you everything but you should be able to figure it out and expand on it real easy, it only took me about 30 minutes to make, so image what you can do with more time.

CTP






Lifes short, try to enjoy it and not take it to seriously!
JSN
20
Years of Service
User Offline
Joined: 8th Nov 2003
Location: 127.0.0.1
Posted: 17th Nov 2003 01:07
Brilliant! Understand it 100% Kinda similar to what I thought, except better.

Many thanks.

~ J ~
JSN
20
Years of Service
User Offline
Joined: 8th Nov 2003
Location: 127.0.0.1
Posted: 17th Nov 2003 01:40
Just one final question, which could lead to another.

Just how 'good' is this method? My PC is quite a powerful one, and the scrolling looks great, but if I do a program using this method, will this routine jepodise performance on low-mid end machines.

Which leads to another question... ...is there a way to emulate a lower end spec pc?

~ J ~
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 17th Nov 2003 02:09
are you using Dark basic pro or dark basic classic?
what do you consider a lower end system?
Dark basic seems most limited by what type of video card is in the computer not what speed it is.
I can run that on a 500 mhz with no slow down.
dark basic pro requires a 8 meg 3d video card, I have no machine equipt with that which is slower.
if your using DBC sprites are just images which may be slower because of tracking over head.
DBP sprite may be faster if your video card is faster at 3d then 2d, which most newer ones are.(sprite in pro are 3d planes)
I don't think you'll have any faster method as it's only syncing as 30 fps.
optimzation tips are to lower resolution, run in full screen exclusive mode or in window mode( but not window fullscreen), lower color bits from 32 to 16.
performace is a tough question and any 2d game in DB should run fine on any machine made in the last 5 years.

I have been playing with that little demo and am making a playable game out of it, If you would like me to post it I will.

CTP

Lifes short, try to enjoy it and not take it to seriously!
JSN
20
Years of Service
User Offline
Joined: 8th Nov 2003
Location: 127.0.0.1
Posted: 17th Nov 2003 09:56
are you using Dark basic pro or dark basic classic?
DBP

what do you consider a lower end system?
Less than 1.4Ghz

Dark basic seems most limited by what type of video card is in the computer not what speed it is.
ok

I can run that on a 500 mhz with no slow down.
Sounds good!

dark basic pro requires a 8 meg 3d video card, I have no machine equipt with that which is slower.
ok

if your using DBC sprites are just images which may be slower because of tracking over head.
N/A

DBP sprite may be faster if your video card is faster at 3d then 2d, which most newer ones are.(sprite in pro are 3d planes)
ok, didn't know that

I don't think you'll have any faster method as it's only syncing as 30 fps.
true, sounds good

optimzation tips are to lower resolution, run in full screen exclusive mode or in window mode( but not window fullscreen), lower color bits from 32 to 16.
ok

performace is a tough question and any 2d game in DB should run fine on any machine made in the last 5 years.
no probs there then?

I have been playing with that little demo and am making a playable game out of it, If you would like me to post it I will.
yeah, would be handy please

~ J ~
CloseToPerfect
21
Years of Service
User Offline
Joined: 20th Dec 2002
Location: United States
Posted: 17th Nov 2003 14:34
There's the code under the source button.
I added 2 kinds of enemies, looped the map, added lives and score display.

It's nothing fancy and there's no media, but it'll show you how I use types to track all my enemies.
spacekey to shoot.

Lifes short, try to enjoy it and not take it to seriously!
JSN
20
Years of Service
User Offline
Joined: 8th Nov 2003
Location: 127.0.0.1
Posted: 17th Nov 2003 16:10
Cheers for that,

Will download and have a look when I get home (don't think work would appreciate me coding a game rather than a portal )

Thanks again, much appreciated.


J

~ J ~

Login to post a reply

Server time is: 2024-05-02 08:44:27
Your offset time is: 2024-05-02 08:44:27