AutoHotkey Community

It is currently May 26th, 2012, 4:42 am

All times are UTC [ DST ]




Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2
Author Message
 Post subject:
PostPosted: March 14th, 2008, 10:16 pm 
Offline

Joined: May 24th, 2007, 3:45 am
Posts: 1121
tic wrote:
I find it strange that you do this:

Code:
Loop Parse, XSpeeds, :
   XSpeed%A_Index% := A_LoopField
Loop Parse, YSpeeds, :
   YSpeed%A_Index% := A_LoopField

Good point. It hardly matters since it only runs once, but I'll fix it.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 15th, 2008, 7:49 pm 
Offline

Joined: November 1st, 2007, 10:03 pm
Posts: 885
Awsome Script

You should develop iut too do more things

Maybe sleep

A bed pciture comes up and he sleeps on it

also maybe it could talk


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 15th, 2008, 9:38 pm 
Offline
User avatar

Joined: December 29th, 2004, 1:28 pm
Posts: 2541
LOL :) Cool. It would make a cool screensaver if there was another one appearing every minute until there are a hundred of so running around...


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 15th, 2008, 10:08 pm 
Offline

Joined: April 22nd, 2007, 6:33 pm
Posts: 1833
Well the alphablended code i posted can easily be used to write the whole thing however complex in no time.


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 16th, 2008, 8:23 am 
Offline

Joined: July 21st, 2006, 12:26 am
Posts: 223
hey very nice, thanks for sharing it!


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 18th, 2008, 8:26 pm 
Offline

Joined: October 27th, 2007, 8:30 am
Posts: 21
Location: Hawaii
SWEEEET lol i have alot going around i put a time into the script and made it re create a new amount of time to wait till it made a new one and i used tics alpha blended code and got this one appeard between like 10secs. - 1 min
[img=http://img243.imageshack.us/img243/3175/spidazou6.th.png]

_________________
Image
0100111001101001011000110110101101011011001101000011001000110000010011010110111101101110011001010111100101011101


Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2008, 5:13 am 
Offline

Joined: May 24th, 2007, 3:45 am
Posts: 1121
Sounds cool, feel free to post your modified version.

I haven't done much more on this myself. I've written code for the bug to follow (or flee from) a point on the screen, but I haven't put it to good use yet. Here's a sample that makes it follow the mouse pointer, but I don't really like the effect, at least not for all the time. It conflicts with the behavior where it runs when you point at it, so I disbaled that in this example.

Code:
#SingleInstance Force
#NoEnv

CoordMode Mouse, Screen
SetBatchLines -1
SetWinDelay -1

IfNotExist bug
{
   FileCreateDir bug
   Loop 17
      UrlDownloadToFile http://www.autohotkey.net/~ManaUser/bugs/bug%A_Index%.png, bug\bug%A_Index%.png
}
SetWorkingDir bug

Gui Color, White
Loop 16
{
   Gui Add, Picture, x0 y0 gGrab, bug%A_Index%.png
   GuiControl Hide, bug%A_Index%.png
}
Gui Add, Picture, x0 y0 gWipe, bug17.png
GuiControl Hide, bug17.png
Gui -Caption +ToolWindow +AlwaysOnTop +LastFound
WinSet, TransColor, White
TheBug := WinExist()

Gui Show, w16 h16 y0, NA
WinGetPos X, Y

XSpeeds := "0:1:2:3:3:3:2:1:0:-1:-2:-3:-3:-3:-2:-1"
YSpeeds := "-3:-3:-2:-1:0:1:2:3:3:3:2:1:0:-1:-2:-3"
StringSplit XSpeed, XSpeeds, :
StringSplit YSpeed, YSpeeds, :

Speed := 1
Random Dir, 1, 9
SetTimer Move, 50
GoSub Move
Return

Move:
   MouseGetPos, Mx, My, UnderMouse
   ;If (TheBug = UnderMouse)
   ;{
   ;   Speed := 3
   ;   SetTimer SlowDown, -525
   ;   SetTimer SlowMore, -1525
   ;}
   
   X += XSpeed%Dir% * Speed
   Y += YSpeed%Dir% * Speed
   
   If (X < -16)
      X := -16
   Else If (X > A_ScreenWidth)
      X := A_ScreenWidth
   If (Y < -16)
      Y := -16
   Else If (Y > A_ScreenHeight)
      Y := A_ScreenHeight
   
   GuiControl Hide, bug%Dir%.png
   ;Dir := NewDirRnd()
   Dir := NewDirChase(Mx, My, 50) ;<-- (X, Y, Influence), also try NewDirFlee
   GuiControl Show, bug%Dir%.png
   
   Gui +LastFound
   WinMove, X, Y
   Gui Show, NA
Return

NewDirRnd()
{
   Global Dir
   Random Rand, 0, 1
   Rand := Rand & !GetKeyState("Left") | GetKeyState("Right")
   NewDir := WrapDir(Dir + (Rand ? 1 : -1))
   Return NewDir
}

NewDirChase(TargetX, TargetY, Influence = 50, Flee = False)
{
   Global Dir, X, Y
   Random Rand, 1, 100
   If (Influence < Rand)
      Return NewDirRnd()     
   Random Rand, 0, 1
   NewDir := WrapDir(Dir + (Rand ? 1 : -1))
   AltDir := WrapDir(Dir + (!Rand ? 1 : -1))
   NewDist := Distance(X+8+XSpeed%NewDir%, Y+8+YSpeed%NewDir%, TargetX, TargetY)
   AltDist := Distance(X+8+XSpeed%AltDir%, Y+8+YSpeed%AltDir%, TargetX, TargetY)
   Return (AltDist < NewDist) ^ Flee ? AltDir : NewDir
}

NewDirFlee(TargetX, TargetY, Influence = 50)
{
   Return NewDirChase(TargetX, TargetY, Influence, True)
}

WrapDir(wDir)
{
   If (wDir = 0)
      Return 16
   If (wDir = 17)
      Return 1
   Return wDir
}

Distance(X1, Y1, X2, Y2)
{
   Return Sqrt(Abs( (X1-X2)**2 + (Y1-Y2)**2 ))
}

SlowDown:
   Speed := 2
Return

SlowMore:
   Speed := 1
Return

Grab:
   SetTimer Move, Off
   SetTimer SlowDown, Off
   SetTimer SlowMore, Off
   SetTimer Hold, 50
   Wiggle := 1
   If (Dir = 16)
      Dir := 1
Return
   
Hold:
   MouseGetPos X, Y
   X -= 8, Y -= 8

   Random Rand, 0, 1
   If Rand
   {
      GuiControl Hide, bug%Dir%.png
      Dir += Wiggle
      GuiControl Show, bug%Dir%.png
      Wiggle *= -1
   }
   
   Gui +LastFound
   WinMove, X, Y
   
   If GetKeyState("LButton") = 0
   {
      SetTimer Hold, Off
      SetTimer Move, 50
   }
Return

GuiContextMenu: ;Squish
   SetTimer Move, Off
   SetTimer Hold, Off
   Gui Show, Hide
   GuiControl Hide, bug%Dir%.png
   GuiControl Show, bug17.png
   Gui Show, NA
   Sleep 60000
Wipe:
   ExitApp
Return

Edit: Thanks for pointing out that goof with UrlDownloadToFile. (Fixed now.)


Last edited by ManaUser on March 19th, 2008, 11:44 pm, edited 3 times in total.

Report this post
Top
 Profile  
Reply with quote  
 Post subject:
PostPosted: March 19th, 2008, 9:23 pm 
Offline

Joined: October 27th, 2007, 8:30 am
Posts: 21
Location: Hawaii
oh hang on im gonna try and make like a little box where you can have an accual convo with him if you nice he will follow then if yor annoying then he will run!! that was a very good but random idea

BTW: url download to file is missing a parameter im assuming it the same as the old so this is it
EDIT: oh wait you just pressed enter i see but you had me for a sec lol
Code:
#SingleInstance Force
#NoEnv

CoordMode Mouse, Screen
SetBatchLines -1
SetWinDelay -1

IfNotExist bug
{
   FileCreateDir bug
   Loop 17
      UrlDownloadToFile http://www.autohotkey.net/~ManaUser/bugs/bug%A_Index%.png, bug\bug%A_Index%.png
}
SetWorkingDir bug

Gui Color, White
Loop 16
{
   Gui Add, Picture, x0 y0 gGrab, bug%A_Index%.png
   GuiControl Hide, bug%A_Index%.png
}
Gui Add, Picture, x0 y0 gWipe, bug17.png
GuiControl Hide, bug17.png
Gui -Caption +ToolWindow +AlwaysOnTop +LastFound
WinSet, TransColor, White
TheBug := WinExist()

Gui Show, w16 h16 y0, NA
WinGetPos X, Y

XSpeeds := "0:1:2:3:3:3:2:1:0:-1:-2:-3:-3:-3:-2:-1"
YSpeeds := "-3:-3:-2:-1:0:1:2:3:3:3:2:1:0:-1:-2:-3"
StringSplit XSpeed, XSpeeds, :
StringSplit YSpeed, YSpeeds, :

Speed := 1
Random Dir, 1, 9
SetTimer Move, 50
GoSub Move
Return

Move:
   MouseGetPos, Mx, My, UnderMouse
   ;If (TheBug = UnderMouse)
   ;{
   ;   Speed := 3
   ;   SetTimer SlowDown, -525
   ;   SetTimer SlowMore, -1525
   ;}
   
   X += XSpeed%Dir% * Speed
   Y += YSpeed%Dir% * Speed
   
   If (X < -16)
      X := -16
   Else If (X > A_ScreenWidth)
      X := A_ScreenWidth
   If (Y < -16)
      Y := -16
   Else If (Y > A_ScreenHeight)
      Y := A_ScreenHeight
   
   GuiControl Hide, bug%Dir%.png
   ;Dir := NewDirRnd()
   Dir := NewDirChase(Mx, My, 50) ;<-- (X, Y, Influence), also try NewDirFlee
   GuiControl Show, bug%Dir%.png
   
   Gui +LastFound
   WinMove, X, Y
   Gui Show, NA
Return

NewDirRnd()
{
   Global Dir
   Random Rand, 0, 1
   Rand := Rand & !GetKeyState("Left") | GetKeyState("Right")
   NewDir := WrapDir(Dir + (Rand ? 1 : -1))
   Return NewDir
}

NewDirChase(TargetX, TargetY, Influence = 50, Flee = False)
{
   Global Dir, X, Y
   Random Rand, 1, 100
   If (Influence < Rand)
      Return NewDirRnd()     
   Random Rand, 0, 1
   NewDir := WrapDir(Dir + (Rand ? 1 : -1))
   AltDir := WrapDir(Dir + (!Rand ? 1 : -1))
   NewDist := Distance(X+8+XSpeed%NewDir%, Y+8+YSpeed%NewDir%, TargetX, TargetY)
   AltDist := Distance(X+8+XSpeed%AltDir%, Y+8+YSpeed%AltDir%, TargetX, TargetY)
   Return (AltDist < NewDist) ^ Flee ? AltDir : NewDir
}

NewDirFlee(TargetX, TargetY, Influence = 50)
{
   Return NewDirChase(TargetX, TargetY, Influence, True)
}

WrapDir(wDir)
{
   If (wDir = 0)
      Return 16
   If (wDir = 17)
      Return 1
   Return wDir
}

Distance(X1, Y1, X2, Y2)
{
   Return Sqrt(Abs( (X1-X2)**2 + (Y1-Y2)**2 ))
}

SlowDown:
   Speed := 2
Return

SlowMore:
   Speed := 1
Return

Grab:
   SetTimer Move, Off
   SetTimer SlowDown, Off
   SetTimer SlowMore, Off
   SetTimer Hold, 50
   Wiggle := 1
   If (Dir = 16)
      Dir := 1
Return
   
Hold:
   MouseGetPos X, Y
   X -= 8, Y -= 8

   Random Rand, 0, 1
   If Rand
   {
      GuiControl Hide, bug%Dir%.png
      Dir += Wiggle
      GuiControl Show, bug%Dir%.png
      Wiggle *= -1
   }
   
   Gui +LastFound
   WinMove, X, Y
   
   If GetKeyState("LButton") = 0
   {
      SetTimer Hold, Off
      SetTimer Move, 50
   }
Return

GuiContextMenu: ;Squish
   SetTimer Move, Off
   SetTimer Hold, Off
   Gui Show, Hide
   GuiControl Hide, bug%Dir%.png
   GuiControl Show, bug17.png
   Gui Show, NA
   Sleep 60000
Wipe:
   ExitApp
Return

_________________
Image
0100111001101001011000110110101101011011001101000011001000110000010011010110111101101110011001010111100101011101


Report this post
Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2

All times are UTC [ DST ]


Who is online

Users browsing this forum: JamixZol and 14 guests


You can post new topics in this forum
You can reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Powered by phpBB® Forum Software © phpBB Group