Graal Forums

Graal Forums (https://forums.graalonline.com/forums/index.php)
-   NPC Scripting (https://forums.graalonline.com/forums/forumdisplay.php?f=8)
-   -   Images along a line (https://forums.graalonline.com/forums/showthread.php?t=134265513)

callimuc 01-05-2012 06:01 PM

Images along a line
 
3 Attachment(s)
I wanted to ask, how you could show images along a line. Letīs say my line starts from:
x: 2
y: 3

and ends at:
x: 50
y: 36

I know how I could use it with a poly.
PHP Code:

showpoly(200, {x1y1x2y2}); 

What I want is to have images along that line. Thatīs also not hard since I could stretch an Image (in case the length doesnīt match)
Attachment 54164
but how could I have, lets say a 16x16 pixel image, shown over and over on that line without stretching it?
Examples below (done in Paint.NET)
Attachment 54162
Attachment 54163

I thought I had seen such a script around but couldnīt find it anymore. Can anyone of you help me?

cbk1994 01-05-2012 06:25 PM

You have to show the image multiple times with a loop.

fowlplay4 01-05-2012 06:36 PM

Something like this should work...

Calculate the distance between the two positions and that will give you roughly how many images you need to draw if each image is one title in width and height (16x16).

Calculate the delta x, y (final - initial)

For image = 1; image <= images; image++

Show image at x + (delta x * (image / images)), y + (delta y * (image / images))

callimuc 01-05-2012 07:14 PM

Quote:

Originally Posted by fowlplay4 (Post 1680823)
Something like this should work...

Calculate the distance between the two positions and that will give you roughly how many images you need to draw if each image is one title in width and height (16x16).

Calculate the delta x, y (final - initial)

For image = 1; image <= images; image++

Show image at x + (delta x * (image / images)), y + (delta y * (image / images))

Have been messing around with something like this:

PHP Code:

//#CLIENTSIDE
function onCreated()
  
onTimeOut();
function 
onTimeOut() {
  if (
leftmousebutton) {
    
temp.img "wmace0.png";  //image to draw
    
temp.distx player.mousex;  //x distance
    
temp.disty player.mousey;  //y distance
    
temp.lennew = (temp.distx^temp.disty^2) ^ 0.5;  //length in tiles
    
player.chat temp.lennew;  //debug
    
for(temp.0temp.<= temp.lennewtemp.i++) {
      
temp.indx ++;
      
temp.newpos temp.i/16*9;
      
player.chat newpos;
      
with (findimg(200+temp.indx)) {
        
player.x+temp.newpos;
        
player.y;
        
image temp.img;
      }
    }
  }
  
settimer(0.05);


It seems to work, but itīs not exactly on the mousex. How could that get fixed?

Tolnaftate2004 01-05-2012 07:24 PM

Quote:

Originally Posted by callimuc (Post 1680826)
Have been messing around with something like this:
PHP Code:

temp.newpos temp.i/16*9


Give temp.newpos = temp.i/temp.lennew*(-temp.distx); (as fp4 described) a whirl for us.

callimuc 01-05-2012 07:26 PM

Thanks guys for helping. I think I understood it now
Quote:

Originally Posted by Tolnaftate2004 (Post 1680828)
Give temp.newpos = temp.i/temp.lennew*(-temp.distx); (as fp4 described) a whirl for us.

Oh that fixed it :P


All times are GMT +2. The time now is 03:07 PM.

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.