Graal Forums  

Go Back   Graal Forums > Development Forums > NPC Scripting
FAQ Members List Calendar Today's Posts

Reply
 
Thread Tools Search this Thread Display Modes
  #1  
Old 01-05-2012, 06:01 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Images along a line

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)
Click image for larger version

Name:	Unbenannt3.png
Views:	141
Size:	2.5 KB
ID:	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)
Click image for larger version

Name:	Unbenannt.png
Views:	146
Size:	2.2 KB
ID:	54162
Name:  Unbenannt2.png
Views: 100
Size:  2.1 KB

I thought I had seen such a script around but couldnīt find it anymore. Can anyone of you help me?
__________________
MEEP!
Reply With Quote
  #2  
Old 01-05-2012, 06:25 PM
cbk1994 cbk1994 is offline
the fake one
cbk1994's Avatar
Join Date: Mar 2003
Location: San Francisco
Posts: 10,718
cbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond reputecbk1994 has a reputation beyond repute
Send a message via AIM to cbk1994
You have to show the image multiple times with a loop.
__________________
Reply With Quote
  #3  
Old 01-05-2012, 06:36 PM
fowlplay4 fowlplay4 is offline
team canada
fowlplay4's Avatar
Join Date: Jul 2004
Location: Canada
Posts: 5,200
fowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond reputefowlplay4 has a reputation beyond repute
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))
__________________
Quote:
Reply With Quote
  #4  
Old 01-05-2012, 07:14 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Quote:
Originally Posted by fowlplay4 View Post
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?
__________________
MEEP!
Reply With Quote
  #5  
Old 01-05-2012, 07:24 PM
Tolnaftate2004 Tolnaftate2004 is offline
penguin.
Join Date: Jul 2004
Location: Berkeley, CA
Posts: 534
Tolnaftate2004 is a jewel in the roughTolnaftate2004 is a jewel in the rough
Send a message via AIM to Tolnaftate2004
Quote:
Originally Posted by callimuc View Post
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.
__________________
◕‿‿◕ · pfa · check yer syntax! · src

Killa Be: when i got that locker in 6th grade the only thing in it was a picture of a midget useing a firehose :/
Reply With Quote
  #6  
Old 01-05-2012, 07:26 PM
callimuc callimuc is offline
callimuc's Avatar
Join Date: Nov 2010
Location: Germany
Posts: 1,015
callimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to beholdcallimuc is a splendid one to behold
Thanks guys for helping. I think I understood it now
Quote:
Originally Posted by Tolnaftate2004 View Post
Give temp.newpos = temp.i/temp.lennew*(-temp.distx); (as fp4 described) a whirl for us.
Oh that fixed it :P
__________________
MEEP!
Reply With Quote
Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT +2. The time now is 08:24 AM.


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