Search Results

Search found 41 results on 2 pages for 'ggg'.

Page 1/2 | 1 2  | Next Page >

  • Determining whether values can potentially match a regular expression, given more input

    - by Andreas Grech
    I am currently writing an application in JavaScript where I'm matching input to regular expressions, but I also need to find a way how to match strings to parts of the regular expressions. For example: var invalid = "x", potentially = "g", valid = "ggg", gReg = /^ggg$/; gReg.test(invalid); //returns false (correct) gReg.test(valid); //returns true (correct) Now I need to find a way to somehow determine that the value of the potentially variable doesn't exactly match the /^ggg$/ expression, BUT with more input, it potentially can! So for example in this case, the potentially variable is g, but if two more g's are appended to it, it will match the regular expression /^ggg$/ But in the case of invalid, it can never match the /^ggg$/ expression, no matter how many characters you append to it. So how can I determine if a string has or doesn't have potential to match a particular regular expression?

    Read the article

  • What is a good way to store tilemap data?

    - by Stephen Tierney
    I'm developing a 2D platformer with some uni friends. We've based it upon the XNA Platformer Starter Kit which uses .txt files to store the tile map. While this is simple it does not give us enough control and flexibility with level design. Some examples: for multiple layers of content multiple files are required, each object is fixed onto the grid, doesn't allow for rotation of objects, limited number of characters etc. So I'm doing some research into how to store the level data and map file. This concerns only the file system storage of the tile maps, not the data structure to be used by the game while it is running. The tile map is loaded into a 2D array, so this question is about which source to fill the array from. Reasoning for DB: From my perspective I see less redundancy of data using a database to store the tile data. Tiles in the same x,y position with the same characteristics can be reused from level to level. It seems like it would simple enough to write a method to retrieve all the tiles that are used in a particular level from the database. Reasoning for JSON/XML: Visually editable files, changes can be tracked via SVN a lot easier. But there is repeated content. Do either have any drawbacks (load times, access times, memory etc) compared to the other? And what is commonly used in the industry? Currently the file looks like this: .................... .................... .................... .................... .................... .................... .................... .........GGG........ .........###........ .................... ....GGG.......GGG... ....###.......###... .................... .1................X. #################### 1 - Player start point, X - Level Exit, . - Empty space, # - Platform, G - Gem

    Read the article

  • 2D Tile Map files for Platformer, JSON or DB?

    - by Stephen Tierney
    I'm developing a 2D platformer with some uni friends. We've based it upon the XNA Platformer Starter Kit which uses .txt files to store the tile map. While this is simple it does not give us enough control and flexibility with level design. Some examples: for multiple layers of content multiple files are required, each object is fixed onto the grid, doesn't allow for rotation of objects, limited number of characters etc. So I'm doing some research into how to store the level data and map file. Reasoning for DB: From my perspective I see less redundancy of data using a database to store the tile data. Tiles in the same x,y position with the same characteristics can be reused from level to level. It seems like it would simple enough to write a method to retrieve all the tiles that are used in a particular level from the database. Reasoning for JSON: Visually editable files, changes can be tracked via SVN a lot easier. But there is repeated content. Do either have any drawbacks (load times, access times, memory etc) compared to the other? And what is commonly used in the industry? Currently the file looks like this: .................... .................... .................... .................... .................... .................... .................... .........GGG........ .........###........ .................... ....GGG.......GGG... ....###.......###... .................... .1................X. #################### 1 - Player start point, X - Level Exit, . - Empty space, # - Platform, G - Gem

    Read the article

  • Loading levels from .txt or .XML for XNA

    - by Dave Voyles
    I'm attemptin to add multiple levels to my pong game. I'd like to simply exchange a few elements with each level, nothing crazy. Just the background texture, the color of the AI paddle (the one on the right side), and the music. It seems that the best way to go about this is by utilizing the StreamReader to read and write the files from XML. If there is a better, or more efficient alternative way then I'm all for it. In looking over the XNA Starter Platformer Kit provided by MS it seems that they've done it in this manner as well. I'm perplexed by a few things, however, namely parts within the Level class which aren't commented. /// <summary> /// Iterates over every tile in the structure file and loads its /// appearance and behavior. This method also validates that the /// file is well-formed with a player start point, exit, etc. /// </summary> /// <param name="fileStream"> /// A stream containing the tile data. /// </param> private void LoadTiles(Stream fileStream) { // Load the level and ensure all of the lines are the same length. int width; List<string> lines = new List<string>(); using (StreamReader reader = new StreamReader(fileStream)) { string line = reader.ReadLine(); width = line.Length; while (line != null) { lines.Add(line); if (line.Length != width) throw new Exception(String.Format("The length of line {0} is different from all preceeding lines.", lines.Count)); line = reader.ReadLine(); } } What does width = line.Length mean exactly? I mean I know how it reads the line, but what difference does it make if one line is longer than any of the others? Finally, their levels are simply text files that look like this: .................... .................... .................... .................... .................... .................... .................... .........GGG........ .........###........ .................... ....GGG.......GGG... ....###.......###... .................... .1................X. #################### It can't be that easy..... Can it?

    Read the article

  • How do I flip a column in mysql that has data structured: 'last name, first name'?

    - by ggg
    I want to create a new column in a MYSQL table that has Fn Ln instead of Ln, Fn. Most of my data is printed Fn Ln. Another idea is to incorporate a string function each time there is an output (php based) but that seems to waste resources. Finally, I couldn't find the syntax (loop or foreach) for my php function anyway. Here is the working php function that I got from a previous post: $name = "Lastname, Firstname"; $names = explode(", ", $name); $name = $names[1] . " " . $names[0];

    Read the article

  • What is the proper PHP syntax to post a file that exists in a directory that's on the server?

    - by ggg
    This is a basic post form in PHP that loads from the client PC. What is the proper syntax to load from a directory on the server? <form enctype="multipart/form-data" action="index.php?option=com_productionparse" method="POST"> <input type="hidden" name="MAX_FILE_SIZE" value="90000000000" /><br /> Choose a file to upload: <input name="file" size=120 type="file" /><br /> <input type="submit" value="Upload File" /> </form>

    Read the article

  • How do I code a loop for my echo statement?

    - by ggg
    I get only one printed result in the foreach echo loop at the bottom of the page. <?php defined('_JEXEC') or die('Restricted access'); $db =& JFactory::getDBO(); $query0 = "SELECT * FROM `jos_ginfo` WHERE . . . LIMIT 30"; //echo $query0; $db->setQuery($query0); $ginfo = $db->loadObjectList(); //echo //$ginfo[0]; foreach($ginfo as $ginfo[$i]): {$i=0; $i++;} endforeach; echo $db->getErrorMsg(); if(empty($ginfo)){ echo "<center>No game found, try a different entry.</center>"; }else{ $pgndata = array ( $ginfo[$i]->Id); $i=0; foreach($pgndata as $ginfo[$i]->Id): //I am only getting one printed result! { echo "<a href='/index.php?option=com_publishpgn&tactical-game=".$ginfo[$i]->Id."&Itemid=78.html'>\n"; echo "".$ginfo[$i]->White." v. ".$ginfo[$i]->Black." (".$ginfo[$i]->Result.") ".$ginfo[$i]->EventDate." ECO:".$ginfo[$i]->ECO."</a><br>\n"; $i++; } endforeach; //echo "</div>"; } ?>

    Read the article

  • How do I apply a string function to an array?

    - by ggg
    I was fortunate enough to receive this code (flips Lastname, Firstname) from an earlier post. $name = "Lastname, Firstname"; $names = explode(", ", $name); $name = $names[1] . " " . $names[0]; How do I apply the function to each value in an array that is in the form: $ginfo ->$(LastName, FirstName). I tried the code below, but it doesn't work. $name1 =($ginfo->White); $name1 = explode(", ", $name1); $FLw = $name1[1] . " " . $name1[0]; foreach ($name1 as ($ginfo->White)) {return($FLw);}

    Read the article

  • How do I code a loop for my echo statements?

    - by ggg
    <?php defined('_JEXEC') or die('Restricted access'); $db =& JFactory::getDBO(); $query0 = "SELECT * FROM `#__chesspositions` WHERE . . . . ."; //echo $query0; $db->setQuery($query0); $ginfo = $db->loadObjectList(); //echo $ginfo[0]; echo $db->getErrorMsg(); if(empty($ginfo)){ echo "<center><h2 style='color:navy'>No game found, we apologize</h2></center>"; }else{ $query1= "SELECT * FROM `#__chessmoves` WHERE Id='".$ginfo[0]->MoveDataId."'"; $db->setQuery($query1); echo $db->getErrorMsg(); $gmove = $db->loadObjectList(); } //define array; //how do I code a foreach loop (or any other type of loop) here? //I'm having trouble properly defining the array and structuring the syntax. echo "[Event \"".$ginfo[0]->Event."\"]\n"; echo "[Site \"".$ginfo[0]->Site."\"]\n"; echo "[Date \"".$ginfo[0]->Date."\"]\n"; echo "[Round \"".$ginfo[0]->Round."\"]\n"; echo "[White \"".$ginfo[0]->White."\"]\n"; echo "[Black \"".$ginfo[0]->Black."\"]\n"; echo "[Result \"".$ginfo[0]->Result."\"]\n"; echo "[ECO \"".$ginfo[0]->ECO."\"]\n"; echo "[WhiteElo \"".$ginfo[0]->WhiteElo."\"]\n"; echo "[BlackElo \"".$ginfo[0]->BlackElo."\"]\n"; echo "[Annotator \"".$ginfo[0]->Annotator."\"]\n"; echo "[SetUp \"".$ginfo[0]->SetUp."\"]\n"; echo $gmove[0]->MoveData; ?>

    Read the article

  • Best way for saving infinit playlists (arrays) into db? (php mySql)

    - by Ole Jak
    So client gives me a string like "1,23,23,abc,ggg,544,tf4," from user 12 . There can be infinit number of elements with no spaces just value,value,... structure. I have users table (with users uId(key), names etc). I have streams table with ( sId(key), externalID, etc values). User sends me externalId's. And I need to hawe externalId's in play list (not my sId's). I need some way to store such array into my DB and be able to get it from DB. I need to be able to do 2 things return such string back to user be able to get na array from it like {1; 23; 23; abc; ggg; 544; tf4;} So what is best method (best here means shourt(small amount of) code) to store such data into db to retrivew stored tata in bouth ways shown

    Read the article

  • How to display node name in Action script 3 xml

    - by Mirage
    My xml is like below <rat> <to>tt</to> <from>ggg</from> <heading>hhhhh</heading> <body>jjj</body> </rat> My AS3 code is var example:XML = new XML(event.target.data); _label.text = example[0].rat[0][nodeName]; addChild(_label); I want to display the data like to = tt from = ggg how can i do that

    Read the article

1 2  | Next Page >