Featured games (91)
games approved by the League of Dukes
Games in Showcase (579)
games submitted by our members
Games in WIP (500)
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 2076 times)
0 Members and 1 Guest are viewing this topic.
Offline alesky

Junior Member

Medals: 2


« Posted 2012-10-19 02: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

Offline Orangy Tang

JGO Kernel

Medals: 51
Projects: 11

Monkey for a head

« Reply #1 - Posted 2012-10-19 13: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:

Bezier curves are a nice simple one to start with:

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

[ - Play Growth Spurt, Rescue Squad and Snowman Village ] [ Rebirth - game resource library ]
Offline Varkas
« Reply #2 - Posted 2012-10-19 14: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.

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):
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline alesky

Junior Member

Medals: 2


« Reply #3 - Posted 2012-10-22 19: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

Offline delt0r

JGO Coder

Medals: 22

Computers can do that?

« Reply #4 - Posted 2012-10-22 20: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 Member

Medals: 2


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

hi delt0r

your solution look like very interessing..
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 Coder

Medals: 22

Computers can do that?

« Reply #6 - Posted 2012-10-23 11: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.

xsi3rr4x (37 views)
2014-04-15 18:08:23

BurntPizza (33 views)
2014-04-15 03:46:01

UprightPath (49 views)
2014-04-14 17:39:50

UprightPath (31 views)
2014-04-14 17:35:47

Porlus (48 views)
2014-04-14 15:48:38

tom_mai78101 (69 views)
2014-04-10 04:04:31

BurntPizza (129 views)
2014-04-08 23:06:04

tom_mai78101 (229 views)
2014-04-05 13:34:39

trollwarrior1 (193 views)
2014-04-04 12:06:45

CJLetsGame (200 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30 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‑
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!