A question about GET, PUT, and graphics

Please use this Board for QBasic related requests ( file research, programming, etc.)

Moderators:Administrator, Global Moderator

Post Reply
QB-DM
A question about GET, PUT, and graphics

Post by QB-DM » Wed Mar 23, 2005 9:27 am

Hoping someone can help me out here ...

I'm working on putting some graphics in a game, and I'm planning to GET a lot of the sprites to make them easier to place later. I realized that GET stores the pic data in a variable array, and though it would be nice if I could use a multi-dimensional array for this. I was hoping to be able to use one array to store a number of pics, and choose between the pics simply by changing one statement in the array. For example, suppose I use the variable Pic(x, y) where x is the number of the pic to display and y is the GET data itself. Then, all I would need to do to place several pics, in a loop for example, is to change x.

Sounds good in theory, but the GET and PUT statements don't seem to allow me to difine the variable like that. Any suggestions?

marko_tomas13

Post by marko_tomas13 » Thu Mar 24, 2005 12:56 am

I don't think thats possible with GET and PUT since they don't work that way. Don't quote me on that but im pretty sure that you cannot do it.

In this case i would create as many arrays as you need (1 per sprite) and then just get and put in the loop accordingly (it will also be easier to keep track of them)

Dr_Davenstein
QBasic God
Posts:166
Joined:Tue Mar 25, 2003 12:45 am
Location:U.S.A.
Contact:

Post by Dr_Davenstein » Thu Mar 24, 2005 8:05 am

You can do that, but you have to dim the array this way... ;)

Code: Select all

DEFINT A-Z


SCREEN 13

Sprite.X.Width = 32
Sprite.Y.Width = 32
Sprite.Len = ((Sprite.X.Width * Sprite.Y.Width) / 2) + 1
Sprite.Total = 16



DIM Sprite.Array(Sprite.Len, 1 TO Sprite.Total)




FOR Sz = 1 TO Sprite.Total
   FOR Y = 0 TO Sprite.Y.Width - 1
      FOR X = 0 TO Sprite.X.Width - 1
         PSET (X, Y), 16 + INT(RND * 16)
      NEXT
  NEXT
  GET (0, 0)-(Sprite.X.Width - 1, Sprite.Y.Width - 1), Sprite.Array(0, Sz)
NEXT

CLS
X = 0

DO
   FOR Sz = 1 TO Sprite.Total
      Radian! = Radian! + .01
      PUT (144 + 64 * SIN(Radian!), 84 + 64 * COS(Radian!)), Sprite.Array(0, Sz), PSET
      WAIT &H3DA, 8, 8
      WAIT &H3DA, 8
   NEXT
LOOP WHILE INKEY$ = ""

Come check out [url=http://www.freebasic.net/forum/index.php]FreeBASIC[/url]. The syntax is based on QuickBasic, but it expands to use pointers, operator overloading, etc... The list goes on and on!

Post Reply