[phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 264: mysqli_fetch_assoc(): Couldn't fetch mysqli_result [phpBB Debug] PHP Warning: in file [ROOT]/phpbb/db/driver/mysqli.php on line 326: mysqli_free_result(): Couldn't fetch mysqli_result Sprite flicker problem - Pete's QBASIC Site
Okay folks, I'm going to be working on a game with sprites in screen 13. I wrote a short program to practice the techniques on, but I get flicker. I've read that to get rid of flicker you use the WAIT &h3da, 8 line, but it didn't help me. In fact, when I used the above line once before the sprite PUT and once before the background PUT (sprite erase), it make the sprite look positively translucent while it was moving!
So basically what I want to know is: a) am I using this method correctly? or b) is there another method I should be using?
DIM sprite(515) AS INTEGER
SCREEN 13
RANDOMIZE TIMER
LINE (0, 0)-(15, 31), 12, BF
GET (0, 0)-(15, 31), sprite(0)
CLS
FOR lines = 1 TO 255
x1 = INT(RND * 320): y1 = INT(RND * 200)
x2 = INT(RND * 320): y2 = INT(RND * 200)
LINE (x1, y1)-(x2, y2), lines
NEXT lines
x = 150: y = 80
DO
oldX = x: oldY = y
GET (x, y)-(x + 15, y + 31), sprite(258)
WAIT &H3DA, 8
PUT (x, y), sprite(0), PSET
DO: k$ = INKEY$: LOOP WHILE k$ = ""
IF k$ = "4" THEN
x = x - 2: IF x < 0 THEN x = 320 - 16
END IF
IF k$ = "6" THEN
x = x + 2: IF x > 320 - 16 THEN x = 0
END IF
IF k$ = "8" THEN
y = y - 2: IF y < 0 THEN y = 200 - 32
END IF
IF k$ = "2" THEN
y = y + 2: IF y > 200 - 32 THEN y = 0
END IF
PUT (oldX, oldY), sprite(258), PSET
LOOP UNTIL k$ = CHR$(27)
SYSTEM
Daniel "Theophage" Clark
theophage (at) geocities (dot) com
"God used to be my co-pilot, but our plane crashed in the mountains and I had to eat Him..."
DIM sprite(515) AS INTEGER
SCREEN 13
RANDOMIZE TIMER
LINE (0, 0)-(15, 31), 12, BF
GET (0, 0)-(15, 31), sprite(0)
CLS
FOR lines = 1 TO 255
x1 = INT(RND * 320): y1 = INT(RND * 200)
x2 = INT(RND * 320): y2 = INT(RND * 200)
LINE (x1, y1)-(x2, y2), lines
NEXT lines
x = 150: y = 80
DO
oldX = x: oldY = y
GET (x, y)-(x + 15, y + 31), sprite(258)
PUT (x, y), sprite(0), PSET
DO: k$ = INKEY$: LOOP WHILE k$ = ""
IF k$ = "4" THEN
x = x - 2: IF x <0> 320 - 16 THEN x = 0
END IF
IF k$ = "8" THEN
y = y - 2: IF y <0> 200 - 32 THEN y = 0
END IF
WAIT &H3DA, 8
PUT (oldX, oldY), sprite(258), PSET
LOOP UNTIL k$ = CHR$(27)
SYSTEM
Thanks Nixon. It's better, but there's still some flicker going on, especially when I hold down a key to move continuously. Is there nothing I can do about that?
Daniel "Theophage" Clark
theophage (at) geocities (dot) com
"God used to be my co-pilot, but our plane crashed in the mountains and I had to eat Him..."
hmm thats odd because I'm not getting any flicker when I move it. Sorry but I can't really help if I can't see the problem. I would suggest to just try moving things around in your code. You should be able to get rid of it.
DIM sprite(515) AS INTEGER
SCREEN 13
RANDOMIZE TIMER
LINE (0, 0)-(15, 31), 12, BF
GET (0, 0)-(15, 31), sprite(0)
CLS
FOR lines = 1 TO 255
x1 = INT(RND * 320): y1 = INT(RND * 200)
x2 = INT(RND * 320): y2 = INT(RND * 200)
LINE (x1, y1)-(x2, y2), lines
NEXT lines
x = 150: y = 80
GET (x, y)-(x + 15, y + 31), sprite(258)
PUT (x, y), sprite(0), PSET
DO
DO
DO: k$ = INKEY$: LOOP WHILE k$ = ""
LOOP WHILE INSTR("2468" + CHR$(27), k$) = 0
if k$=chr$(27) then exit do
Newx=x: Newy=y
SELECT CASE VAL(k$)
CASE 4: Newx = x - 2: IF Newx < 0 THEN Newx = 320 - 16
CASE 6: Newx = x + 2: IF Newx > 320 - 16 THEN Newx = 0
CASE 8: Newy = y - 2: IF Newy < 0 THEN Newy = 200 - 32
CASE 2: Newy = y + 2: IF Newy > 200 - 32 THEN Newy = 0
END SELECT
WAIT &H3DA, 8
PUT (x, y), sprite(258), PSET
x=Newx: y=Newy
GET (x, y)-(x + 15, y + 31), sprite(258)
PUT (x, y), sprite(0), PSET
WAIT &H3DA, 8,8
LOOP
SYSTEM
Since Mac rebuked me in the other thread for not giving proper acknowledgement, I thought I would make it known that I hadn't gotten as far as implementing his change to my program since I completely changed how my program was going to work. I started the other thread because I hadn't even gotten the revised program far enough to worry about flicker again before running into a problem.
When I do get that far, I will adopt Mac's solution (which seems to be placing the WAIT statement before every PUT) and post the results here. Thank you all for your patience (or lack thereof...)
Daniel "Theophage" Clark
theophage (at) geocities (dot) com
"God used to be my co-pilot, but our plane crashed in the mountains and I had to eat Him..."
[quote="Theophage"]Mac's solution (which seems to be placing the WAIT statement before every PUT)[/quote]
My suggestion, in words, rather than code, is to put
WAIT &H3DA, 8
before you start messing with the screen and
WAIT &H3DA, 8,8
after you are finished.
If you never come back to see this thread, fine. Maybe some researcher of the future will see this hint.