Search Results

Search found 16 results on 1 pages for 'm28'.

Page 1/1 | 1 

  • Algorithm to make groups of units

    - by M28
    In Age of Mythology and some other strategy games, when you select multiple units and order them to move to some place, they make a "group" when they reach the desired location: I have a Vector with several sprites, which are the selected units, the variables tarX and tarY are the target x and y. I just want an example, so you can just set the x and y position and I can adapt it to my code. Also, I would like to ask that the algorithm calls "isWalkable" for the x and y position, to determine if it's a valid position for each unit.

    Read the article

  • Collision Detection for Actionscript 3

    - by M28
    Well, I was searching for a simple collision detection function for as3, I found Collision Detection Kit, but it is too complicated, I just want a damn function that I give 2 objects as paramenters and that's it. I would like to know where can I find a pixel-perfect collision detection function (The faster, the better)

    Read the article

  • Regex is capturing the whole string

    - by M28
    I am using the following regex: (public|private +)?function +([a-zA-Z_$][0-9a-zA-Z_$]*) *\\(([0-9a-zA-Z_$, ]*)\\) *{(.*)} To match the following string: public function messenger(text){ sendMsg(text); } private function sendMsg(text){ alert(text); } (There is no line breaks in the string, they are converted to whitespaces before the regex runs) I wanted it to capture both functions, but it is capturing: $1: "" $2: "messenger" $3: "text" $4: " sendMsg(text); } private function sendMsg(text){ alert(text); " By the way, I am using Javascript.

    Read the article

  • Strange php problem

    - by M28
    The following code: print_r($_GET); echo '<br />'; echo isset($_GET['logout'])?'yes':'no'; prints: Array ( [logoout] => ) no Why is it printing "no" instend of "yes"?

    Read the article

  • Make character escape from shot

    - by M28
    Hello all math masters, I got a problem for you: I have a 2D game (top down), and I would like to make the character escape from a shot, but not just walk away from the shot (I mean, don't be pushed by the shot), I want it to have a good dodging skills. The variables are: shotX - shot x position shotY - shot y position shotSpeedX - shot x speed shotSpeedY - shot x speed charX - character x position charY - character y position keyLeft - Set to true to make the character press the to left key keyRight - Set to true to make the character press the to right key keyUp - Set to true to make the character press the to up key keyDown - Set to true to make the character press the down key I can understand the following languages: C/C++ Java Actionscript 2/3 Javascript

    Read the article

  • Simple Hexadecimal color question

    - by M28
    I have a number between 0.0 and 1.0, I would like to convert it to a grayscale color. White = 0 Black = 1 You can show me how in any understandable language (I prefer actionscript 3) Please, don't just give a name of a function that a language have to do this, I want to know how it does.

    Read the article

  • Generate syntax tree for simple math operations

    - by M28
    I am trying to generate a syntax tree, for a given string with simple math operators (+, -, *, /, and parenthesis). Given the string "1 + 2 * 3": It should return an array like this: ["+", [1, ["*", [2,3] ] ] ] I made a function to transform "1 + 2 * 3" in [1,"+",2,"*",3]. The problem is: I have no idea to give priority to certain operations. My code is: function isNumber(ch){ switch (ch) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': case '.': return true; break; default: return false; break; } } function generateSyntaxTree(text){ if (typeof text != 'string') return []; var code = text.replace(new RegExp("[ \t\r\n\v\f]", "gm"), ""); var codeArray = []; var syntaxTree = []; // Put it in its on scope (function(){ var lastPos = 0; var wasNum = false; for (var i = 0; i < code.length; i++) { var cChar = code[i]; if (isNumber(cChar)) { if (!wasNum) { if (i != 0) { codeArray.push(code.slice(lastPos, i)); } lastPos = i; wasNum = true; } } else { if (wasNum) { var n = Number(code.slice(lastPos, i)); if (isNaN(n)) { throw new Error("Invalid Number"); return []; } else { codeArray.push(n); } wasNum = false; lastPos = i; } } } if (wasNum) { var n = Number(code.slice(lastPos, code.length)); if (isNaN(n)) { throw new Error("Invalid Number"); return []; } else { codeArray.push(n); } } })(); // At this moment, codeArray = [1,"+",2,"*",3] return syntaxTree; } alert('Returned: ' + generateSyntaxTree("1 + 2 * 3"));

    Read the article

  • What functions a lexer needs to provide?

    - by M28
    I am making a lexer, don't tell me to not do because I already did most of it. Currently it makes an array of tokens and that's it. I would like to know, what functions the lexer needs to provide and a brief explanation of what each function needs to do. I'll accept the most complete list. An example function would be: next: Consume the current token and return it

    Read the article

  • Can't use "continue <label>"

    - by M28
    I am trying this code: entLoop:for(var i:*in entities) { for(var i2:*in ignoreEntities) { if(entities[i].type==ignoreEntities[i2]) { continue entLoop; } } } Why is it not working? The error is: Target of continue statement was not found.

    Read the article

  • Is there a way to stop all javascript on the page?

    - by M28
    I need to stop all the javascript running on the page, but I have a limitation: I cannot control the tags content, I am editing the page after it's being loaded. Also, I need to remove all the variables defined by the old script that was running and stop all the intervals.

    Read the article

1