Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (527)
Games in Android Showcase (127)
games submitted by our members
Games in WIP (593)
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  
  Image following line  (Read 2525 times)
0 Members and 1 Guest are viewing this topic.
Offline MindOfCorruption97

Senior Newbie





« Posted 2012-09-29 02:16:23 »

Hi, I have a question about Images. Is there a way to make an image trace/follow a line? If so, can you please explain on how to do it? I want know how to make the image trace a line from point A to point B.

Chaos is Beatiful...
For without Chaos the world will never spin...
Offline Vladiedoo
« Reply #1 - Posted 2012-09-29 03:20:56 »

Reading parts of this might help you http://www.java-gaming.org/index.php?topic=25402.0. I have yet to add this feature myself so that is all I can provide, good luck!
Offline ReBirth
« Reply #2 - Posted 2012-09-29 12:35:19 »

Or you meant follow complex line like tower defense, with all of that curves?

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Roquen
« Reply #3 - Posted 2012-09-29 13:18:34 »

direction of line: D=|B-A|
parameterize:  F(t) =Dt+A
where 't' is on [0,1]

brain-dump untested pseudocode:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
public void setup(Vect2f a, Vect2f b)
{
  // store initial point
  x0 = a.x;
  y1 = a.y;

  // compute and store direction of line
  dx = b.x-x0;
  dy = b.y-y0;

  // compute and store length of the line segment
  len = (float)(Math.sqrt(dx*dx+dy*dy));

  // normalize direction
  float t = 1.f/len;
  dx *= t;
  dy *= t;
}

/** Set 'r' to the blah, blah and returns 'r'. */
public Vect2f position(Vect2f r, float t)
{
  r.x = x0 + t*dx;
  r.y = y0 + t*dy;
 
  return r;
}
Offline MindOfCorruption97

Senior Newbie





« Reply #4 - Posted 2012-09-29 23:48:37 »

I meant more of, just following a straight line.

Chaos is Beatiful...
For without Chaos the world will never spin...
Offline Phased
« Reply #5 - Posted 2012-09-30 01:43:31 »

Just set the y to a number and never change the y, but every update add to the x of the image.

If you want it to go up add to the y instead of the x.
Sorry if any spelling mistakes I'm on my phone
Offline ReBirth
« Reply #6 - Posted 2012-09-30 02:45:13 »

Never change X -> vertical move.
Never change Y -> horizontal move.

Offline Roquen
« Reply #7 - Posted 2012-09-30 07:44:04 »

I meant more of, just following a straight line.
All lines are straight. Smiley
Offline Jimmt
« League of Dukes »

JGO Kernel


Medals: 139
Projects: 4
Exp: 3 years



« Reply #8 - Posted 2012-09-30 15:45:50 »

Yeah I think he means any line not just vertical/horiz lines.
Offline MindOfCorruption97

Senior Newbie





« Reply #9 - Posted 2012-10-01 01:07:53 »

Yeah I think he means any line not just vertical/horiz lines.
Yea, that's what I was asking for. I understand how to make Vert and Horiz lines, just wondering how to make an image follow a line that has a certain amount of degrees to it.

Chaos is Beatiful...
For without Chaos the world will never spin...
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.

PocketCrafter7 (12 views)
2014-11-28 16:25:35

PocketCrafter7 (7 views)
2014-11-28 16:25:09

PocketCrafter7 (8 views)
2014-11-28 16:24:29

toopeicgaming1999 (75 views)
2014-11-26 15:22:04

toopeicgaming1999 (65 views)
2014-11-26 15:20:36

toopeicgaming1999 (15 views)
2014-11-26 15:20:08

SHC (29 views)
2014-11-25 12:00:59

SHC (27 views)
2014-11-25 11:53:45

Norakomi (32 views)
2014-11-25 11:26:43

Gibbo3771 (28 views)
2014-11-24 19:59:16
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!