Qbasicnews.com
February 27, 2020, 01:40:32 PM
 Pages: 1 [2] 3
 Author Topic: Scolling Background  (Read 7705 times)
bonfire89
Member

Posts: 25

 « Reply #15 on: January 11, 2004, 04:30:21 PM »

Ill ask my teacher on tuesday about the version of QB that has to be used.

what is theis select case arraynumber stuff? you can acctually use GET (10,10)-(30,30),imagearray(5)

sorry about my longer replies.. studying up for physics
 Logged
Agamemnus
x/ \z

Posts: 3491

 « Reply #16 on: January 11, 2004, 04:56:55 PM »

powerbasic7.02
 Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
*/-\*

Posts: 3655

 « Reply #17 on: January 11, 2004, 05:11:48 PM »

bonfire, you can put multiple sprites into a single array and then PUT them using an offset. For example:

Code:
offset = 10 * 10 / 2 + 1 'the standard 13h method of sprite size calculation
DIM sprite(11 * offset) AS INTEGER 'the sprite array
GET (0, 0) - (9, 9), sprite(10 * offset) 'get the sprite
PUT (50, 50), sprite(10 * offset) 'put it down elsewhere

The offset calculation is different depending on what screenmode you're in. The 13h one I just showed takes the height and width of the sprite (10x10) and multiplies it to get the number of bytes the sprite will be, then divides it in half (remember, an integer array has 2 bytes per element), and then add 1 to hold the sprite header (again, 2 bytes, so add 1). Hope this isn't too confusing for you, and hope it puts you in the right direction.
 Logged

I'd knock on wood, but my desk is particle board.
bonfire89
Member

Posts: 25

 « Reply #18 on: January 11, 2004, 05:26:37 PM »

so the sprite would be the entire background, and then you just shift it over everytime the character moves?
 Logged
red_Marvin
Na_th_an

Posts: 1509

 « Reply #19 on: January 11, 2004, 06:03:44 PM »

I think you misunderstood that... tiles is like Lego(r),
you use many small pieces to build a big

..uh something, perhaps a castle?
 Logged

/post]
bonfire89
Member

Posts: 25

 « Reply #20 on: January 11, 2004, 06:35:38 PM »

lol yeah, thats what I thought.

so. I have tones and tones of tiles, that all fit together to make my background.

as far as I know, I would have to store each tile in its own array

DIM tile1%(w*h)
DIM tile2%(w*h)
DIM tile3%(w*h)

.
.
.
DIM tile5000%(w*h)

now that is a lot of dimming, and since doing somthing like

for i = 1 to 5000
put (1,1), tile i %, PSET
next i

is not possible as far as I know (although it has been said otherwise but it is a secrete for now) I would have to type each one out manually, which is okay since I have ASP at my disposal

Im thinking each tile can be the entire height of the screen and for this example one pixel wide.

if the screen res is set so the width is 640pixels I could say

display tiles 1 to 640

and then when the user pressed the move right key it would display tiles 2 to 641
 Logged
Agamemnus
x/ \z

Posts: 3491

 « Reply #21 on: January 11, 2004, 06:44:21 PM »

Hi again. Would this help? -- use two dimensions. IE:

tile%(h * w - 1, amount - 1)

-1 is there 'cuz you have 0 as the first subscript by default, so a(0) has one number/pixel, and tile%(h * w - 1, amount - 1) has h * w * amount pixels.
 Logged

Peace cannot be obtained without war. Why? If there is already peace, it is unnecessary for war. If there is no peace, there is already war."

Visit www.neobasic.net to see rubbish in all its finest.
bonfire89
Member

Posts: 25

 « Reply #22 on: January 11, 2004, 06:48:56 PM »

ahh got it to work!

OH MY

THANK YOU!
 Logged
bonfire89
Member

Posts: 25

 « Reply #23 on: January 11, 2004, 07:26:44 PM »

so Im trying to just put up enough vertical bars to fill the screen right now.

Code:

SCREEN 7

OPTION BASE 1
DIM tiles%(200, 1 TO 320)

FOR i = 1 TO 320
count = count + 1

IF count > 10 THEN 'this is for the first 10 colors
count = 1
END IF

FOR z = 1 TO 200
PSET (i, z), count
NEXT z
GET (i, 1)-(i, 200), tiles%(199 * 1, i)
NEXT i

for some reason I can only do like 5 bars though, by the end, Im going to want thousands

im thinking I have to do somthing special for huge arrays
 Logged
na_th_an
*/-\*

Posts: 8244

 « Reply #24 on: January 11, 2004, 07:49:46 PM »

It seems that you are storing in arrays 1x200 pixels sprites of the same colour. Why don't you just use LINE to draw lines?
 Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
bonfire89
Member

Posts: 25

 « Reply #25 on: January 11, 2004, 08:09:48 PM »

right now this is just for testing purposes. eventually this will be a background which scrolls and will not be solid lines
 Logged
na_th_an
*/-\*

Posts: 8244

 « Reply #26 on: January 11, 2004, 08:16:32 PM »

you haven't understood the concept of tiles. Usually, tiles are 16x16, 8x8, 20x20 or something like that. The idea is not to spend memory in a whole screen, but storing only the necessary. For example, if your background is a castle, you have a tile with a wall, a tile with floor, a tile with a window and you build a map using those tiles to get the background.

To make it scroll, you just have a camera position and draw your tiles from that position. You will need a PUT routine with clipping, and QB's own PUT doesn't have one, so go finding a graphics library or code yourself.
 Logged

SCUMM (the band) on Myspace!
ComputerEmuzone Games Studio
underBASIC, homegrown musicians
[img]http://www.ojodepez-fanzine.net/almacen/yoghourtslover.png[/i
bonfire89
Member

Posts: 25

 « Reply #27 on: January 11, 2004, 08:31:44 PM »

in anyevent. This is all I know, and in theory it should work. But it isn't.
 Logged
Anonymous
Guest
 « Reply #28 on: January 11, 2004, 08:46:55 PM »

tip 1: dont do lines dude. its dumb. do what youre gonna do. the more you learn wrong the more youre gonna have to 'unlearn' when you wanna actually do it. just make colored boxes if anything

tip2 : i think maybe youre assuming that each 'tile' (or line) is only taking up one index of the array. its actually taking up the number of pixels \ 2 + 2. that may be your problem.
 Logged
bonfire89
Member

Posts: 25

 « Reply #29 on: January 11, 2004, 09:05:18 PM »

is there a maximum size to an array?

because if I put

DIM tiles%(200, 1 TO 5)

it works (that line only)

but I want

DIM tiles%(200, 1 TO 320)

and later on, instead of 320, ill want somthing like 5000
 Logged
 Pages: 1 [2] 3