PDA

Click to See Complete Forum and Search --> : Two Begginer Questions


joey o.
Dec 14th, 2000, 12:37 PM
I've been doing VB for a few years but only recently have I decided to explore VB's gaming possibilities. I need examples for the following issues to help me get started.

1.I want a function to select a point, a distance from it, and orbit a pixel around it at that distance. Similiar to the circle function.

2.I've got a small black square in the middle of my screen with lines connecting the cornors with coresponding conors of the screen to give a tunnel affect. How do I get the side walls to give the illusion of the user moving into the tunnel?

Thanks in Advance,
Joey O

kedaman
Dec 15th, 2000, 01:43 AM
Here's for having a point orbiting a pixel at a constant distance:
http://forums.vb-world.net/showthread.php?threadid=44426
To give the illusion of moving into a tunel, with a constant speed, you probably need more walls, but for the moment and for a single wall(you can do this for all walls) is a line with two points, and each points moves away from the center of the tunnel exponentially.

How to do it is to first get the distance d to the center:

dy=(poiny-centery)
dx=(pointx-centerx)
d=sqr(dy*dy+dx*dx)

then you offset the pixel by a constant fraction of the distance, which is called speed:

pointy=pointy+(pointy-centery)*speed
pointx=pointx+(pointx-centerx)*speed

note that speed has to be a very small fraction, for instance 0.02 to give a realistic effect.
Now you repeat this for both points in all lines, and then repeat everything and you have a tunnel animation.