Java-Gaming.org Hi !
Featured games (81)
games approved by the League of Dukes
Games in Showcase (513)
Games in Android Showcase (119)
games submitted by our members
Games in WIP (576)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  Tracking 2D objects on a path / pre-determined movement  (Read 2389 times)
0 Members and 1 Guest are viewing this topic.
Offline alesky

Junior Duke


Medals: 3
Exp: 15 years


mmm....


« Posted 2012-10-19 00:00:01 »

I guys
i have crated a side scrolling space shooter game.

the enemy of my games has all a very basic movement (left to right, go directly to the player etc...), and before to start to reinvent the wheel, i would like to know whot are good stategies to create more complicated object movement.

I'd like to have enemy them perform more movements  such as moving down the screen, go to left  go up again etc...
I belive that I have to create a Path and iterate on it during the update logic of the enemy Sprite.

My question is if someone of you know same resource that i can use to study at list the basic of the path creation and iteration
or if you can share with me your strategy to give me some idea, or you know if there are already some implementation that i could use to do it
thanks



Offline Orangy Tang

JGO Kernel


Medals: 56
Projects: 11


Monkey for a head


« Reply #1 - Posted 2012-10-19 11:48:17 »

You probably want to define your paths as splines, and move your enemies along them at a fixed rate. Pick something from here and implement it is a good starting point: http://en.wikipedia.org/wiki/Category:Splines

Bezier curves are a nice simple one to start with: http://en.wikipedia.org/wiki/B%C3%A9zier_curve

But you may want to progress to something more complicated depending on what your movement should look like.

[ TriangularPixels.com - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Varkas
« Reply #2 - Posted 2012-10-19 12:13:29 »

Splines are very useful, indeed. If you want to do more research, check he general idea of "parametric curves".

Generally they work like (x,y) = f(p), and give you the position on the curve for p in [0..1] (or any other interval, but usually normalized). If you modulate the step size of p, you can speed up/ slow down your object while they follow the curve. You can also have sequences of curves that the objects will follow, but if you use splines you can make one spline with all twists and turns.

http://en.wikipedia.org/wiki/Parametric_equation

There are also examples for 3D curves and parametric surfaces there.

Edit: If you find a way to make splines from random parameter sets, you'll have a shooter where even you as creator can't predict the enemies, and it will be a constant challenge even for yourself Grin

if (error) throw new Brick(); // Blog (german): http://gedankenweber.wordpress.com
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline alesky

Junior Duke


Medals: 3
Exp: 15 years


mmm....


« Reply #3 - Posted 2012-10-22 17:22:41 »

thanks guys for your suggestion!  Smiley

I create my implementation that i shared with the guys that will need it
this is the link  Pointing

http://www.java-gaming.org/topics/static-path-builder-object-for-2d/27600/view.html

Offline delt0r

JGO Knight


Medals: 27
Exp: 18 years


Computers can do that?


« Reply #4 - Posted 2012-10-22 18:54:41 »

In my game i use Cubic Hermite splines. I also need to move along the curve at constant "speed" ie t needs to be parametrized in terms of cord length. I found that using a 2nd order Gaussian quadrature was more than accurate enough just to create approximate "look up table" of distance vers t. All my unit movement uses this rather than "true physics". Yet it gives the illusion of being a full physics model, while permitting easy "move here via there" control.

I have no special talents. I am only passionately curious.--Albert Einstein
Offline alesky

Junior Duke


Medals: 3
Exp: 15 years


mmm....


« Reply #5 - Posted 2012-10-23 08:48:27 »

hi delt0r

your solution look like very interessing..
Quote
In my game i use Cubic Hermite splines. I also need to move along the curve at constant "speed"

actually my implementation suffers exactly of an indeterminant speed long the segment of the bspline created.

can I see some snippets of code or discuss with you about the implementation of this solution?
i would try to add also this algorithm to my implementation and sahre to all the guys in the forum.

Offline delt0r

JGO Knight


Medals: 27
Exp: 18 years


Computers can do that?


« Reply #6 - Posted 2012-10-23 09:20:05 »

Currently the code is not very tidy. But i sure don't mind sharing. I will try to do so by the end of the day.
[edit] Also i am on irc #lwjgl.

I have no special talents. I am only passionately curious.--Albert Einstein
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Longarmx (45 views)
2014-10-17 03:59:02

Norakomi (36 views)
2014-10-16 15:22:06

Norakomi (27 views)
2014-10-16 15:20:20

lcass (31 views)
2014-10-15 16:18:58

TehJavaDev (61 views)
2014-10-14 00:39:48

TehJavaDev (61 views)
2014-10-14 00:35:47

TehJavaDev (51 views)
2014-10-14 00:32:37

BurntPizza (69 views)
2014-10-11 23:24:42

BurntPizza (39 views)
2014-10-11 23:10:45

BurntPizza (81 views)
2014-10-11 22:30:10
Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!