Qbasicnews.com

Full Version: reading an array?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Ok so here is the deal. Im making a game and i use data statements then store them with the get command. The only problem is that i dont like the way the graphics come out since im doing it by hand. So the next thing i did is used pp256 and then just wrote them down by hand then copied them into a statement.

So now what im doing is using a bitmap loader and making graphics in paint. Load the bitmap use the get command and store the info in a array. So the question is this. After i have stored the graphic's data to an array how can i read that info and have it print to the screen. Cause what i really want to do is have it print it to a file that i can just call instead of having to put full data statements in my program. Or at least be able to copy and paste kind of thing. Anyway, plz help.


P.S. Im sure someone is going to say just learn how to load them using pp256 or the bload bsave thingy. I really want to do it this way cause im having a problem and i want to get past it. That way when i have a problem later down the road all have experince fixing it instead of just avoiding it. Thx.
Could you please be more specific? Are you just trying to get the graphic on the screen?
In response to your reply offensive... What im trying to do is print the data statement from a graphic for example


1. Load the bmp

2. Store the info of that graphic in a array

3. Read the array and print the info to the screen


so...

data 1,2,3,4,5
data 1,1,1,1,1
data 1,1,1,1,1
data 1,1,1,1,1

I want to be able to get that information. From the gfx i made in paint. Hope you get what im trying to do thx.
I havent done graphics in a while....nor am I good with them but i'll try to solve your problem..(if I am understanding what you want correctly)

Code:
DIM sprite(4, 5)

FOR y = 1 to 5
FOR x = 1 to 5
READ clr
PSET (x, y), clr
GET sprite(1, 1)-(4, 5)
CLS

PUT sprite (1, 1)-(4, 5)

not to sure if this will work or if this is what you want...Have you read Vic Luc's RPG tutorial on this site? It's a great tutorial it'll tell you what you need.
Thx for trying to help me offensive. But, that is not what im wanting. Thx anyway
Dude! Really, this couldn't be any easier.
Just use PP256, and save them, then in your program you
can just bload them back up, very simple...

Code:
SUB V13hBLD (ARRAY(), file$)
length& = V13hLOF&(file$)
IF length& THEN
  Words = ((length& + 1) \ 2) - 1
  REDIM ARRAY(0 TO Words)
  DEF SEG = VARSEG(ARRAY(0))
  BLOAD file$, 0
END IF
END SUB
'
FUNCTION V13hLOF& (file$)
  FileNum = FREEFILE
OPEN file$ FOR BINARY ACCESS READ AS FileNum
  V13hLOF& = LOF(FileNum) - 7
CLOSE FileNum
END FUNCTION
'

I don't know if you know how to use subs and functions yet?
If you don't then just reply in this thread and I'll re-write these routines and make a complete file so all that you need to do is run it.
Also, getting back to using subs and functions...
If you don't know what or how to use these than I say stop trying to code your own games/programs or whatever it is your doing,
and learn some more about programming!
Not trying to sound mean, just giving some advice :)

Hope it works out for you.

Nemesis
Tim, do yo uwant to be able to read the info into an array, and then PUT that array on screen?

Doing that is a bit hard, and requires fiddling with segments, and poking to memory.

Otherwise:
Code:
LoadBMP &HA000, 320, 200, "thefile.bmp", 0, 0, -1, -1
Dim Array(imgXSize, imgYSize) As Integer
For y = 0 To imgYSize
For x = 0 To imgXSize
  Array(x, y) = Point(x,y)
Next
Next


Cls: Screen 0
For y = 0 To imgYSize
Print "Data ";
For x = 0 To imgXSize
  If x < imgXSize Then Print Array(x, y); ","; Else Print Array(x, y)
Next
Next
Do you mean something like that?
Quote:Thx for trying to help me offensive. But, that is not what im wanting. Thx anyway

sorry :normal: