2D Rotation 
Author Message
 2D Rotation

I'm trying to write a game in QuickBasic that uses 2D sprite rotation.  
I found the generic x=radius*cos(angle) method, which worked fine on one
point, but when I tried to use it on each point of an array (ie. a 9x9
array, each element being a pixel) it would flip the sprite by the x and
y axis instead of rotating.

Here's what I used:

screen 13

dim sprite(9,9)

[code to put stuff in sprite goes here]

do

for y = 1 to 9
        for x = 1 to 9
                dx = (x - 5) * cos(angle * PI / 180)
                dy = (y - 5) * sin(angle * PI / 180)
                pset (160 + dx, 100 + dy), sprite(x,y)
        next x
next y

angle = angle + 1
if angle = 360 then angle = 0

loop while inkey$ = ""

Can someone tell me what I'm doing wrong?

Thanks,
Alex



Sun, 30 Apr 2000 03:00:00 GMT  
 2D Rotation

Quote:

>I'm trying to write a game in QuickBasic that uses 2D sprite rotation.  
>I found the generic x=radius*cos(angle) method, which worked fine on one
>point, but when I tried to use it on each point of an array (ie. a 9x9
>array, each element being a pixel) it would flip the sprite by the x and
>y axis instead of rotating.

I wrote an article on 2D graphics rotation in Basix Fanzine Issue 9. You can
download it (a text file) from:

  http://www.users.globalnet.co.uk/~dewarr/basix.htm

Hope that helps,

Alex Warren,
Buckinghamshire, England


icq:   4043750

_______________________________________________________________________

WEBSITE:   http://www.users.globalnet.co.uk/~dewarr/

See the website for CyPet _ a virtual pet for Win95, MOD music files
for ST3 and IT, The BASIX Fanzine _ a magazine for programmers of
BASIC, QuickBASIC Programs, +++ more!
_______________________________________________________________________



Tue, 02 May 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. FAST 2D Rotation code

2. 2D rotation problem

3. Matrix rotation

4. Text Block rotation in a line.

5. Tracking shape position and rotation WHILE moving

6. Table Rotation

7. Image Rotation

8. getting the region of a usercontrol ? (for rotation)

9. page rotation

10. 3D Rotation Points

11. 3d rotation's

12. 3D rotation

 

 
Powered by phpBB® Forum Software