Qbasicnews.com

Full Version: im prgressing but..........need your help once again
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2
hey everyone im working on graphics bitmaps and such, having a great time learning but im stuck. here is the code

Code:
FOR y = 1 TO 15
FOR x = 1 TO 21
READ map(x, y)
NEXT x
NEXT y

FOR y = 1 TO 15
FOR x = 1 TO 21
IF map(x, y) = 3 THEN PUT (x * 10 - 10, y * 10 - 10), grass
IF map(x, y) = 2 THEN PUT (x * 21 - 21, y * 16 - 16), jester
IF map(x, y) = 1 THEN PUT (x * 10 - 10, y * 10 - 10), wall
NEXT x
NEXT y
SLEEP

'map
DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
DATA 1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,1,1,1,1,1,1,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,1,0,0,0,0,1,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,1,0,0,0,0,1,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,1,0,0,0,0,1,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,1,0,0,0,0,1,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,1,0,0,0,0,1,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,1,0,0,0,0,1,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,1,0,0,0,0,1,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,1,1,1,1,1,1,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1

it keeps saying out of data...what have i done wrong????? thanks i have only posted the map not the other sprites so as not to take up space. the "out of data" statment occurs right here:
READ map(x, y)

thanks
nothing is wrong with taht part of it (among it not being able to run) so post it all =P
k here is the entire thing
Code:
DIM jester(16, 21), grass(10, 10), wall(10, 10)
DIM map(21, 15)

SCREEN 13

ylength = 21
xlength = 16

FOR y = 1 TO 21
FOR x = 1 TO 16
READ z
PSET (x, y), z
NEXT x
NEXT y
GET (0, 0)-(16, 21), jester



FOR y = 1 TO 10
FOR x = 1 TO 10
READ z
PSET (x, y), z
NEXT x
NEXT y
GET (0, 0)-(10, 10), grass

FOR y = 1 TO 10
FOR x = 1 TO 10
READ z
PSET (x, y), z
NEXT
NEXT
GET (0, 0)-(10, 10), wall


CLS
FOR y = 1 TO 15
FOR x = 1 TO 21
READ map(x, y)
NEXT x
NEXT y

FOR y = 1 TO 15
FOR x = 1 TO 21
IF map(x, y) = 3 THEN PUT (x * 10 - 10, y * 10 - 10), grass
IF map(x, y) = 2 THEN PUT (x * 21 - 21, y * 16 - 16), jester
IF map(x, y) = 1 THEN PUT (x * 10 - 10, y * 10 - 10), wall
NEXT x
NEXT y
SLEEP

'jester
DATA 15,15,15,15,15,15,15,00,00,00,15,15,15,15,15,15
DATA 15,15,15,15,15,00,00,05,05,13,00,15,15,15,15,15
DATA 15,15,15,15,15,05,05,05,13,00,14,00,15,15,15,15
DATA 15,15,15,15,00,00,05,13,00,15,00,15,15,15,15,15
DATA 15,15,15,15,00,05,05,13,13,00,00,15,15,15,15,15
DATA 15,00,00,00,04,05,05,05,13,04,00,00,00,15,15,15
DATA 00,04,04,04,04,05,05,05,13,04,04,04,04,00,15,15
DATA 14,00,00,00,04,05,05,05,13,04,04,00,00,14,00,15
DATA 00,15,15,00,06,06,06,06,06,06,00,15,15,00,15,15
DATA 15,15,15,00,06,00,06,06,00,06,00,15,15,15,15,15
DATA 15,15,15,00,06,00,06,06,00,06,00,15,15,15,15,15
DATA 00,00,00,10,00,06,06,06,06,06,09,00,00,15,15,15
DATA 00,10,09,10,09,00,00,00,00,10,09,06,06,00,15,15
DATA 06,09,00,10,09,10,09,10,09,10,00,06,06,00,15,15
DATA 06,00,15,00,00,10,09,10,09,00,00,00,00,15,15,15
DATA 15,15,15,00,04,04,01,04,01,04,00,00,15,15,15,15
DATA 15,15,15,00,04,04,01,04,01,04,04,00,15,15,15,15
DATA 15,15,15,00,00,04,01,04,00,00,00,15,15,15,15,15
DATA 15,15,15,15,00,05,14,05,00,15,15,15,15,15,15,15
DATA 15,15,15,15,05,05,05,05,05,15,15,15,15,15,15,15
DATA 15,15,15,15,15,15,15,15,15,15,15,15,15,15,15,15

'grass
DATA 2,2,2,2,2,2,2,2,2,2
DATA 2,2,2,2,2,2,2,2,2,2
DATA 2,2,2,2,2,2,2,2,2,2
DATA 2,2,2,2,2,2,2,2,2,2
DATA 2,2,2,2,2,2,2,2,2,2
DATA 2,2,2,2,2,2,2,2,2,2
DATA 2,2,2,2,2,2,2,2,2,2
DATA 2,2,2,2,2,2,2,2,2,2
DATA 2,2,2,2,2,2,2,2,2,2
DATA 2,2,2,2,2,2,2,2,2,2

'wall
DATA 7,7,7,7,7,7,7,7,7,7
DATA 7,7,7,7,7,7,7,7,7,7
DATA 7,7,7,7,7,7,7,7,7,7
DATA 7,7,7,7,7,7,7,7,7,7
DATA 7,7,7,7,7,7,7,7,7,7
DATA 7,7,7,7,7,7,7,7,7,7
DATA 7,7,7,7,7,7,7,7,7,7
DATA 7,7,7,7,7,7,7,7,7,7
DATA 7,7,7,7,7,7,7,7,7,7




'map
DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
DATA 1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,1,1,1,1,1,1,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,1,0,0,0,0,1,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,1,0,0,0,0,1,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,1,0,0,0,0,1,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,1,0,0,0,0,1,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,1,0,0,0,0,1,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,1,0,0,0,0,1,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,1,0,0,0,0,1,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,1,1,1,1,1,1,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,2,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,3,1
DATA 1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1
thanks
Two things:

1. You are consistent with using NEXT Y and NEXT X, but on one of your READ loops, you only use NEXT and NEXT. It still works, but you might wanna stick with one way or the other (I prefer the first).

2. The program is running out of data because your Wall sprite is looking for a 10x10 grid of numbers but your data statements are only 10x9.

*peace*

Meg.
I learned a new lesson. Don't fall asleep before posting....
i fixed it but its not working, it like not reading fromt the map or somthing. please help
I added one line of 7s to the wall DATA, and it seems to run fine for me. Of course, the jester sprite isn't 10x10 so it won't fit on your map.

What part isn't working for you?

*peace*

Meg.
lol nvm its workign thanks. also can you recommend any programs to add gifs to my programs cause drawing that jester in data statments was a pain. ive looked at tutorals but there to advanced any easy ways to do this?
#1: You can use a library to load pictures for you.

#2: You can make your own picture loading routines, depending on the image format.

I'd recommend #2, because you then get insight about how a file is built up and how it should be loaded. However, it costs more time, depending on the file format you want to load. GIFs are harder than BMPs or PUTs for example. I'd recommend PUTs for sprites (256 colours, generated by PP256), and BMPs for large images, because they're the easiest to be loaded by hand, and the easiest to start with. You can look for file formats at http://www.wotsit.org.
To load a PUT file:
[syntax="QBasic"]SUB LoadPut (PutFile$, Array() AS INTEGER)
FF = FREEFILE
OPEN PutFile$ FOR BINARY AS #FF
l& = LOF(FF) - 7
CLOSE #FF
REDIM Array(l& \ 2 - 1) AS INTEGER
DEF SEG = VARSEG(Array(0))
BLOAD PutFile$, VARPTR(Array(0))
DEF SEG
END SUB[/syntax]
Note: written entirely by heart, don't know if it's correct Wink

Hope it helped you a bit,

Neo
Smile
thanks Neo.


meg are you saying my sprite would either have to be 10 by 10 or that my tiles would have to be the same size as the sprite?
Pages: 1 2