runthis Posted September 24, 2011 Share Posted September 24, 2011 I thought this deserved a reply. This seems like a much better alternative http://www.thomasfrank.se/text_color_gradients.html Quote Link to comment Share on other sites More sharing options...
Djkanna Posted September 25, 2011 Share Posted September 25, 2011 (edited) Why would he need to read it easier, hes plugging into a functions page and never looking at it again except maybe to change the colors. Also, take a closer look, mine is alot easier to read, all you need to know is the name, and colors. I believe, people like to learn from code posted on here, therefore your code (all scrunched up, on-liner doing all the work) is unreadable to most. $newName = ''; not needed to dot-add in php Yes it is, otherwise it will throw an undefined variable notice. Let me guess you develop with notices turned off? (not wise & lazy) At the whitespace comments: Personal preference, once again I enjoy the fact that my code can be read by other people. ;) -DJK. Edited September 25, 2011 by Djkanna Added Whitespace answer. Quote Link to comment Share on other sites More sharing options...
SMOKEY_TEK Posted September 29, 2011 Author Share Posted September 29, 2011 Okay, I know I am asking a lot, but how would I go about getting different colors up to 16 different colors? For example: SMEXEH JAMES Quote Link to comment Share on other sites More sharing options...
rulerofzu Posted September 29, 2011 Share Posted September 29, 2011 Place the colors in an array. Or you could write a function like I have done where you can allow the player to select x amount of colors, font style, font variation and pull it all from a database table. Quote Link to comment Share on other sites More sharing options...
Djkanna Posted September 29, 2011 Share Posted September 29, 2011 If you take from the code I posted before, you could try; <?php $username = 'Smokey'; $colours = array ( '#FFF', '#000', '#eee' ); //Add more... $newName = ''; for ($i = 0; $i < strlen($username); $i++) { $newName .= '<span style="color: '.$colours[array_rand($colours)].'">'.$username[$i].'</span>'; } echo $newName; ?> To generate a random value of that colours array and use that value as that characters colour, however this will change each page load, and has the possibility to pick the exact same colour for each character. (script it untested but should work fine.) Quote Link to comment Share on other sites More sharing options...
SMOKEY_TEK Posted September 29, 2011 Author Share Posted September 29, 2011 I play this some what new text-based game, all mostly in Javascript and Ajax. And they have a custom name where you can pick a color and then pick a letter for where you want that color at, and so on.. Just not really certain on how to do this.. I really like the idea that they have, and want to incorporate that into my game if I'm able to find a solution to it. Quote Link to comment Share on other sites More sharing options...
newttster Posted September 30, 2011 Share Posted September 30, 2011 I'm not sure but couldn't you do something with a drop down for the colours and the letters. Click the alphabet drop down, choose letter A then click the colour drop down, choose your colour, then do an update. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.