Jump to content

Adam1213

Active Members
  • Posts

    131
  • Joined

  • Last visited

Profile Information

  • WWW
    http://www.adam1213.tk
  • Interests
    Programing.

Adam1213's Achievements

Adventurer

Adventurer (3/7)

1

Reputation

  1. I am still trying to open the usb port properly - currently I am getting an error that the function does not exist within the dll (despite it being documented as being a function within that dll...)... ;http://www.autoitscript.com/forum/index.php?showtopic=83147&hl=usb ;http://www.codeproject.com/KB/cs/USB_HID.aspx?fid=398968&df=90&mpp=25&noise=3&sort=Position&view=Quick&select=2706675 ;http://www.alanmacek.com/usb/ $dll = DllOpen('UsbLibrary.dll') ; if autoit crashes the dll was not found - file available from http://www.codeproject.com/KB/cs/USB_HID.aspx const $VENDOR_ID=0483 const $PRODUCT_ID=1311 ;$struct_devinfo = DllStructCreate('int VendorId;int ProductId') $result=DllCall ($dll, 'str', ' HIDDevice', 'int', $VENDOR_ID, 'int', '') msgbox(0,'',$result&@CRLF&'error: '&@ERROR) ;$result=DllCall ($dll, 'str', 'set_VendorId', 'int', $VENDOR_ID) #cs static HIDDevice FindDevice( int nVid, int nPid, Type oType ) #ce DllClose($dll)
  2. I am trying to use Autoit for usb communication with a HID (human interface device). I have found an USB library which should be able to do the communication (the sample app provided worked). I am currently trying to use the dll that they provide to interface with ta device however I am still trying to work out how to make it work.
  3. I never really finished coding this so its missing many features - the basic idea was to scroll a gui have jump and fire (in directions) etc. While the character that moves flashes I don't think the gui flashes when it scrolls (scrolling has stopped working with the new version of autoit due to a small issue with the include files). You can make the bullets move faster (currently $bullet_speed=2) By the way I admit that I should have chosen a better background.
  4. Have a look at Radar animation with GDI+ It may be that you just clear the object and redraw it without any problems.
  5. I have started changing your code, currently I have just moved things into arrays and added a bit of documentation to these parts. I have fixed jumping (one of the problems with the way you had coded jumping before was that you set a variable to presumably say to jump up and once the slime got to this height you made it go down, next loop it would be below the threshold and go up and just repeat. Once the slime gets to the top the code needed to set your variable for jumping up to 0. Another problem was that your "collision detection" did not realise that the coordinates of the slime had changed once it had jumped (perhaps you were going to code this after you got jumping working)). - it now starts a new game after the ball hits the ground. - There are some issues with the interaction between the slime and the ball where the ball does not properly bounce of the slime - I have given it a forum release version because I intend on editing this post a few times. #include <guiconstants.au3> #include <misc.au3> $vDll = "user32.dll" #cs ;slime volleyball! ;http://www.autoitscript.com/forum/index.php?showtopic=84253&hl=slime forum release v1.0.6 Future features: - Add a key to start again - interaction with net - is moving appears to be old position (if this is the case it should be renamed) - user timer to work out how long to sleep (delay-time_spent_in_loop) - move gui options into a function gui_defaults - fix handling of area below slime (with collisions / distance formula) - replay game #ce ;______________________________________________________ const $GROUND_HEIGHT=240 ;dim $collision ; what does this variable do? dim $velocity ;___________ BALL _____________________________ dim $ball[3] ; image reference/ x / y ;$ball[1]=154 ;$ball[2]=200 $ball_radius=10 dim $ballh ; _____________ SLIME _________________________ dim $slime[2][4] ; player, image_reference / x / y / jump - the default values are set in the function start_game - [jump indicates that the slime is moving up] dim $slime_visual[2][2] ; player, radius / colour for $i=0 to 1 $slime_visual[$i][0]=40 ; radius next ;-------- colour -------------- $slime_visual[0][1]=0x00FF00 $slime_visual[1][1]=0xFF0000 ;-------------------------------------- $slime_jump_height=70 $slime_jump_up_speed=10 $slime_jump_down_speed=8 ;_____________________________________ const $NET_THICKNESS=5 global $ball_y_movement ; this used to be called g ;$k = 0 ;$f = 8 ;$jump = False Global Const $t = 0.017453292519943295 ;pi/180 ;______________________________ GUI ___________________________________________ Global Const $WS_EX_COMPOSITED = 0x2000000 GUICreate("Slime Volleyball", 700, 250, -1, -1, -1, $WS_EX_COMPOSITED) ;---------- Slime ----------------------- for $i=0 to 1 $slime[$i][0]=guictrlcreategraphic(0,0,0,0) guictrlsetgraphic(-1, $GUI_GR_COLOR, $slime_visual[$i][1], $slime_visual[$i][1]) guictrlsetgraphic(-1, $GUI_GR_PIE, 0, $GROUND_HEIGHT, $slime_visual[$i][0], 0, 180) ; the position of the slimes is relative to the start position guictrlsetgraphic(-1, $GUI_GR_REFRESH) guictrlsetgraphic(-1, $GUI_GR_CLOSE) guictrlsetpos($slime[$i][0], $slime[$i][1], $slime[$i][2]) next ;--------- Ball --------------------------- $ball[0] = guictrlcreategraphic(10,0,0,0) guictrlsetgraphic(-1, $GUI_GR_COLOR, 0xFFFF00, 0xFFFF00) guictrlsetgraphic(-1, $GUI_GR_PIE, 0, $GROUND_HEIGHT, 10, 0, 360) guictrlsetgraphic(-1, $GUI_GR_REFRESH) guictrlsetgraphic(-1, $GUI_GR_CLOSE) guictrlsetpos($ball[0], $ball[1], -$ball[2]) ;------------------------------------- $floor = guictrlcreategraphic(0,0,0,0) guictrlsetgraphic(-1, $GUI_GR_COLOR, 0xCCCCCC, 0xCCCCCC) guictrlsetgraphic(-1, $GUI_GR_RECT, -1, $GROUND_HEIGHT, 700, 10) guictrlsetgraphic(-1, $GUI_GR_REFRESH) guictrlsetgraphic(-1, $GUI_GR_CLOSE) ;--------------------------- $net = guictrlcreategraphic(0,0,0,0) guictrlsetgraphic(-1, $GUI_GR_COLOR, 0xFFFFFF, 0xFFFFFF) guictrlsetgraphic(-1, $GUI_GR_RECT, 340, 220, $NET_THICKNESS, 40) guictrlsetgraphic(-1, $GUI_GR_REFRESH) guictrlsetgraphic(-1, $GUI_GR_CLOSE) guisetbkcolor(0x0000FF) guisetstate() ;______________________________________________________________ dim $s[2]=[0,0] $WS_EX_TRANSPARENT = 0x00000020 $label = guictrlcreatelabel("Slime Volleyball By Isaac and Adam1213. Click here to play!", 200, 100, 500, 70) guictrlsetbkcolor(-1, $GUI_BKCOLOR_TRANSPARENT) guictrlsetcolor($label, 0xFFFFFF) $p1score = guictrlcreatelabel("0", 0, 0, 50, 50) guictrlsetcolor(-1, 0xFFFFFF) guictrlsetbkcolor(-1, $GUI_BKCOLOR_TRANSPARENT) guictrlsetfont($p1score, 20) $p2score = guictrlcreatelabel("0", 670, 0, 50, 50) ; 680 guictrlsetcolor(-1, 0xFFFFFF) guictrlsetbkcolor(-1, $GUI_BKCOLOR_TRANSPARENT) guictrlsetfont($p2score, 20) start_game() ;__________________________________________ do $msg = guigetmsg() if $msg = -3 then Exit Until $msg = $label guictrldelete($label) ;______________________________________________________________________ While 1 $msg = guigetmsg() if $msg = -3 then Exit if ($ball[2] <= 220) Then $ball_y_movement -= .2 EndIf sleep(20) $ismoving = $slime[0][1] ; what does this do? ; ___________ JUMP __________________________ If _IsPressed(26, $vDll) AND $slime[0][2]=0 Then ; make sure that the slime is on the ground $slime[0][3]=1 endif if $slime[0][3] then ; jump up $slime[0][2]+=$slime_jump_up_speed if $slime[0][2]>=$slime_jump_height then $slime[0][3]=0 ; set jump up to 0 endif else if $slime[0][2]>0 then ; slime is off the ground $slime[0][2]-=$slime_jump_down_speed if $slime[0][2]<0 then $slime[0][2]=0 endif endif endif ;_____________ BALL _______________________________________ ;------------ check if the ball has hit the ground ----------- if $ball[2] < $ball_radius then ; the ball must have hit the ground if($ball[1] > 340) Then $winning_player=0 Else $winning_player=1 EndIf $s[$winning_player] += 1 guictrlsetdata($p1score, $s[0]) ; change this to an array !!! guictrlsetdata($p2score, $s[1]) sleep(1000) start_game() EndIf ;____________ SLIME MOVEMENT __________________________________ If (_IsPressed(25, $vDll)) and ($slime[0][1] > $slime_visual[0][0]) Then ; $slime_visual[0][0] is the radius $slime[0][1] -=6 endif If ((_IsPressed(27, $vDll)) and ($slime[0][1] <= 340-$slime_visual[0][0]-$NET_THICKNESS)) Then ; 258 $slime[0][1] +=6 endif ;___________________________________________________________ $distx = Abs($slime[0][1] - $ball[1]) $disty = Abs($slime[0][2] - $ball[2]) $dist = Sqrt(($distx * $distx) + ($disty * $disty)) If $dist <= 50 Then ;If(($dist < 50) and ($collision = False)) Then ; 50 = radius of slime + ball [40 +10] $distx = (($slime[0][1]) - ($ball[1])) $disty = (($slime[0][2]) - ($ball[2])) $angle = Atan($disty/$distx) if($angle <= 0) Then $ballh = true Else $ballh = False EndIf $vi = Sqrt(($velocity * $velocity) + ($ball_y_movement* $ball_y_movement)) $a1 = (findangle($velocity, $ball_y_movement) * $t) $vx = $vi * Cos(abs($angle)-$a1) $vy = $vi * Sin(abs($angle)-$a1) If((Abs($ismoving - $slime[0][1]) = 6) or (Abs($ismoving - $slime[0][1]) = 12)) Then $velocity = $vy + 3 Else $velocity = $vy EndIf $ball_y_movement = 1 * ($vx - 1) ;$collision = True ;Else ;$collision = False EndIf ;if $dist > 50 then ; $collision = False ;endif ; _________ BOUNCE OFF WALLS (still need to add net!!!) __________ if $ball[1] <= $ball_radius Then $velocity *= -1 ; Assuming that the ball must have been moving left to reach the left wall make it move the other way endif if $ball[1] >= 700-$ball_radius then $velocity *= -1 endif ;_____________________________________________________ $ball[2] += $ball_y_movement If ($ballh) Then $ball[1] += $velocity Else $ball[1] -= $velocity EndIf $v = false guictrlsetpos($slime[0][0], $slime[0][1], -$slime[0][2]) guictrlsetgraphic($slime[0][0], $GUI_GR_REFRESH) guictrlsetpos($ball[0], $ball[1], -$ball[2]) tooltip($slime[0][1]&'x'&$slime[0][2]&@CRLF& _ round($ball[1])&'x'&round($ball[2]),500,0) WEnd Func findangle($v, $ball_y_movement) $includedside=Atan($ball_y_movement/$v)/$t select case $v = 0 and $ball_y_movement = 0 $j = 0 case $v = 0 and $ball_y_movement<0 $j = 90 case $v < 0 $j = 180 + $includedside case $v > 0 and $ball_y_movement>=0 $j = $includedside case $v > 0 and $ball_y_movement>0 $j = 360 + $includedside case else $j = 270 endselect ;msgbox(0,'','Ball y movement: '&$ball_y_movement&@CRLF& _ ;'v '&$v&@CRLF& _ ;'included side '&$includedside&@CRLF& _ ;'j '&$j) return $j EndFunc ;_______________ START GAME _____________________________ func start_game() $ball[1]=154 $ball[2]=200 $ballh = 1 $ball_y_movement =- 2 ;$collision = False $velocity = 0 ;------ slime -------- $slime[0][1]=154 ; x coordinate - make sure that the x coordinate + radius of slime is a multiple of the movement multiplier (or the slime won't go all the way to one of the sides) $slime[1][1]=500 for $i=0 to 1 $slime[$i][2]=0 ; y coordinate $slime[$i][3]=0 ; jump up guictrlsetpos($slime[$i][0], $slime[$i][1], -$slime[$i][2]) next guictrlsetpos($ball[0], $ball[1], -$ball[2]) guictrlsetgraphic($slime[0][0], $GUI_GR_REFRESH) ; refresh the graphics endfunc
  6. Due to changes to autoit the code stopped working so I have made a few modifications to game.au3 (to run this extract the zip file and replace game.au3 with this code) #include <GUIConstants.au3> #Include <GuiStatusBar.au3> #include <GUIScrollBars.au3> #include <Misc.au3> #include <WindowsConstants.au3> #include <GuiStatusBar.au3> #include <ScrollBarConstants.au3> #include <GuiScrollBars.au3> ;_____________________ SETTINGS ______________________________ global $players=2 global $multiply=5 ; Movement speed global $jump=60 global $ground=10 global $gravity=1 global $jet_depleat=1 global $jet_refill=0.4 global $jet_fuel=200 global $max_bullets=4 global $bullet_speed=2 global $start_jet=$jet_fuel ;_____________________________________________________________ global $me=0 global $SHOWSCROLLBARS=0 Global $m_width =@DesktopWidth, $m_height = 740 global $player_img_height=67 global $player_img_width=44 global $height=$m_height-$player_img_height global $width=$m_width-90 global $MAP_width=2000 global $scroll_width=$MAP_width/1.87 global $MAP_x=0 global $display[$players] global $pos[$players][2] global $pd[$players][1] ;____________________KEYS_________________________________________ global $d[1][4] $d[0][0] = 25; left $d[0][1] = 27;right $d[0][2] = 26; up $d[0][3] = 28; down Opt("GUIOnEventMode", 1) ;_________________________________________________________________________________ $dll = DllOpen("user32.dll") ; no child gui or no controls exceeding the width/height of the window ;~ Global $c_width = 0, $c_height = 0, $c_left = 0, $c_top = 0 Local $nFileMenu, $nExititem, $GUIMsg, $h_cGUI, $h_cGUI2 Local $listview, $button ;___________________________________________________________________________________________________ ;_____________________________________ GUI __________________________________________________________ ;___________________________________________________________________________________________________ ;GUIRegisterMsg($WM_CREATE, "MY_WM_CREATE") if $SHOWSCROLLBARS then GUIRegisterMsg($WM_SIZE, "MY_WM_SIZE"); SCROLLBARS!!!! (SHOWTHEM)!!!!!!!!!!!!!!!!!!!! global $hGUI = GUICreate('Game', $m_width, $m_height, -1, -1, BitOR($WS_MAXIMIZE, $WS_POPUPWINDOW, $WS_SYSMENU));, $WS_VSCROLL, $WS_HSCROLL GUISetOnEvent($GUI_EVENT_CLOSE, 'quit') GUISetCursor(16,1,$hGUI); No cursor GUISetBkColor(0x88AABB) ;$nFileMenu = GUICtrlCreateMenu("File") ;$nExititem = GUICtrlCreateMenuitem("Exit", $nFileMenu) GUICtrlCreatePic('background.jpg', 0,0, $MAP_width, $m_height+10); !!!!!!!!! for $i=0 to $players-1 $pd[$i]['f']=$start_jet $pos[$i][0]=30 $pos[$i][1]=$ground $display[$i]=GUICtrlCreatePic('merlin.gif', $pos[$i][0], $height-$pos[$i][1], $player_img_width, $player_img_height);@Systemdir & "\oobe\images\ next global $bullets[$players][$max_bullets][5] for $plr=0 to $players-1 for $i=0 to $max_bullets-1 $bullets[$plr][$i][0]=GUICtrlCreatePic('bullet.gif', -20, -20, 20, 20) $bullets[$plr][$i][1]=-20; x $bullets[$plr][$i][2]=-20;y $bullets[$plr][$i][3]=0; Gradient $bullets[$plr][$i][4]=0 next next GUISetState() ;______________________________CURSOR GUI __________________________________________________________________ $cursor=GUICreate("", 20, 20, 50, 90,$WS_POPUP,BitOr($WS_EX_LAYERED,$WS_EX_MDICHILD),$hGUI) GUISetCursor(16,1,$cursor) GUISetOnEvent ($GUI_EVENT_PRIMARYDOWN, 'onclick',$cursor ) GUICtrlCreatePic('cursor.gif', 0, 0, 20, 20) GUISetState(@SW_SHOW, $cursor) GUISetOnEvent($GUI_EVENT_CLOSE, 'quit') ;___________________________ STATUS BAR GUI ____________________________________________________________________ $gui_status=GUICreate("", $m_width, 20, 0, $m_height+10, BitOR($WS_SYSMENU,$WS_POPUPWINDOW,$WS_BORDER), BitOR($WS_EX_TOPMOST, $WS_EX_TOOLWINDOW)) Local $a_PartsRightEdge[6] = [100, 200, 300, 400, 500, 700] Local $a_PartsText[6] = ['Health: 100%','Jet: 100%', 'Amo: 100%', 'Player 1:', 'Map:'] Global $StatusBar1 =_GUICtrlStatusBar_Create ($gui_status, $a_PartsRightEdge, $a_PartsText) _GuiCtrlStatusBar_SetIcon ($StatusBar1, 1, "shell32.dll", 168) _GuiCtrlStatusBar_SetIcon ($StatusBar1, 0, "shell32.dll", 21) GUISetOnEvent($GUI_EVENT_CLOSE, 'quit') GUISetState() ;___________________________________________________________________________________________________ __________ GUISwitch($hGUI) _GUIScrollBars_SetScrollRange ($hGUI, $SB_HORZ, 0, $scroll_width) while 1 move() cursor() bullets() sleep(1) wend exit ;================================ MOVE ======================================================================== func move() $x=$pos[$me][0] $y=$pos[$me][1] ;______________________ LEFT _________________________________________ If _IsPressed ($d[$me][0], $dll) then if ($pos[$me][0]>=$MAP_x)=0 AND $MAP_x>0 then movemap(-1) else if $pos[$me][0]>0 then $pos[$me][0]-=$multiply endif endif ;______________________ RIGHT ________________________________________ If _IsPressed ($d[$me][1], $dll) then if ($pos[$me][0]<$MAP_x+$width-$player_img_width)=0 AND $MAP_x<$scroll_width-$width then movemap(1) else if $pos[$me][0]<$scroll_width+$player_img_width then $pos[$me][0]+=$multiply endif endif ;______________________ UP (JUMP) _______________________________________________________________ If _IsPressed ($d[$me][2], $dll) AND $pos[$me][1]<=$ground then $pos[$me][1]+=$jump ;______________________ FLY _____________________________________________________________________ $i=GUIGetCursorInfo ($hGUI) $temp_pdf=$pd[$i]['f'] if $i[3] AND $pd[$i]['f']>=1 then $pos[$me][1]+=2 $pd[$i]['f']-=$jet_depleat else if $pd[$i]['f']<$jet_fuel then $pd[$i]['f']+=$jet_refill endif endif ;____________________ Come down _____________________________________________ for $t=0 to $players-1 if $pos[$t][1]>$ground then $pos[$t][1]-=$gravity endif next if $pd[$me]['f']<>$temp_pdf then _GuiCtrlStatusBar_SetText ($StatusBar1, 'Jet: '&Round($pd[$me]['f']/$jet_fuel*100)&'%', 1) endif ;_______________________________________________________________________ if $pos[$me][0]<>$x OR $pos[$me][1]<>$y then moveplayer($me) endif EndFunc ;=========================================== MOVE PLAYER ====================================== func moveplayer($plr) GUICtrlSetPos($display[$me], $pos[$me][0]-$MAP_x, $height-$pos[$me][1]) _GuiCtrlStatusBar_SetText ($StatusBar1, 'Player 1: '&$pos[$me][0]&'x'&$pos[$me][1], 3) endfunc func movemap($ammount) $MAP_x+=$ammount*$multiply _SetScrollPos ($hGUI, $SB_HORZ, $MAP_x) _GuiCtrlStatusBar_SetText ($StatusBar1, 'Map: '&$MAP_x, 4) endfunc ;========================= CURSOR =============================================================== func cursor() $c=MouseGetPos() WinMove($cursor,"",$c[0]-10, $c[1]-10) endfunc ;=========================== BULLETS============================================================== func bullets() for $plr=0 to $players-1 for $i=0 to $max_bullets-1 if $bullets[$plr][$i][1]>-20 then $bullets[$plr][$i][1]+=$bullets[$plr][$i][3] $bullets[$plr][$i][2]+=$bullets[$plr][$i][4] if $bullets[$plr][$i][1]>$MAP_width OR $bullets[$plr][$i][1]<0 _ OR $bullets[$plr][$i][0]>$height OR $bullets[$plr][$i][1]<0 then $bullets[$plr][$i][1]=-20 else GUICtrlSetPos($bullets[$plr][$i][0], $bullets[$plr][$i][1]-$MAP_x, $height-$bullets[$plr][$i][2]) endif endif next next endfunc ;================== ON FIRE (click) ============================================================== func onclick() ;_____________ LOCATE BULLET TO USE ________________________________ local $bn=-1 for $i=0 to $max_bullets-1 if $bullets[$me][$i][1]=-20 then $bn=$i exitloop endif next if $bn=-1 then return ;___________________ DIRECTION _____________________________________ $start_x=$pos[$me][0]+$player_img_width/2 $start_y=$pos[$me][1]-$player_img_height/2 $cursorinfo=GUIGetCursorInfo($hGUI) $xdist=$cursorinfo[0]-$pos[$me][0]; cursor- start_pos $ydist=($start_y+$m_height)-$cursorinfo[1]; (startpos) - cursor $grad=$ydist/$xdist $bullets[$me][$bn][1]=$start_x $bullets[$me][$bn][2]=$start_y $bullets[$me][$bn][3]=$bullet_speed/Sqrt(expo($grad,2)+1) $bullets[$me][$bn][4]=$grad*($bullet_speed/Sqrt(expo($grad,2)+1)) ;_GuiCtrlStatusBar_SetText ($StatusBar1, 'Bullet: '&$dist_x&'x'&$dist_y&' '&round($grad,2)&'x'&round($grado,2), 5) ;fire! endfunc func expo($n, $exp) $r=$n for $i=1 to ($exp-1) $r*=$n next return $r endfunc ;============================================= func quit() exit $crash=$problem+1 endfunc
  7. I like the way your GUI is done along with the angles. While I realise that you are still writing the code and the final code may be neater, it may be easier to code things slightly differently. - The positions of both slimes should be in an array (you can use a simple loop to handle both slimes [moving the slime, ball movements etc]) - The arrays that contain the slimes should also contain the coordinates of the slime (so the array should look something like $slime[player][coordinate] - where player is 0 or 1 and coordinate is 0 or 1 (where x is 0 and y is 1) There are a few quick changes which you probably have not got around to yet however would be useful. - Start with the slime and ball on the left in the centre of that section - When the ball touches the ground have text with the number of deaths and increment this and start a new game [or code the part for points and look at which side of the net it is]. - Allow anywhere to be clicked when starting a game (rather than only the text displayed) - Fix the bug where you can't use escape or alt+f4 to close the game once you have started (it may be useful to have this as an option [it might make testing it nicer however you might want to disable this for the completed version. I originally posted the following under Collision Detector. You can detect the collision by measuring the distance between the two circles using the coordinates of the centres using distance=sqrt( (x2-x1)^2 + (y2-y1)^2) If the distance is equal to (or less than) the sum of the radius of both circles than a collision has occurred. - In your case one of the objects is a semicircle (so you don't have the bottom of this circle). So if the vertical coordinate of the circle [y1] is less than that of the semicircle [y2] then you should use distance_x=abs(x2-x1) - in a collision this will be equal to (or less than) the sum of the radii of both circles distance_y=y2-y1 - in a collision this will be equal to (or less than) the radius of the circle [no need for the absolute value because this method is only used when the conditions are met (the circle is below the semicircle, y1<y2)] For a collision both the horizontal and vertical conditions must be satisfied (If you are using a coordinate system where the y values get smaller as you go up you need to change the calculations and conditions around [or just swap y1 for y2]. Your current code that you have posted does not appear to handle the part where the ball is below the slime that well. However it can handle when the ball is above the slime (with a few issues)
  8. You can detect the collision by measuring the distance between the two circles using the coordinates of the centres using distance=sqrt( (x2-x1)^2 + (y2-y1)^2) If the distance is equal to (or less than) the sum of the radius of both circles than a collision has occurred. - In your case one of the objects is a semicircle (so you don't have the bottom of this circle). So if the vertical coordinate of the circle [y1] is less than that of the semicircle [y2] then you should use distance_x=abs(x2-x1) - in a collision this will be equal to (or less than) the sum of the radii of both circles distance_y=y2-y1 - in a collision this will be equal to (or less than) the radius of the circle [no need for the absolute value because this method is only used when the conditions are met (the circle is below the semicircle, y1<y2)] For a collision both the horizontal and vertical conditions must be satisfied (If you are using a coordinate system where the y values get smaller as you go up you need to change the calculations and conditions around [or just swap y1 for y2]. Your current code that you have posted Slime Volleyball, Slime Volleyball with collision detection! does not appear to handle the part where the ball is below the slime that well. However it can handle when the ball is above the slime (with a few issues)
  9. Your http string replace code was useful as a guide to code a better version of that part func stringtohttp($str) for $i=33 to 47 $str=stringreplace($str, chr($i), '%'&hex($i, 2)) next for $i=58 to 64 $str=stringreplace($str, chr($i), '%'&hex($i, 2)) next $str=StringReplace ($str, ' ', '+') return ($str) endfunc
  10. You can integrate firefox as an object (see automating Mozilla/Firefox) - (for the properties and methods that might be relevant try the web or the source code for firefox / the activex control)
  11. The fixed SocketToIp function should be included with autoitscript
  12. I need a way of getting the time more accurately from my computes clock (preferably in milliseconds). Currently I can only get the time to the second using @sec I have noticed that cmd can give the time to the hundredth of a second (using echo %time%) I was thinking about calling it to get the time, but there is a bit of delay with this method. I am sure there is a simple way of doing this however I have not been able to find it.
  13. I run a server on port 80, but I dont want to open port 80 to the web or run my server locally on 81, so I wrote this program, it works by: Getting the request from the client Sending the request to the server Getting the servers response Sending the servers response to the client $port=81 ; remote TCPStartup() $mainsocket= TCPListen('', $port, 100) ; I know it probably should be @ipaddress1, however localhost + 127.0.0.1 did not work until i made it blank (before my ip worked, and it still does) If $mainsocket = -1 Then $err = @error MsgBox(16, "Error", "Unable to connect." & @CRLF & @CRLF & "dec: " & $err & @CRLF & "hex: 0x" & Hex($err, 8)) EndIf While 1 $socket = TCPAccept($mainsocket); If $socket >= 0 Then $recv = TCPRecv($socket, 1000000) ;_________________ SERVER ______________________________ $server_con=TCPConnect (@IPADDRESS1, 80) if $server_con=0 OR @ERROR then msgbox(0,'Error','could not connect to local sever') exit endif TCPSend($server_con,$recv) $server_recv='' $i=0 $newrecv=1 while ($server_recv='' OR $newrecv=1) AND $i<1000 $i=$i+1 $len=stringlen($server_recv) $server_recv&=TCPRecv($server_con, 10000000) if StringLen($server_recv)>$len then $newrecv=1 else $newrecv=0 endif sleep(10) wend TCPSend($socket, $server_recv) TCPCloseSocket($server_con) ;_______________________________________________ TCPCloseSocket($socket) endif sleep(100) wend My web server was taking ages to do ajax autocomplete, and now its instant through this, dont know why but it works!.
×
×
  • Create New...