Path: chuka.playstation.co.uk!scea!greg_labrec@interactive.sony.com From: "John Emmer" Newsgroups: scea.yaroze.programming.2d_graphics Subject: Sprite/OT trouble Date: 2 Aug 1997 19:10:52 GMT Organization: Justice Center Lines: 64 Message-ID: <01bc9f6f$da300e60$37f135ce@jjustice.iquest.net> Reply-To: "John Emmer" NNTP-Posting-Host: and-000-23.iquest.net X-Newsreader: Microsoft Internet News 4.70.1161 Here's my main display loop: while(!(padValue&PAD1_SELECT)) { padValue = PadRead(); activeBuff = GsGetActiveBuff(); GsSetWorkBase((PACKET*)GpuPacketArea[activeBuff]); GsClearOt(0,0,&WorldOT[activeBuff]); // register sprites in OT (just players for now) for (i = 0; i < 2; i++) { GsSortSprite(&(player[i].tank.turret.turretSprite), &WorldOT[activeBuff],0); GsSortSprite(&(player[i].tank.tankSprite), &WorldOT[activeBuff],1); } // add a dummy tank because last sprite is not displaying GsSortSprite(&(computer[0].tank.tankSprite),&WorldOT[activeBuff],0); DrawSync(0); VSync(0); GsSwapDispBuff(); GsSortClear(255,255,255,&WorldOT[activeBuff]); GsDrawOt(&WorldOT[activeBuff]); } And here are my questions: A couple of weird things are happening. I want the turrets to display over the tanks, so I set the priority of the tanks to 1 and the turrets to 0. (My OT length is currently 4). For some reason, if I swap the order of the two lines inside the for loop, the screen gets garbage. In their current order it works. I know "Doctor, it hurts when I put them in this order" "If it hurts, don't do it!" - but I want to understand _why_ this makes a difference. Secondly, as you see from the comment after the for loop, the fourth sprite doesn't display (actually, it flickers on for a fraction of a second every now and then). I figured it had something to do with the timing, so I added a fifth sprite that I don't currently care about, so that the fifth one wouldn't display instead of the fourth one that I do want. But why isn't the fourth sprite displaying? Finally, both of these problems go away if I run the program stepwise through the CodeWarrior Debugger. This suggests to me even more strongly that the problem has to do with timing. But I have my DrawSync(0) and VSync(0) in there, and the rest of my code looks like the examples I've seen (thanks Shadow and Mario!) as far as I can tell. What's up? Thanks! -- John Emmer Video Game Enthusiast, Philosopher, Fledgling Programmer jjustice@cs.bsu.edu jjustice@iquest.net jpemmer@bsuvc.bsu.edu Vectrex; 7800, Supercharger, Lynx, Jaguar; NES, SNES, Virtual Boy; Turbo Duo & Express; SG, SGCD, 32X, Saturn; 3DO; PlayStation, Yaroze; C64, A600, A1200, P100; Arcade Centipede, Spy Hunter, Neo-Geo; BA, MA, ABD