### Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.

### Messages - SBlectric

Pages: 1 2 3 [4]
46
##### Off Topic / Re: Create your own robot
« on: 2011-Dec-27 »
That looks neat

47
##### Off Topic / Re: Merry Christmas Guys!
« on: 2011-Dec-27 »
Merry Late Christmas!

48
##### Code Snippets / 3D Distance
« on: 2011-Dec-27 »
2nd post...
For any 3D game you need to know the distance between two objects, there is this function I made:

Code: (glbasic) [Select]
`FUNCTION Distance3D: x1,y1,z1, x2,y2,z2RETURN SQR( POW(x2-x1,2) + POW(y2-y1,2) + POW(z2-z1,2) )ENDFUNCTION`
Enjoy!

49
##### Code Snippets / Command Line Seperator function
« on: 2011-Dec-27 »
My first post! Woo!

When I call GETCOMMANDLINE\$() the commands are separated by either quotes (if they contain spaces) or just by spaces. Here is a function that will separate each one into elements of an array.

Check it out.

Code: (glbasic) [Select]
`FUNCTION CmdLine: cmd\$,e\$[]LOCAL a%,b%,exit%,pos%,endpos%cmd\$=REPLACE\$(cmd\$,CHR\$(92),"/")DIM e\$[0]WHILE 1IF pos>LEN(cmd\$)-1 THEN BREAKSELECT ASC(MID\$(cmd\$,pos,1))CASE 34 // if the value is an open quoteb=INSTR(cmd\$,CHR\$(34),pos+1) IF b<pos+1 endpos=-1 exit=1 ELSE endpos=b-1-(pos) ENDIFDIMPUSH e\$[],MID\$(cmd\$,pos+1,endpos)pos=b+1CASE 32 // if it's a spaceINC pos,1DEFAULT // if it's any other characterb=INSTR(cmd\$,CHR\$(32),pos) IF b<pos+1 endpos=-1 exit=1 ELSE endpos=b-1-(pos-1) ENDIFDIMPUSH e\$[],MID\$(cmd\$,pos,endpos)pos=bENDSELECTIF exit THEN BREAKWENDENDFUNCTION`

Pages: 1 2 3 [4]