EDIT: I'm editing this post as even though it's notched up a few views no-one has yet replied. If I could just ask whether it's because I've posted this in the wrong forum, whether the problem is too hard, whether I haven't described the problem very well or if this kind of problem isn't the kind of thing that should be asked in these forums? Any response is much appreciated.
Hi,
I'm looking for some help for a computer game I am trying to write and not having done much in the way of complex math (when I say complex I mean anything more complicated than checking my credit card statement) for about 15 years my math is a little rusty - seems trial and error isn't a good way to go when trying to solve math problems! Anyway my frustration and ineptitude have got the better of me and I came across this forum in my search for help.
The easiest way to describe what I'm doing (or trying to do) is to have objects travel from the top of the screen to the bottom in the same way that the notes in Guitar Hero do. i.e. They not only travel down, but also out from the center to give the effect of perspective.
The screen has the dimensions of 800 pixels across by 450 down with the objects traveling down a "road" (or fretboard for Guitar Hero aficionados) that is placed in the horizontal center of the screen. The road is 200 pixels wide at the top widening to 800 at the bottom. While the horizontal center of the road is located at 400 pixels I have decided to refer to it as 0 (x position = x position - 400) since any object placed to the left of this point falls down and to the left, anything placed to the right of this point falls down and to the right, and any object placed directly at the center (0) will fall straight down.
The initial position of the objects are y:1 and x:random number between -100 and 100. I have the objects falling down in a straight line by calculating the next y position using NEXTy = OLDy * 1.2 This makes the object fall faster as it gets closer to the bottom, which is what I want so as to give the effect of getting closer.
What I need help in is creating a formula that calculates the NEXTx position as well. I'm guessing it will involve using the initial x position somewhere as it is this value (how far it is from the center) that will determine how sharp the angle the object will fall at and also the y position somewhere as well.
I hope I've explained my problem ok. Here's a few examples just to help clarify:
An object placed at (x,y) (50, 1) will fall in a straight line to (200, 450).
An object placed at (x,y) (-50, 1) will fall in a straight line to (-200, 450).
An object placed at (x,y) (100, 1) will fall in a straight line to (400, 450).
An object placed at (x,y) (-100, 1) will fall in a straight line to (-400, 450).
An object placed at (x,y) (0, 1) will fall in a straight line to (0, 450).
So the information I have is:
Initial x position of the object.
Initial y position of the object.
Next y position of the object.
And what I need is a formula that calculates the Next x position of the object.
Any help would be MUCH appreciated.
I know I've rambled on a lot compared to other problems on this site but I just wanted to make sure I was being clear and I'm not sure how to get my problem across in mathematical terms - I hope you'll forgive me. I also hope I've posted this in the correct forum. If not, let me know.
Thanks.
PS. If it makes it easier I can shorten the height of the playing area from 450 to 400 pixels.


LinkBack URL
About LinkBacks

