Qbasicnews.com
Scolling Background - Printable Version

+- Qbasicnews.com (http://qbasicnews.com/newforum)
+-- Forum: QBasic (http://qbasicnews.com/newforum/forum-4.html)
+--- Forum: QB Discussion & Programming Help (http://qbasicnews.com/newforum/forum-11.html)
+--- Thread: Scolling Background (/thread-2952.html)

Pages: 1 2 3 4


Scolling Background - bonfire89 - 01-11-2004

I would like to write one of those games where the character remains in the middle, and the background scrolls right to left.

Can anyone give me any hints, or point me to a tutorial on how to accomplish this?


Thank You.


Scolling Background - adosorken - 01-11-2004

Hint: tile scrolling engine. Information on building them is everywhere, as well as example sourcecode. Smile


Scolling Background - Zack - 01-11-2004

I've been thinking of that lately.
Actually (weirdly), I think it's easier to make a side-scroller engine (like Keene, for instance), than it is to make a normal Zelda-style scroller. My own weird logic tells me that. :roll:


Scolling Background - bonfire89 - 01-11-2004

I wouldn't know.

Im in grade 11 programming at school. And we really havn't done much graphics at all, but we just recieved our game assignment which will be due pretty much at the end of the year.


Scolling Background - Zack - 01-11-2004

If you're new at QB, you shouldn't begin with something so advanced...
My suggestion is a nice space-fighter, or a Tetris game with twists. Or Arkanoid.


Scolling Background - bonfire89 - 01-11-2004

not that new, grade 10 was all qb too.

I've made graphics move around the screen.. Made a bouncing ball that got smaller and smaller using parabolas, and a bunch of other things.

I think I can pull it off as long as I can figure out how to get the scolling background


Scolling Background - bonfire89 - 01-11-2004

I was just thinking, to make tones and tones of columns of of psets and using a 2d arrary


dim thing(left to right position, y for pset)


then normally it it may show left to righ position of 0 to 800

but then when a user presses the right button it may advance it to 0+1 to 800 + 1


and then you could put it in a for loop




for i = 0 + times pressed right button to 800 + times pressed right button
for z = 0 to screen heigh
pset (thing(i), thing(z))
next z
next i



then of course I'd have to deal with colour some how.



in anyevent, I would assume this is garbage since the screen would just flicker horribly

or am I wrong?


then along with that, there can be an array wich would hold anything that it could possibly collide with.


actually this would be the perfect way to do it I think, as long as there is a way to stop the flicker








woa, just been reading on, maybe I need some type of buffer?


Scolling Background - Anonymous - 01-11-2004

first off, hi Smile havent seen you around good ta have ya.

but yeah. zelda style isnt *that* hard, but its not real easy either. Your idea with PSET is alright, but you gotta realize QB PSET is sloooooooow... you gotta learn how to poke to &HA000 to do anything remotely fast enough. (i think anyways) Really, it's soooo much easier to use tiles when doing pxp. if your tiles are 16x16 you just PSETd 256 pixels in the time you couldve done one Wink (well almost the same time but still). Ill give you a basic idea of pxp.

by the way you need a 'camera' to do that effectively, so ill show you how to do that too.

you have an x and y coord

in order to keep ur char in the middle of the screen we...

1. assume camera is upperleftmost postion on screen (actually we need camx and camy to do this)

2. Make sure CamX is Xpos - 160 (half the distance so its in the middle) CamY - YPos = 100 keep in mind this is 13h good luck going any other mode Wink

so now, you have to figure out where you are in the lay of things.

Lets say our tiles are 16x16

Code:
CamXTile = CamX \ 16 (\ = integer division; much faster)
CamYTile = CamY \ 16
YOffset = CamY MOD 16
XOffset = CamX MOD 16

now to put these tiles, you have to use this info, and you have to put an extra tile since one will be cut 15 out of 16 times.

Code:
FOR YPut = 0 to 200 step 16
FOR XPut = 0 to 320 step 16

Use your routine to put here at XPut - XOff, YPut - YOff

NEXT
NEXT

Keep in mind the CamXTile, CamYTiles are really only there for ease of getting your info out of your map array. Oh, and you cant just use QB PUT for this one, cause it goes off the screen. better read up how to do that Wink... or get a lib Tongue. This maybe isn't anything how you wanted to do it, but hey i tried Wink Oh, by the way

to put ur char, you do something like this...

Code:
XPos - Camx, YPos - CamY

and when you update your camera (which should be every iteration, just in case Wink) you gotta throw in something like this.

Code:
if CamY < 0 then CamY = 0
if CamX < 0 then CamX = 0

plus checking for the right and lower side as well.. since i dun know ur map size, i cant tell you what to use Wink

sorry if this is confusing. Wink


Scolling Background - bonfire89 - 01-11-2004

hey thanks for the reply, I'm brand new here. But have to create a game for school, so I'll probably be around more from now on.


Thanks for the reply, I just woke and groggy, so I shall give it another read in a bit

Thanks


Scolling Background - bonfire89 - 01-11-2004

ooOOOooo

I have just advanced my knowledge to know tiles. I could do what I was prevously thinking, but using tiles.

That will require thousands of tiles though.

And I would have to load all of them into get things

I have sort have read that I can do that, with out it ever having to display that on the screen with somthing to do with screen7

also, I know what you mean if a tile is partly on the screen... Ihave to learn how to deal with that.



can you havea dynamic variable name?

eg


for i = 1 to 10
put (1,1), tile i %, pset
next i


and then that would work out to be
put (1,1), tile1%, pset
put (1,1), tile2%, pset
put (1,1), tile3%, pset
put (1,1), tile4%, pset
put (1,1), tile5%, pset
put (1,1), tile6%, pset
put (1,1), tile7%, pset
put (1,1), tile8%, pset
put (1,1), tile9%, pset
put (1,1), tile10%, pset