Drawing Sprites

by Ben (Login qben1)

Hi,

I am a new to QBasic and I have trouble loading a sprite
from DATA statements. I am trying to get the data with the
READ statement then I want to put all the data in an array,
but I can only put it in backwards (line 19, line 21). The POKE
statement is not drawing the sprite properly. I haven't used the
POKE statement alot so maybe I'm using it wrong?

How could I make this program work.
(Also, don't tell me that FUNCTIONs are better
then FnFunctions.)

Thanks,
Ben

'*** START ***
DEFINT A-Z

DEF FnBIN2DEC& (binary$)

DIM ex AS LONG

ex = LEN(binary$)

FOR i = 1 TO LEN(binary$)

IF MID$(binary$, i, 1) = "1" THEN sum& = sum& + 2 ^ ex / 2

ex = ex - 1

NEXT

FnBIN2DEC& = sum&

END DEF

DIM bytes(11) AS STRING * 8

SCREEN 12

DEF SEG = &HA000

FOR y = 1 TO 11

FOR x = 1 TO 8

READ z

IF z <> 0 THEN

bytes(y) = "1" + bytes(y) 'line 19

ELSE

bytes(y) = "0" + bytes(y) 'line 21

END IF

NEXT

POKE y * 80&, FnBIN2DEC&(bytes(y))

NEXT
SYSTEM

DATA 0,0,0,0,0,0,0,0

DATA 0,0,0,0,0,0,0,0

DATA 0,0,0,0,0,0,0,0

DATA 0,1,1,1,1,1,1,0

DATA 1,0,0,0,0,0,1,1

DATA 0,1,1,1,1,1,1,1

DATA 1,1,0,0,0,0,1,1

DATA 1,1,0,0,0,0,1,1

DATA 0,1,1,1,1,1,1,0

DATA 0,0,0,0,0,0,0,0

DATA 0,0,0,0,0,0,0,0

'*** END ***

Posted on Jul 20, 2008, 11:50 AM

Respond to this message   

Goto Forum Home


Response TitleAuthor and Date
It works fine if you PSET it... on Jul 20
 If I'm not mistakenlkt153 on Jul 20
  Hey, lkt153, very interesting -- quick question... on Jul 20
   Hmmm on Jul 20
    *Thanks Artelius -- I appreciate the warning -- I won't advertise the method. on Jul 20
    * AND is exactly what it does, I didn't know about the palette loss part, though.lkt153 on Jul 21
  * Don't use OUT for that! POKE should not cause any damage however on Jul 20
 * I'm trying to use POKE instead of PSET for practiceBen on Jul 20
  *Then POKE in SCREEN 13 all you want on Jul 20
  There's a FAQ about POKEing SCREEN 12 (*URL) on Jul 20
 Re: It works fine if you PSET it...Ben on Jul 20
  Ok then... on Jul 20