Sprite help 
Author Message
 Sprite help

Does anyone out there have a program on flipping sprites (or any
art) over the y-axis (a thing that looks like this  :) will look like (:
this)?



Tue, 17 Oct 2000 03:00:00 GMT  
 Sprite help

I don't have a program, but I could theory one out for ya real quick... :)

Here's the idea:  You have a sprite image on the screen, which is nothing more
than a bunch of numbers (color values) stored in specific memory locations
(screen memory).  Therefore, you could store the entire sprite (provided it
isn't too big...) in a 2 dimension array.  You do that like so...

DIM sprite%(xspritesize%,yspritesize%)
(where xspritesize% and yspritesize% are your sprite width and height)

Then, copy the color values into the array likeso...
for i%=xstart% to (xstart%+xspritesize%)
   for j%=ystart% to (ystart%+yspritesize%)
      sprite%((i%-xstart%),(j%-ystart%))=point(i%,j%)
   next j%
next i%

This looks a little complicated, but it is designed to work regardless of the
sprite screen position.  The xstart% and ystart% variables represent where the
top left corner of the sprite image is on your screen. POINT reads the color of
the pixel at a specific screen location.  

So, now you have the sprite stored in your array.  In order to play around with
it, you simply loop through the array in different orders.  So, in order to
display the sprite flipped vertically, you'd step through in the negative
direction to get your y value from the array.

for i%=xstart% to (xstart%+xspritesize%)
   for j%=ystart% to (ystart%+yspritesize%)
      colour%=sprite%(i%-xstart%,yspritesize%-(j%-ystart%))
      pset (i%,j%),colour%
   next j%
next i%

Tada!

This should work, but it might need soe fine tuning for you.  If the math seems
a bit complicated, I recommend listing out your variables on paper and track
each through a few loops.  It should start to make sense after a few
iterations.

Good luck!
Brian



Tue, 17 Oct 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Sprite Help

2. Sprite.Begin and Sprite.End

3. How to clear a sprite without clearing all the sprites from a picturebox

4. Sprite blitter help

5. Sprite Blitting Help

6. Need help to add sprite to fishtank

7. Need Help: Rotating Sprites

8. Sprite Mask ! help

9. help drawing sprites over background

10. Help with Pcopy and sprite animation?

11. Help - Qbasic code for putting and animating sprites on background

12. More Help On Sprite Moving

 

 
Powered by phpBB® Forum Software