Java-Gaming.org
Java4K winners:
[
by our judges
|
by the community
]
Featured games (67)
games approved by the League of Dukes
Games in Showcase (∞)
games submitted by our members
News
: Read the
Java Gaming Resources
, or peek at
the official Java tutorials
Home
Help
Search
Login
Register
Java-Gaming.org
>
Game Development
>
Newbie & Debugging Questions
>
Slope Help!
Pages: [
1
]
Print
Slope Help!
(Read 450 times)
0 Members and 1 Guest are viewing this topic.
Shin_Bet
JGO n00b
Posts: 14
Slope Help!
«
on:
2006-01-18 19:46:39
»
Hi, im making a game and i need some help in calculating some slope stuff.
i basically have two points, and i want to draw a ball travelling between the two. I used Y = mX + b...But when the X points start becoming similar this method goes to pot. It also has differnet speeds depending on where you shoot. Any help is appreciated, thanks.
noblemaster
JGO Ninja
Posts: 730
Medals: 6
Age of Conquest makes your day!
Re: Slope Help!
«
Reply #1 on:
2006-01-18 20:26:56
»
Your question is not so clear, but let me give it a try!
Let's assume your 2 points are given as (x0, y0) and (x1, y1).
The x and y distances are given as:
dx = x1 - x0;
dy = y1 - y0;
The total distance is (Pytagoras):
d = Math.sqrt(dx * dx + dy * dy);
So, to move with constant speed from (x0, y0) to (x1, y1) you have to
define a speed, e.g.
speed = 5;
Let's assume your current position is given as x and y. For each time step, you apply
the following transform:
x = x + dx * speed / d;
y = y + dy * speed / d;
[
Twitter
|
Blog
|
Noble Master
]
Pages: [
1
]
Print
Jump to:
Please select a destination:
-----------------------------
Games Center
-----------------------------
=> Featured Games
=> Showcase
=> Contests
===> LWJGL16k - 2011
===> 4K Game Competition - 2012
===> JGO Comp Petite
===> Finished Contests
=====> 4K Game Competition - 2011
=====> 4K Game Competition - 2010
=====> 4K Game Competition - 2009
=====> 4K Game Competition - 2008
=====> 4K Game Competition - 2007
=====> 4K Game Competition - 2006
=====> 4K Game Competition - 2005
=====> Tiny Game 2010
=====> JGO Comp 2009
=====> 16K LWJGL Competition - 2005
=====> Java Technology Game Development Contest - 2004
-----------------------------
Discussions
-----------------------------
=> General Discussions
===> Suggestions
=> Business and Project Discussions
===> Jobs and Resumes
===> Community & Volunteer Projects
=> Miscellaneous Topics
-----------------------------
Game Development
-----------------------------
=> Newbie & Debugging Questions
=> Articles & tutorials
=> Game Play & Game Design
=> Game Mechanics
===> Artificial Intelligence
=> Networking & Multiplayer
=> Performance Tuning
=> Shared Code
-----------------------------
Java Game APIs & Engines
-----------------------------
=> Engines, Libraries and Tools
===> Java 3D
===> JInput
===> jMonkeyEngine
===> Xith3D Forums
===> Tools Discussion
=> Java 2D
===> JavaFX
=> OpenGL Development
===> JOGL Development
===> LWJGL Development
=> Java Sound & OpenAL
===> JOAL Development
=> Java on Mobile Devices
===> Android
===> J2ME
Loading...