dmg@ssc-vax.UUCP (David Geary) (01/06/88)
I am writing my own version of Arkanoid in C. Everything works great, except for the fact that I cannot make my boxes completely disappear when the ball collides with a box. My paddle and ball are both bobs. My boxes are not bobs, I simply use DrawImage() and RectFill() to create them at the beginning of the game. Then, when the ball collides with a box, I call RectFill(), to blank out the box that was hit. Sometimes, the entire box gets blanked (as it should). However, most of the time, only part of the box gets blanked out. There is seemingly no pattern to when the box gets blanked or not. I have a forever loop which calls SortGList(), DrawGList(), MakeScreen(), and RethinkDisplay(), and then goes on to check for collisions, make adjustments if collisions are detected, and move any objects which need to be moved. Then the loop goes back to the top. I have a feeling that something to do with animation is not letting my RectFill() command finish. I am not using any Animcomp's or Animob' s, just bobs. I have no idea if my thinking here is correct. This is driving me nuts! I' ve tried everything I can think of to correct the problem, namely: 1) Use DrawImage() or WritePixel() repeatedly instead of RectFill(). 2) Move the RectFill() call nearer to the top of the forever loop. 3) Call WaitTOF() before the RectFill(), and WaitBOVP() afterwards. 4) Call MakeScreen() and RethinkDisplay() after RectFill(). 5) Call LockLayerInfo() before RectFill(), and UnlockLayerInfo() afterwards. This has an interesting effect. The box gets blanked correctly, but then the program S T O P S. No guru, no nothing. It just sits until I reboot. Obviously, none of the above worked, or I would not be posting this message. I have no idea what to do next. Can someone please help? I've spent over 100 hours on this thing, and I' m very close to being finished (if i could just make the boxes disappear). I have considered not using the animation routines (that means not using bobs), and using the Layers library to do my own animation, but what a pain that would be just to get the stupid boxes to disappear. Thanks in advance for the help. . -- *********************************************************** * David Geary, Boeing Aerospace Co., Seattle, WA * * (206)773-5249. --I disclaim everything I've ever said--* ***********************************************************
rap@dana.UUCP (Rob Peck) (01/08/88)
In article <1603@ssc-vax.UUCP>, dmg@ssc-vax.UUCP (David Geary) writes: > I am writing my own version of Arkanoid in C. Everything works great, > except for the fact that I cannot make my boxes completely disappear > when the ball collides with a box. > > My paddle and ball are both bobs. My boxes are not bobs, I simply > use DrawImage() and RectFill() to create them at the beginning > of the game. Then, when the ball collides with a box, I call > RectFill(), to blank out the box that was hit. Sometimes, the > entire box gets blanked (as it should). However, most of the > time, only part of the box gets blanked out. There is seemingly > no pattern to when the box gets blanked or not. The most likely problem here is that when the collision is sensed, the bob is ever so slightly covering the other onscreen object that is not a bob. The way bobs work in the first place is to save the background area that they will cover, then blit the bob image in place. When the bob is to be moved, the background image is restored to what it was before the bob was there and the bob is moved to a new location where the process is repeated. What is most likely is that the RectFill happens between drawing bobs and moving them to a new location. Therefore the bob remembers what was underneath it and naturally puts it back. Most probably these are small bob-bite chunks you have left over when this happens. Related problem: the docs for the collision detection routines state something like "collisions between objects not handled completely correctly". As I understand it, collisions with borders are ok, (on the left and right, that is) because the border mask is used to detect the collisions. But it still means that only when there is at least a 1 pixel overlap that a collision will be detected. Collisions with tops and bottoms of objects are handled not quite so well - someone (was it you) had contacted me about a PONG-ish game in which if the ball hit the paddle from the side, all went well (as noted above because of sidehits ) but if the ball hit the paddle from the top, well sometimes the ball would appear to hit the top surface and sometimes go most of the way through the paddle before the hit was detected. This I believe is part of the "not completely handled correctly" business in that the scrunched image of the bob (single line border collision mask) is what is being used in the built-in collision routines, at some specific y-location within the bob itself. My suggested solution(s): 1. Write your own collision detection routines, and 2. When a collision occurs, then you may have to do something else... a. If the object is to bounce off of the box that is blows up, then once the collision is detected, set a flag that says blow away this box after the object moves away enough so that there is no longer a collision detected. This says that the object will no longer remember any piece of the box and it will be safe to RectFill it away. b. If the object is to move through the box that it blows away, you'll have to do a bit more work: remove the object itself from the GList, rerender the bobs (SortGList(), DrawGList()), blast the rectangle, then add the object to the list and render the bobs again. Only then will the background be as it should be. Then again, the entire of the above may be a bunch of mungo and the RectFill might be coming in the middle of a mass of queued QBlits that the Gel functions are performing. But I suspect I am correct. Rob Peck ...ihnp4!hplabs!dana!rap