Pages: [1]
  Print  
Author Topic: move_contact_solid()  (Read 2280 times)
Offline (Male) RetroX
Posted on: August 09, 2008, 02:52:41 PM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
Could someone make an alternate for me?  I'm clueless on how to do it.  It'll probably be easy to do, but ENIGMA doesn't support it yet.
Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Unknown gender) basil
Reply #1 Posted on: August 09, 2008, 03:47:21 PM

Member
Joined: Apr 2008
Posts: 30
MSN Messenger - irbasil@hotmail.com AOL Instant Messenger - irbasil
View Profile Email
Code: [Select]
for(yy=y; place_free(x,y+1); y++)
{
y=yy;
}

I have no idea if that would work but you can try it.  :-\
Logged
www.Teslaur.com - Coming soon.
Offline (Male) RetroX
Reply #2 Posted on: August 09, 2008, 03:55:58 PM

Master of all things Linux
Contributor
Location: US
Joined: Apr 2008
Posts: 1055
MSN Messenger - classixretrox@gmail.com
View Profile Email
No, it doesn't. =P

And I just figured it out... if anyone wants it:
Code: [Select]
i=0;
error=false;
x2=x;
y2=y;
while(place_free(x2+cos(degtorad(argument0)),y2-sin(degtorad(argument0))))
 {
 if i<argument1
  {
  x2+=cos(degtorad(argument0));
  y2-=sin(degtorad(argument0));
  i+=1;
  }
 else
  {
  return false;
  error=true;
  break;
  }
 }
if error=false
 {
 x=x2;
 y=y2;
 }
Logged
My Box: Phenom II 3.4GHz X4 | ASUS ATI RadeonHD 5770, 1GB GDDR5 RAM | 1x4GB DDR3 SRAM | Arch Linux, x86_64 (Cube) / Windows 7 x64 (Blob)
Quote from: Fede-lasse
Why do all the pro-Microsoft people have troll avatars? :(
Offline (Unknown gender) basil
Reply #3 Posted on: August 09, 2008, 04:18:59 PM

Member
Joined: Apr 2008
Posts: 30
MSN Messenger - irbasil@hotmail.com AOL Instant Messenger - irbasil
View Profile Email
Hehehe, nice job.
Logged
www.Teslaur.com - Coming soon.
Offline (Male) Josh @ Dreamland
Reply #4 Posted on: August 10, 2008, 04:02:47 PM

Prince of all Goldfish
Developer
Location: Ohio, United States
Joined: Feb 2008
Posts: 2933

View Profile Email
Now that colligma is integrated, and hopefully soon to be more stable,  I can rig up the script-free version.

Expect to see that shortly.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) MrGriggs
Reply #5 Posted on: December 30, 2010, 05:36:08 AM

Member
Joined: Dec 2010
Posts: 128

View Profile Email
Could someone make an alternate for me?  I'm clueless on how to do it.  It'll probably be easy to do, but ENIGMA doesn't support it yet.

No one seemed to reply with a simple answer, so I'll just paste the code I use.
(After place free was implemented)

Code: [Select]
for(i=0;i<MaxDown;i+=1){

if place_free(x,y+i+1) && if !place_free(x,y+i){ //Check one pixel above contact is free and one pixel below is not

y+=i //Move to the contacting position

}

}

Set MaxDown as the maximum amount of pixels you want to check below the instance. (You could make this a script called move_contact_for and call move_contact_for(20) replacing MaxDown with argument0, this way you don't have to re-paste the code for every time you do the check)
« Last Edit: December 30, 2010, 05:37:45 AM by MrGriggs » Logged
Offline (Unknown gender) MrGriggs
Reply #6 Posted on: December 30, 2010, 05:56:02 AM

Member
Joined: Dec 2010
Posts: 128

View Profile Email
RetroX's move contact supplies the abillity to set direction and distance, though.

you'd use it as such

set script name: move_contact_retro (or whatever)

Code: [Select]
i=0;
error=false;
x2=x;
y2=y;
while(place_free(x2+cos(degtorad(argument0)),y2-sin(degtorad(argument0))))
 {
 if i<argument1
  {
  x2+=cos(degtorad(argument0));
  y2-=sin(degtorad(argument0));
  i+=1;
  }
 else
  {
  return false;
  error=true;
  break;
  }
 }
if error=false
 {
 x=x2;
 y=y2;
 }

Put that code into the script.

Then call it as such

move_contact_retro(Direction.Distance)

This is a translation for all the idiots out there like me!  :v:
Logged
Offline (Unknown gender) MrGriggs
Reply #7 Posted on: December 30, 2010, 06:33:07 AM

Member
Joined: Dec 2010
Posts: 128

View Profile Email
Also, just for the lols, here's a script that turns the instance to a desried direction at a determined speed.


Code: [Select]
turn2 = argument1

if accel<argument2{
accel+=0.5
}

diff = turn2 - direction;

while (diff > 180) diff -= 360;
while (diff < -180) diff += 360;

if (abs(diff) < accel) {
        direction = turn2;
}
else {
        direction += sign(diff) * accel;
}

if argument0 = argument1{
accel=0
}


declare accel in the object's creation event, and use the script as such

turnto(direction,point_direction(x,y,mouse_x,mouse_y),6)

that would make the instance turn towards the mouse at a maximum speed of 6
« Last Edit: December 30, 2010, 01:05:20 PM by MrGriggs » Logged
Pages: [1]
  Print