User Tag List

Page 3 of 4 FirstFirst 1 2 3 4 LastLast
Results 21 to 30 of 40

Thread: walkTo() void?

  1. #21
    &&
    ZC Developer
    Joe123's Avatar
    Join Date
    Sep 2006
    Age
    33
    Posts
    3,061
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    7,322
    Level
    26
    vBActivity - Bars
    Lv. Percent
    11.56%

    Re: walkTo() void?

    ?

    Plotting y=sint,x=cost is exactly the same as plotting y=cost,x=sint

  2. #22
    Lynel
    ZC Developer
    pkmnfrk's Avatar
    Join Date
    Jan 2004
    Location
    Toronto
    Age
    37
    Posts
    1,248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    3,161
    Level
    18
    vBActivity - Bars
    Lv. Percent
    15.16%

    Re: walkTo() void?

    That doesn't make any sense. For that to be true, COS(t) would have to equal SIN(t), which it does not.

    http://www.themathpage.com/atrig/gra...m#sine%20graph
    http://www.themathpage.com/atrig/graphs-trig.htm#cosine

    It's the same wave, but offset by 1/2 Pi
    Tale of the Cave - a web comic - Updates Monday, Wednesday, Friday
    ZC Tutorials - Tutorials and Script Library - Updated July 30, 2008
    ZeldaGuard - Corruption in my save files? It's more likely than you think!
    I do script requests!

  3. #23
    &&
    ZC Developer
    Joe123's Avatar
    Join Date
    Sep 2006
    Age
    33
    Posts
    3,061
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    7,322
    Level
    26
    vBActivity - Bars
    Lv. Percent
    11.56%

    Re: walkTo() void?

    I know the difference between sine and cosine.

    It does, however, make sense.
    When plotting a circle parametrically, it doesn't matter whether you use sine or cosine on the x or y, provided you don't use them for both (otherwise you'll get a diagonal line, which makes sense as y = x).

    Have a look:
    Code:
    ffc script circle{
    	void run(){
    	int x = 80; int y = 80;
    	int r = 32;
    		while(true){
    			for(int i;i<360;i++){
    				int x2 = y+r*Cos(i);
    				int y2 = x+r*Sin(i);
    				Screen->PutPixel(6,x2,y2,Rand(10),0,0,0,128);
    			}
    		Waitframe();
    		}
    	}
    }
    Will produce the exact same result as:
    Code:
    ffc script circle{
    	void run(){
    	int x = 80; int y = 80;
    	int r = 32;
    		while(true){
    			for(int i;i<360;i++){
    				int x2 = y+r*Sin(i);
    				int y2 = x+r*Cos(i);
    				Screen->PutPixel(6,x2,y2,Rand(10),0,0,0,128);
    			}
    		Waitframe();
    		}
    	}
    }

  4. #24
    Lynel
    ZC Developer
    pkmnfrk's Avatar
    Join Date
    Jan 2004
    Location
    Toronto
    Age
    37
    Posts
    1,248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    3,161
    Level
    18
    vBActivity - Bars
    Lv. Percent
    15.16%

    Re: walkTo() void?

    Maybe for plotting a circle, but I believe in experimental data.

    The script:
    Code:
    import "advmath.zh"
    
    void moveTowards1(ffc this, int x, int y, int speed) {
    	int angle = findAngle(this->X, this->Y, x, y);
    	float dx = RadianSin(angle) * speed;
    	float dy = RadianCos(angle) * speed;
    	
    	this->X += dx;
    	this->Y += dy;
    }
    
    void moveTowards2(ffc this, int x, int y, int speed) {
    	int angle = findAngle(this->X, this->Y, x, y);
    	float dx = RadianCos(angle) * speed;
    	float dy = RadianSin(angle) * speed;
    	
    	this->X += dx;
    	this->Y += dy;
    }
    
    ffc script followLink {
    	void run(int method) {
    		while(true) {
    			if(method==1) {
    				moveTowards1(this, Link->X, Link->Y, 1);
    			} else if(method==2) {
    				moveTowards2(this, Link->X, Link->Y, 1);
    			}
    			Waitframe();
    		}
    	}
    }
    The results:

    On YouTube

    FFC #1 calls "moveTowards1", while #2 calls "moveTowards2". Only #1 behaves properly.
    Tale of the Cave - a web comic - Updates Monday, Wednesday, Friday
    ZC Tutorials - Tutorials and Script Library - Updated July 30, 2008
    ZeldaGuard - Corruption in my save files? It's more likely than you think!
    I do script requests!

  5. #25
    &&
    ZC Developer
    Joe123's Avatar
    Join Date
    Sep 2006
    Age
    33
    Posts
    3,061
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    7,322
    Level
    26
    vBActivity - Bars
    Lv. Percent
    11.56%

    Re: walkTo() void?

    Oh, you're making triangles.
    Should've read the thread a bit more carefully before I posted really.

    It does work for circles though, trust me =P

  6. #26
    The Time-Loop Continues ZC Developer
    Gleeok's Avatar
    Join Date
    Apr 2007
    Posts
    4,827
    Mentioned
    259 Post(s)
    Tagged
    10 Thread(s)
    vBActivity - Stats
    Points
    12,978
    Level
    33
    vBActivity - Bars
    Lv. Percent
    28.31%

    Re: walkTo() void?

    Hahaha.. "ALL YOUR BASE ARE BELONG TO US!!!" I forgot about that shit.

    Yeah, you're both right, and on a related note, It took me way too long to figure out this one:

    Code:
    x += cos(rad)*speed; 
    y += sin(rad)*speed;
    That's the way it goes though, you feel like a dumbass, then a genius, then a dumbass again when you realize that you just figured out something everyone uses already that you probably could've googled in the first place.



    I'll take a look at that script a little later joe, thanks...although watching pkmnfrk's video, there doesn't seem to be a problem with that...(maybe it was a bug in an older build?) So FFC's coordinates are stored in floats I guess.
    This post contains the official Gleeok seal of approval. Look for these and other posts in an area near you.

  7. #27
    Lynel
    ZC Developer
    pkmnfrk's Avatar
    Join Date
    Jan 2004
    Location
    Toronto
    Age
    37
    Posts
    1,248
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    3,161
    Level
    18
    vBActivity - Bars
    Lv. Percent
    15.16%

    Re: walkTo() void?

    Just be careful about checking absolute position if you use my script, since FFCs won't necessarily be pixel-aligned any more.

    So, if you need to check an exact position, do something like:

    Code:
    if(Floor(theffc->X) == 120 && Floor(theffc->Y) == 80) //do something
    Tale of the Cave - a web comic - Updates Monday, Wednesday, Friday
    ZC Tutorials - Tutorials and Script Library - Updated July 30, 2008
    ZeldaGuard - Corruption in my save files? It's more likely than you think!
    I do script requests!

  8. #28
    a.k.a. Zephlon Arphanosh Mega Link's Avatar
    Join Date
    May 2006
    Age
    31
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    1,689
    Level
    13
    vBActivity - Bars
    Lv. Percent
    79.08%

    Re: walkTo() void?

    If I use this on Link (assuming I can); will Link walk, or will he "float"?

  9. #29
    Keese
    Join Date
    Jan 2008
    Age
    28
    Posts
    52
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    764
    Level
    9
    vBActivity - Bars
    Lv. Percent
    71.05%

    Re: walkTo() void?

    Ya, I think you can. Just change "this->" into "Link->". However, he won't animate, he'll just float like you said. And you will probably need to stop the player from pressing any of the direction buttons.

  10. #30
    a.k.a. Zephlon Arphanosh Mega Link's Avatar
    Join Date
    May 2006
    Age
    31
    Posts
    371
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    vBActivity - Stats
    Points
    1,689
    Level
    13
    vBActivity - Bars
    Lv. Percent
    79.08%

    Re: walkTo() void?

    Ok. I know how to get link to walk.

    If Link walks over a tile/side warp, will he go where the warp says to go?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
About us
Armageddon Games is a game development group founded in 1997. We are extremely passionate about our work and our inspirations are mostly drawn from games of the 8-bit and 16-bit era.
Social